]> git.baikalelectronics.ru Git - kernel.git/commit
net: neighbor: fix a crash caused by mod zero
authorweichenchen <weichen.chen@linux.alibaba.com>
Fri, 25 Dec 2020 05:44:45 +0000 (13:44 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Dec 2020 22:49:48 +0000 (14:49 -0800)
commit458105c085be54d033ae686468a2104206f9606e
treeec36cd2b1aaea81ad270c0bb939a083d8a47829a
parent1e2acba54e78499ac613043a6935d04a994eeab2
net: neighbor: fix a crash caused by mod zero

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 random delay instead
which avoids potential division by zero.

Signed-off-by: weichenchen <weichen.chen@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/neighbour.c