Skip to contentSkip to conversation

oops in af_packet fanout mode

PATCH Superseded Eric Leblond 4 participants 7 messages Nov 6, 2012 – Nov 7, 2012

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/1 af-packet: fix oops when socket is not present

In reply to Eric Leblond

When skb->sk is NULL and when packet fanout is used, there is a crash in match_fanout_group where skb->sk is accessed. This patch fixes the issue by returning false as soon as the socket is NULL: this correspond to the wanted behavior because the kernel as to resend the skb to all the listening socket in this case.

---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index b4978e2..c7b5293 100644
@@ -1666,7 +1666,7 @@ static inline int deliver_skb(struct sk_buff *skb,
 
 static inline bool skb_loop_sk(struct packet_type *ptype, struct sk_buff *skb)
 {
-	if (ptype->af_packet_priv == NULL)
+	if ((ptype->af_packet_priv == NULL) || (skb->sk == NULL))
 		return false;
 
 	if (ptype->id_match)
Signature · 1 line
1.7.10.4
#0 lore raw

cover oops in af_packet fanout mode

Due to a NULL dereference, the following patch is causing oops in normal trafic condition:

commit c0de08d04215031d68fa13af36f347a6cfa252ca

Author: Eric Leblond <[email protected]>
Date:   Thu Aug 16 22:02:58 2012 +0000

af_packet: don't emit packet on orig fanout group

This patch was a feature fix and has reached most stable branches. The following patch fixes the issue and should be applied to branch containing the previous patch.

BR,
--
Eric Leblond <[email protected]>

#2 lore raw

Re: [PATCH 1/1] af-packet: fix oops when socket is not present

In reply to Eric Leblond
Quoted 17 lines · Eric Leblond

When skb->sk is NULL and when packet fanout is used, there is a crash in match_fanout_group where skb->sk is accessed. This patch fixes the issue by returning false as soon as the socket is NULL: this correspond to the wanted behavior because the kernel as to resend the skb to all the listening socket in this case.

---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +0 -0
index b4978e2..c7b5293 100644

net/core/dev.c static inline int deliver_skb(struct sk_buff *skb, · line 1669

Quoted 5 lines
net/core/dev.c +1 -1
@@ -1666,7 +1666,7 @@ static inline int deliver_skb(struct sk_buff *skb,
 
 static inline bool skb_loop_sk(struct packet_type *ptype, struct sk_buff *skb)
 {
-	if (ptype->af_packet_priv == NULL)
+	if ((ptype->af_packet_priv == NULL) || (skb->sk == NULL))

Why adding these parentheses ?

if (!ptype->af_packet_priv || !skb->sk)

net/core/dev.c static inline int deliver_skb(struct sk_buff *skb, · line 1672

Quoted 3 lines
net/core/dev.c +0 -0
 		return false;
 
 	if (ptype->id_match)

Your patch is technically correct, but misses extra information to ease stable team work.

Your previous mail with this useful information wont be part of the patch.

Please add this information in the changelog ?

Thanks

#3 lore raw

PATCH v2 1/1 af-packet: fix oops when socket is not present

Due to a NULL dereference, the following patch is causing oops in normal trafic condition:

commit c0de08d04215031d68fa13af36f347a6cfa252ca
Author: Eric Leblond <[email protected]>
Date:   Thu Aug 16 22:02:58 2012 +0000

    af_packet: don't emit packet on orig fanout group

This buggy patch was a feature fix and has reached most stable branches.

When skb->sk is NULL and when packet fanout is used, there is a crash in match_fanout_group where skb->sk is accessed. This patch fixes the issue by returning false as soon as the socket is NULL: this correspond to the wanted behavior because the kernel as to resend the skb to all the listening socket in this case.

---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index b4978e2..83232a1 100644
@@ -1666,7 +1666,7 @@ static inline int deliver_skb(struct sk_buff *skb,
 
 static inline bool skb_loop_sk(struct packet_type *ptype, struct sk_buff *skb)
 {
-	if (ptype->af_packet_priv == NULL)
+	if (!ptype->af_packet_priv || !skb->sk)
 		return false;
 
 	if (ptype->id_match)
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH v2] af-packet: fix oops when socket is not present

Quoted 19 lines · Eric Leblond

Due to a NULL dereference, the following patch is causing oops in normal trafic condition:

commit c0de08d04215031d68fa13af36f347a6cfa252ca
Author: Eric Leblond <[email protected]>
Date:   Thu Aug 16 22:02:58 2012 +0000

    af_packet: don't emit packet on orig fanout group

This buggy patch was a feature fix and has reached most stable branches.

When skb->sk is NULL and when packet fanout is used, there is a crash in match_fanout_group where skb->sk is accessed. This patch fixes the issue by returning false as soon as the socket is NULL: this correspond to the wanted behavior because the kernel as to resend the skb to all the listening socket in this case.

Quoted 4 lines
---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>

#5 lore raw

Re: [PATCH v2] af-packet: fix oops when socket is not present

Quoted 25 lines · Greg KH
Quoted 19 lines · Eric Leblond

Due to a NULL dereference, the following patch is causing oops in normal trafic condition:

commit c0de08d04215031d68fa13af36f347a6cfa252ca

Author: Eric Leblond <[email protected]>
Date:   Thu Aug 16 22:02:58 2012 +0000

af_packet: don't emit packet on orig fanout group

This buggy patch was a feature fix and has reached most stable branches.

When skb->sk is NULL and when packet fanout is used, there is a crash in match_fanout_group where skb->sk is accessed. This patch fixes the issue by returning false as soon as the socket is NULL: this correspond to the wanted behavior because the kernel as to resend the skb to all the listening socket in this case.

Quoted 4 lines
---
 net/core/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>

Right.

By the way, David Miller prefers to handle stable submissions himself.

So Eric, I guess you could just do nothing for this particular patch, since your [email protected] addition in the CC will be void.

(Dont add the Cc: in the patch itself, as David will remove it anyway)

Thanks

maintainer
#6 lore raw

Re: [PATCH v2] af-packet: fix oops when socket is not present

In reply to Eric Leblond

From: Eric Leblond <[email protected]>
Date: Tue, 6 Nov 2012 13:10:10 +0100

Quoted 12 lines

Due to a NULL dereference, the following patch is causing oops in normal trafic condition:

commit c0de08d04215031d68fa13af36f347a6cfa252ca
Author: Eric Leblond <[email protected]>
Date:   Thu Aug 16 22:02:58 2012 +0000

    af_packet: don't emit packet on orig fanout group

This buggy patch was a feature fix and has reached most stable branches.

Quoted 8 lines

When skb->sk is NULL and when packet fanout is used, there is a crash in match_fanout_group where skb->sk is accessed. This patch fixes the issue by returning false as soon as the socket is NULL: this correspond to the wanted behavior because the kernel as to resend the skb to all the listening socket in this case.

Applied and queued up for -stable, thanks.