ipv6: add NULL checks for idev in SRv6 paths
Subsystems (3)
PATCH 1/1 ipv6: add NULL checks for idev in SRv6 paths
From: Minhong He <[email protected]>
[ Upstream commit 06413793526251870e20402c39930804f14d59c0 ]
__in6_dev_get() can return NULL when the device has no IPv6 configuration (e.g. MTU < IPV6_MIN_MTU or after NETDEV_UNREGISTER).
Add NULL checks for idev returned by __in6_dev_get() in both seg6_hmac_validate_skb() and ipv6_srh_rcv() to prevent potential NULL pointer dereferences.
Fixes 1ababeba4a21 ("ipv6: implement dataplane support for rthdr type 4 (Segment Routing Header)")
Fixes bf355b8d2c30 ("ipv6: sr: add core files for SR HMAC support")
Signed-off-by Minhong He <[email protected]>
Reviewed-by Andrea Mayer <[email protected]>
Signed-off-by Jakub Kicinski <[email protected]>
Signed-off-by Li hongliang <[email protected]>
--- net/ipv6/exthdrs.c | 4 ++++ net/ipv6/seg6_hmac.c | 2 ++ 2 files changed, 6 insertions(+)
net/ipv6/exthdrs.c +4 -0
@@ -361,6 +361,10 @@ static int ipv6_srh_rcv(struct sk_buff *skb) hdr = (struct ipv6_sr_hdr *)skb_transport_header (skb); idev =__in6_dev_get (skb->dev); +if (!idev) { +kfree_skb (skb); +return -1 ; + } accept_seg6 = net->ipv6.devconf_all->seg6_enabled;if (accept_seg6 > idev->cnf.seg6_enabled)
net/ipv6/seg6_hmac.c +2 -0
@@ -245,6 +245,8 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb)struct inet6_dev *idev; idev =__in6_dev_get (skb->dev); +if (!idev) +return false; srh = (struct ipv6_sr_hdr *)skb_transport_header (skb);
Signature · 1 line
2.34.1