diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2007-10-08 02:44:17 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-08 02:44:17 -0400 |
commit | 891e6a931255238dddd08a7b306871240961a27f (patch) | |
tree | 70cd2faf43bd7f306f3b7a758388e6b272ff1730 /net/rose | |
parent | 48611c47d09023d9356e78550d1cadb8d61da9c8 (diff) |
[ROSE]: Fix rose.ko oops on unload
Commit a3d384029aa304f8f3f5355d35f0ae274454f7cd aka
"[AX.25]: Fix unchecked rose_add_loopback_neigh uses"
transformed rose_loopback_neigh var into statically allocated one.
However, on unload it will be kfree's which can't work.
Steps to reproduce:
modprobe rose
rmmod rose
BUG: unable to handle kernel NULL pointer dereference at virtual address 00000008
printing eip:
c014c664
*pde = 00000000
Oops: 0000 [#1]
PREEMPT DEBUG_PAGEALLOC
Modules linked in: rose ax25 fan ufs loop usbhid rtc snd_intel8x0 snd_ac97_codec ehci_hcd ac97_bus uhci_hcd thermal usbcore button processor evdev sr_mod cdrom
CPU: 0
EIP: 0060:[<c014c664>] Not tainted VLI
EFLAGS: 00210086 (2.6.23-rc9 #3)
EIP is at kfree+0x48/0xa1
eax: 00000556 ebx: c1734aa0 ecx: f6a5e000 edx: f7082000
esi: 00000000 edi: f9a55d20 ebp: 00200287 esp: f6a5ef28
ds: 007b es: 007b fs: 0000 gs: 0033 ss: 0068
Process rmmod (pid: 1823, ti=f6a5e000 task=f7082000 task.ti=f6a5e000)
Stack: f9a55d20 f9a5200c 00000000 00000000 00000000 f6a5e000 f9a5200c f9a55a00
00000000 bf818cf0 f9a51f3f f9a55a00 00000000 c0132c60 65736f72 00000000
f69f9630 f69f9528 c014244a f6a4e900 00200246 f7082000 c01025e6 00000000
Call Trace:
[<f9a5200c>] rose_rt_free+0x1d/0x49 [rose]
[<f9a5200c>] rose_rt_free+0x1d/0x49 [rose]
[<f9a51f3f>] rose_exit+0x4c/0xd5 [rose]
[<c0132c60>] sys_delete_module+0x15e/0x186
[<c014244a>] remove_vma+0x40/0x45
[<c01025e6>] sysenter_past_esp+0x8f/0x99
[<c012bacf>] trace_hardirqs_on+0x118/0x13b
[<c01025b6>] sysenter_past_esp+0x5f/0x99
=======================
Code: 05 03 1d 80 db 5b c0 8b 03 25 00 40 02 00 3d 00 40 02 00 75 03 8b 5b 0c 8b 73 10 8b 44 24 18 89 44 24 04 9c 5d fa e8 77 df fd ff <8b> 56 08 89 f8 e8 84 f4 fd ff e8 bd 32 06 00 3b 5c 86 60 75 0f
EIP: [<c014c664>] kfree+0x48/0xa1 SS:ESP 0068:f6a5ef28
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/rose')
-rw-r--r-- | net/rose/rose_loopback.c | 4 | ||||
-rw-r--r-- | net/rose/rose_route.c | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/net/rose/rose_loopback.c b/net/rose/rose_loopback.c index cd01642f0491..114df6eec8c3 100644 --- a/net/rose/rose_loopback.c +++ b/net/rose/rose_loopback.c | |||
@@ -79,7 +79,7 @@ static void rose_loopback_timer(unsigned long param) | |||
79 | 79 | ||
80 | skb_reset_transport_header(skb); | 80 | skb_reset_transport_header(skb); |
81 | 81 | ||
82 | sk = rose_find_socket(lci_o, &rose_loopback_neigh); | 82 | sk = rose_find_socket(lci_o, rose_loopback_neigh); |
83 | if (sk) { | 83 | if (sk) { |
84 | if (rose_process_rx_frame(sk, skb) == 0) | 84 | if (rose_process_rx_frame(sk, skb) == 0) |
85 | kfree_skb(skb); | 85 | kfree_skb(skb); |
@@ -88,7 +88,7 @@ static void rose_loopback_timer(unsigned long param) | |||
88 | 88 | ||
89 | if (frametype == ROSE_CALL_REQUEST) { | 89 | if (frametype == ROSE_CALL_REQUEST) { |
90 | if ((dev = rose_dev_get(dest)) != NULL) { | 90 | if ((dev = rose_dev_get(dest)) != NULL) { |
91 | if (rose_rx_call_request(skb, dev, &rose_loopback_neigh, lci_o) == 0) | 91 | if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0) |
92 | kfree_skb(skb); | 92 | kfree_skb(skb); |
93 | } else { | 93 | } else { |
94 | kfree_skb(skb); | 94 | kfree_skb(skb); |
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c index bbcbad1da0d0..96f61a71b252 100644 --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c | |||
@@ -45,7 +45,7 @@ static DEFINE_SPINLOCK(rose_neigh_list_lock); | |||
45 | static struct rose_route *rose_route_list; | 45 | static struct rose_route *rose_route_list; |
46 | static DEFINE_SPINLOCK(rose_route_list_lock); | 46 | static DEFINE_SPINLOCK(rose_route_list_lock); |
47 | 47 | ||
48 | struct rose_neigh rose_loopback_neigh; | 48 | struct rose_neigh *rose_loopback_neigh; |
49 | 49 | ||
50 | /* | 50 | /* |
51 | * Add a new route to a node, and in the process add the node and the | 51 | * Add a new route to a node, and in the process add the node and the |
@@ -362,7 +362,12 @@ out: | |||
362 | */ | 362 | */ |
363 | void rose_add_loopback_neigh(void) | 363 | void rose_add_loopback_neigh(void) |
364 | { | 364 | { |
365 | struct rose_neigh *sn = &rose_loopback_neigh; | 365 | struct rose_neigh *sn; |
366 | |||
367 | rose_loopback_neigh = kmalloc(sizeof(struct rose_neigh), GFP_KERNEL); | ||
368 | if (!rose_loopback_neigh) | ||
369 | return; | ||
370 | sn = rose_loopback_neigh; | ||
366 | 371 | ||
367 | sn->callsign = null_ax25_address; | 372 | sn->callsign = null_ax25_address; |
368 | sn->digipeat = NULL; | 373 | sn->digipeat = NULL; |
@@ -417,13 +422,13 @@ int rose_add_loopback_node(rose_address *address) | |||
417 | rose_node->mask = 10; | 422 | rose_node->mask = 10; |
418 | rose_node->count = 1; | 423 | rose_node->count = 1; |
419 | rose_node->loopback = 1; | 424 | rose_node->loopback = 1; |
420 | rose_node->neighbour[0] = &rose_loopback_neigh; | 425 | rose_node->neighbour[0] = rose_loopback_neigh; |
421 | 426 | ||
422 | /* Insert at the head of list. Address is always mask=10 */ | 427 | /* Insert at the head of list. Address is always mask=10 */ |
423 | rose_node->next = rose_node_list; | 428 | rose_node->next = rose_node_list; |
424 | rose_node_list = rose_node; | 429 | rose_node_list = rose_node; |
425 | 430 | ||
426 | rose_loopback_neigh.count++; | 431 | rose_loopback_neigh->count++; |
427 | 432 | ||
428 | out: | 433 | out: |
429 | spin_unlock_bh(&rose_node_list_lock); | 434 | spin_unlock_bh(&rose_node_list_lock); |
@@ -454,7 +459,7 @@ void rose_del_loopback_node(rose_address *address) | |||
454 | 459 | ||
455 | rose_remove_node(rose_node); | 460 | rose_remove_node(rose_node); |
456 | 461 | ||
457 | rose_loopback_neigh.count--; | 462 | rose_loopback_neigh->count--; |
458 | 463 | ||
459 | out: | 464 | out: |
460 | spin_unlock_bh(&rose_node_list_lock); | 465 | spin_unlock_bh(&rose_node_list_lock); |