net/neighbour: fix potential null pointer deference
Subsystems (2)
PATCH 1/1 net/neighbour: fix potential null pointer deference
There is a possible null pointer deference bugs in neigh_fill_info(), which is similar to the bug which was fixed in commit 6adc5fd6a142 ("net/neighbour: fix crash at dumping device-agnostic proxy entries").
--- net/core/neighbour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/neighbour.c +1 -1
@@ -2440,7 +2440,7 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh, ndm->ndm_pad2 =0 ; ndm->ndm_flags = neigh->flags; ndm->ndm_type = neigh->type; - ndm->ndm_ifindex = neigh->dev->ifindex; + ndm->ndm_ifindex = neigh->dev ? neigh->dev->ifindex :0 ;if (nla_put (skb,NDA_DST , neigh->tbl->key_len, neigh->primary_key)) goto nla_put_failure;
Signature · 1 line
2.7.4
Quoted 3 lines · Young Xiao
There is a possible null pointer deference bugs in
neigh_fill_info(), which is similar to the bug which was fixed in commit6adc5fd6a142("net/neighbour: fix crash at dumping device-agnostic proxy entries").
Have you seen this in real life?
I see nobody who could produce neighbour with null device pointer._
Quoted 20 lines
Signed-off-by Young Xiao <[email protected]>--- net/core/neighbour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/core/neighbour.c +1
-1@@ -2440,7 +2440,7 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh, ndm->ndm_pad2 =0 ; ndm->ndm_flags = neigh->flags; ndm->ndm_type = neigh->type; - ndm->ndm_ifindex = neigh->dev->ifindex; + ndm->ndm_ifindex = neigh->dev ? neigh->dev->ifindex :0 ;if (nla_put (skb,NDA_DST , neigh->tbl->key_len, neigh->primary_key)) goto nla_put_failure;
Paolo Abeni
maintainerQuoted 14 lines · Young Xiao
There is a possible null pointer deference bugs in
neigh_fill_info(), which is similar to the bug which was fixed in commit6adc5fd6a142("net/neighbour: fix crash at dumping device-agnostic proxy entries").Signed-off-by Young Xiao <[email protected]>--- net/core/neighbour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/core/neighbour.c +0
-0
net/core/neighbour.c static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh, · line 2446
Quoted 8 lines
net/core/neighbour.c +1
-1@@ -2440,7 +2440,7 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh, ndm->ndm_pad2 =0 ; ndm->ndm_flags = neigh->flags; ndm->ndm_type = neigh->type; - ndm->ndm_ifindex = neigh->dev->ifindex; + ndm->ndm_ifindex = neigh->dev ? neigh->dev->ifindex :0 ;if (nla_put (skb,NDA_DST , neigh->tbl->key_len, neigh->primary_key)) goto nla_put_failure;
AFAICS, neigh->dev is requested to be != NULL at neighbour creation time (see ___neigh_create()), so the above NULL ptr dereference looks impossible. Am I missing something?
Thanks,
Paolo
Quoted 15 lines · Young Xiao
There is a possible null pointer deference bugs in
neigh_fill_info(), which is similar to the bug which was fixed in commit6adc5fd6a142("net/neighbour: fix crash at dumping device-agnostic proxy entries").Signed-off-by Young Xiao <[email protected]>--- net/core/neighbour.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/core/neighbour.c +0
-0
net/core/neighbour.c static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh, · line 2446
Quoted 8 lines
net/core/neighbour.c +1
-1@@ -2440,7 +2440,7 @@ static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh, ndm->ndm_pad2 =0 ; ndm->ndm_flags = neigh->flags; ndm->ndm_type = neigh->type; - ndm->ndm_ifindex = neigh->dev->ifindex; + ndm->ndm_ifindex = neigh->dev ? neigh->dev->ifindex :0 ;if (nla_put (skb,NDA_DST , neigh->tbl->key_len, neigh->primary_key)) goto nla_put_failure;
When was the bug added exactly ?
Hint : We want a Fixes: tag, so that we can fully understand the issue and make sure the fix is complete.
Otherwise, your patch might very well have been randomly generated by a bot.
Thank you.