Re: [PATCH v4] net: neighbor: fix a crash caused by mod zero

2020-12-28 Thread David Miller
From: weichenchen Date: Fri, 25 Dec 2020 13:44:45 +0800 > pneigh_enqueue() tries to obtain a random delay by mod > NEIGH_VAR(p, PROXY_DELAY). However, NEIGH_VAR(p, PROXY_DELAY) > migth be zero at that point because someone could write zero > to /proc/sys/net/ipv4/neigh/[device]/proxy_delay after

[PATCH v4] net: neighbor: fix a crash caused by mod zero

2020-12-24 Thread weichenchen
pneigh_enqueue() tries to obtain a random delay by mod NEIGH_VAR(p, PROXY_DELAY). However, NEIGH_VAR(p, PROXY_DELAY) migth be zero at that point because someone could write zero to /proc/sys/net/ipv4/neigh/[device]/proxy_delay after the callers check it. This patch uses prandom_u32_max() to get a