Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bac169b authored by Eric Dumazet's avatar Eric Dumazet Committed by Sasha Levin
Browse files

net: fix a race in dst_release()



[ Upstream commit d69bbf88c8d0b367cf3e3a052f6daadf630ee566 ]

Only cpu seeing dst refcount going to 0 can safely
dereference dst->flags.

Otherwise an other cpu might already have freed the dst.

Fixes: 27b75c95 ("net: avoid RCU for NOCACHE dst")
Reported-by: default avatarGreg Thelen <gthelen@google.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent b2567c1c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ void dst_release(struct dst_entry *dst)

		newrefcnt = atomic_dec_return(&dst->__refcnt);
		WARN_ON(newrefcnt < 0);
		if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt)
		if (!newrefcnt && unlikely(dst->flags & DST_NOCACHE))
			call_rcu(&dst->rcu_head, dst_destroy_rcu);
	}
}