garp: fix a NULL pointer dereference bug
Subsystems (2)
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.
---
net/802/garp.c +4 -0
@@ -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);
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->pduis NULL'ed ingarp_pdu_rcv()in BH, whilegarp_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!
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->pduis NULL'ed ingarp_pdu_rcv()in BH, whilegarp_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]>Signed-off-by Cong Wang <[email protected]>---
net/802/garp.c +0
-0@@ -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
-0del_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
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!
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()