Skip to content

Commit fd63f18

Browse files
Paolo Abenikuba-moo
authored andcommitted
ipv6: prevent possible UaF in addrconf_permanent_addr()
The mentioned helper try to warn the user about an exceptional condition, but the message is delivered too late, accessing the ipv6 after its possible deletion. Reorder the statement to avoid the possible UaF; while at it, place the warning outside the idev->lock as it needs no protection. Reported-by: Jakub Kicinski <[email protected]> Closes: https://sashiko.dev/#/patchset/8c8bfe2e1a324e501f0e15fef404a77443fd8caf.1774365668.git.pabeni%40redhat.com Fixes: f1705ec ("net: ipv6: Make address flushing on ifdown optional") Signed-off-by: Paolo Abeni <[email protected]> Link: https://patch.msgid.link/ef973c3a8cb4f8f1787ed469f3e5391b9fe95aa0.1774601542.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent dc9e9d6 commit fd63f18

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

net/ipv6/addrconf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,12 +3625,12 @@ static void addrconf_permanent_addr(struct net *net, struct net_device *dev)
36253625
if ((ifp->flags & IFA_F_PERMANENT) &&
36263626
fixup_permanent_addr(net, idev, ifp) < 0) {
36273627
write_unlock_bh(&idev->lock);
3628-
in6_ifa_hold(ifp);
3629-
ipv6_del_addr(ifp);
3630-
write_lock_bh(&idev->lock);
36313628

36323629
net_info_ratelimited("%s: Failed to add prefix route for address %pI6c; dropping\n",
36333630
idev->dev->name, &ifp->addr);
3631+
in6_ifa_hold(ifp);
3632+
ipv6_del_addr(ifp);
3633+
write_lock_bh(&idev->lock);
36343634
}
36353635
}
36363636

0 commit comments

Comments
 (0)