* [PATCH] ipv6: prevent possible NULL dereference in ndisc_recv_na()
@ 2024-07-16 2:15 Ma Ke
2024-07-16 2:30 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2024-07-16 2:15 UTC (permalink / raw)
To: davem, dsahern, edumazet, kuba, pabeni, johannes.berg
Cc: netdev, linux-kernel, Ma Ke
In ndisc_recv_na(), __in6_dev_get() could return NULL, which is a NULL
pointer dereference. Add a check to prevent bailing out.
Fixes: 7a02bf892d8f ("ipv6: add option to drop unsolicited neighbor advertisements")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
net/ipv6/ndisc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d914b23256ce..f7cafff3f6a9 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1000,6 +1000,8 @@ static enum skb_drop_reason ndisc_recv_na(struct sk_buff *skb)
struct ndisc_options ndopts;
struct net_device *dev = skb->dev;
struct inet6_dev *idev = __in6_dev_get(dev);
+ if (!idev)
+ return SKP_DROP_REASON_NOT_SPECIFIED;
struct inet6_ifaddr *ifp;
struct neighbour *neigh;
SKB_DR(reason);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ipv6: prevent possible NULL dereference in ndisc_recv_na()
2024-07-16 2:15 [PATCH] ipv6: prevent possible NULL dereference in ndisc_recv_na() Ma Ke
@ 2024-07-16 2:30 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2024-07-16 2:30 UTC (permalink / raw)
To: Ma Ke; +Cc: davem, dsahern, kuba, pabeni, johannes.berg, netdev, linux-kernel
On Mon, Jul 15, 2024 at 7:16 PM Ma Ke <make24@iscas.ac.cn> wrote:
>
> In ndisc_recv_na(), __in6_dev_get() could return NULL, which is a NULL
> pointer dereference. Add a check to prevent bailing out.
>
> Fixes: 7a02bf892d8f ("ipv6: add option to drop unsolicited neighbor advertisements")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> net/ipv6/ndisc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
> index d914b23256ce..f7cafff3f6a9 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -1000,6 +1000,8 @@ static enum skb_drop_reason ndisc_recv_na(struct sk_buff *skb)
> struct ndisc_options ndopts;
> struct net_device *dev = skb->dev;
> struct inet6_dev *idev = __in6_dev_get(dev);
> + if (!idev)
> + return SKP_DROP_REASON_NOT_SPECIFIED;
> struct inet6_ifaddr *ifp;
> struct neighbour *neigh;
> SKB_DR(reason);
Please do not mix code and variables.
Also, idev is correctly tested in the current code, therefore your
patch is not needed.
Thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-16 2:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16 2:15 [PATCH] ipv6: prevent possible NULL dereference in ndisc_recv_na() Ma Ke
2024-07-16 2:30 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox