Skip to content

Commit 06a0716

Browse files
Ziyang Xuandavem330
authored andcommitted
ipv6/addrconf: fix a potential refcount underflow for idev
Now in addrconf_mod_rs_timer(), reference idev depends on whether rs_timer is not pending. Then modify rs_timer timeout. There is a time gap in [1], during which if the pending rs_timer becomes not pending. It will miss to hold idev, but the rs_timer is activated. Thus rs_timer callback function addrconf_rs_timer() will be executed and put idev later without holding idev. A refcount underflow issue for idev can be caused by this. if (!timer_pending(&idev->rs_timer)) in6_dev_hold(idev); <--------------[1] mod_timer(&idev->rs_timer, jiffies + when); To fix the issue, hold idev if mod_timer() return 0. Fixes: b7b1bfc ("ipv6: split duplicate address detection and router solicitation timer") Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Ziyang Xuan <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 51d03e2 commit 06a0716

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/ipv6/addrconf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,8 @@ static void addrconf_del_dad_work(struct inet6_ifaddr *ifp)
318318
static void addrconf_mod_rs_timer(struct inet6_dev *idev,
319319
unsigned long when)
320320
{
321-
if (!timer_pending(&idev->rs_timer))
321+
if (!mod_timer(&idev->rs_timer, jiffies + when))
322322
in6_dev_hold(idev);
323-
mod_timer(&idev->rs_timer, jiffies + when);
324323
}
325324

326325
static void addrconf_mod_dad_work(struct inet6_ifaddr *ifp,

0 commit comments

Comments
 (0)