]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipv6/addrconf: fix a potential refcount underflow for idev
authorZiyang Xuan <william.xuanziyang@huawei.com>
Sat, 8 Jul 2023 06:59:10 +0000 (14:59 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Aug 2023 09:33:44 +0000 (11:33 +0200)
commitc6395e32935d35e6f935e7caf1c2dac5a95943b4
tree3707c2aa41ccd1e9ed5873363f41cff8941f1462
parent401807fec2c5d7effa15b60ca7f8ef4f52fa4073
ipv6/addrconf: fix a potential refcount underflow for idev

[ Upstream commit 06a0716949c22e2aefb648526580671197151acc ]

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: b7b1bfce0bb6 ("ipv6: split duplicate address detection and router solicitation timer")
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv6/addrconf.c