Skip to content

Commit 1e3db30

Browse files
edumazetgregkh
authored andcommitted
ipv6: guard against possible NULL deref in __in6_dev_stats_get()
[ Upstream commit 507541c ] dev_get_by_index_rcu() could return NULL if the original physical device is unregistered. Found by Sashiko. Fixes: e1ae5c2 ("vrf: Increment Icmp6InMsgs on the original netdev") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Stephen Suryaputra <ssuryaextr@gmail.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20260526145529.3587126-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ec2644c commit 1e3db30

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

include/net/addrconf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@ static inline struct inet6_dev *__in6_dev_get(const struct net_device *dev)
334334
static inline struct inet6_dev *__in6_dev_stats_get(const struct net_device *dev,
335335
const struct sk_buff *skb)
336336
{
337-
if (netif_is_l3_master(dev))
337+
if (netif_is_l3_master(dev)) {
338338
dev = dev_get_by_index_rcu(dev_net(dev), inet6_iif(skb));
339+
if (!dev)
340+
return NULL;
341+
}
339342
return __in6_dev_get(dev);
340343
}
341344

0 commit comments

Comments
 (0)