Skip to content

Commit f31867d

Browse files
alexhenriedavem330
authored andcommitted
net: ipv6/addrconf: avoid integer underflow in ipv6_create_tempaddr
The existing code incorrectly casted a negative value (the result of a subtraction) to an unsigned value without checking. For example, if /proc/sys/net/ipv6/conf/*/temp_prefered_lft was set to 1, the preferred lifetime would jump to 4 billion seconds. On my machine and network the shortest lifetime that avoided underflow was 3 seconds. Fixes: 76506a9 ("IPv6: fix DESYNC_FACTOR") Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 151e887 commit f31867d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ipv6/addrconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
13781378
* idev->desync_factor if it's larger
13791379
*/
13801380
cnf_temp_preferred_lft = READ_ONCE(idev->cnf.temp_prefered_lft);
1381-
max_desync_factor = min_t(__u32,
1381+
max_desync_factor = min_t(long,
13821382
idev->cnf.max_desync_factor,
13831383
cnf_temp_preferred_lft - regen_advance);
13841384

0 commit comments

Comments
 (0)