Skip to contentSkip to conversation

garp: fix a NULL pointer dereference bug

PATCH In review Cong Wang 2 participants 5 messages Mar 4, 2013

Subsystems (2)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 garp: fix a NULL pointer dereference bug

From: Cong Wang <[email protected]>

A NULL-deref bug was reported in:
https://bugzilla.kernel.org/show_bug.cgi?id=54281
when deleting a vlan interface:

# ip link  del em1.57
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffffa03c356f>] garp_uninit_applicant+0x2f/0xd0 [garp]
...

This is probably app->pdu is NULL'ed in garp_pdu_rcv() in BH, while garp_uninit_applicant() only holds rtnl lock which is not enough to prevent this.

OTOH, garp_pdu_queue() should ways be called with the spin lock.

Reported-by [email protected]
Cc David Ward <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc David S. Miller <[email protected]>

---

net/802/garp.c +4 -0
index 8456f5d..5d9630a 100644
@@ -609,8 +609,12 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl
 	/* Delete timer and generate a final TRANSMIT_PDU event to flush out
 	 * all pending messages before the applicant is gone. */
 	del_timer_sync(&app->join_timer);
+
+	spin_lock_bh(&app->lock);
 	garp_gid_event(app, GARP_EVENT_TRANSMIT_PDU);
 	garp_pdu_queue(app);
+	spin_unlock_bh(&app->lock);
+
 	garp_queue_xmit(app);
 
 	dev_mc_del(dev, appl->proto.group_address);
author
#1 lore raw
Quoted 11 lines · Cong Wang

From: Cong Wang <[email protected]>

A NULL-deref bug was reported in:
https://bugzilla.kernel.org/show_bug.cgi?id=54281
when deleting a vlan interface:

# ip link  del em1.57
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffffa03c356f>] garp_uninit_applicant+0x2f/0xd0 [garp]
...
Quoted 8 lines

This is probably app->pdu is NULL'ed in garp_pdu_rcv() in BH, while garp_uninit_applicant() only holds rtnl lock which is not enough to prevent this.

OTOH, garp_pdu_queue() should ways be called with the spin lock.

Reported-by [email protected]

I can't reproduce it locally, so please help to test it. I only did compiling test.

Thanks!

#2 lore raw
In reply to Cong Wang
Quoted 33 lines · Cong Wang

From: Cong Wang <[email protected]>

A NULL-deref bug was reported in:
https://bugzilla.kernel.org/show_bug.cgi?id=54281
when deleting a vlan interface:

# ip link  del em1.57
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffffa03c356f>] garp_uninit_applicant+0x2f/0xd0 [garp]
...

This is probably app->pdu is NULL'ed in garp_pdu_rcv() in BH, while garp_uninit_applicant() only holds rtnl lock which is not enough to prevent this.

OTOH, garp_pdu_queue() should ways be called with the spin lock.

Reported-by [email protected]
Cc David Ward <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc David S. Miller <[email protected]>

---

net/802/garp.c +0 -0
index 8456f5d..5d9630a 100644
@@ -609,8 +609,12 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl
 	/* Delete timer and generate a final TRANSMIT_PDU event to flush out
 	 * all pending messages before the applicant is gone. */

net/802/garp.c void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl · line 620

Quoted 10 lines
net/802/garp.c +4 -0
 	del_timer_sync(&app->join_timer);
+
+	spin_lock_bh(&app->lock);
 	garp_gid_event(app, GARP_EVENT_TRANSMIT_PDU);
 	garp_pdu_queue(app);
+	spin_unlock_bh(&app->lock);
+
 	garp_queue_xmit(app);
 
 	dev_mc_del(dev, appl->proto.group_address);

Nope this patch doesnt solve the problem

Crash is in :

49 8b 1c c6 mov (%r14,%rax,8),%rbx

Thats because r14 (port) is NULL

author
#3 lore raw
Quoted 11 lines · Eric Dumazet

Nope this patch doesnt solve the problem

Crash is in :

49 8b 1c c6 mov (%r14,%rax,8),%rbx

Thats because r14 (port) is NULL

Hmm, but I can't see how it can be NULL, the only place of NULL'ing it is inside garp_release_port(), right after the piece of code that I patched.

Thanks!

#4 lore raw
Quoted 13 lines · Cong Wang
Quoted 11 lines · Eric Dumazet

Nope this patch doesnt solve the problem

Crash is in :

49 8b 1c c6 mov (%r14,%rax,8),%rbx

Thats because r14 (port) is NULL

Quoted 6 lines

Hmm, but I can't see how it can be NULL, the only place of NULL'ing it is inside garp_release_port(), right after the piece of code that I patched.

Thanks!

Maybe port is NULL from the beginning.

Try to inject memory allocations error in garp_init_port()