ipv4: fix lock usage in udp_ioctl
Subsystems (5)
PATCH 1/1 ipv4: fix lock usage in udp_ioctl
From: Heiko Carstens <[email protected]>
Fix lock usage in udp_ioctl().
---
udp_poll() seems to have the same problem, right?
As reported by the lock validator:
============================
[ BUG: illegal lock usage! ]
----------------------------
illegal {in-hardirq-W} -> {hardirq-on-W} usage. syslogd/739 [HC0[0]:SC0[1]:HE1:SE0] takes:
(&list->lock){++..}, at: [<002e36d6>] udp_ioctl+0x96/0x100
{in-hardirq-W} state was registered at:
[<00062128>] lock_acquire+0x9c/0xc0 [<0036209e>] _spin_lock_irqsave+0x66/0x84 [<002912ce>] skb_dequeue+0x32/0xb0 [<00263160>] qeth_qdio_output_handler+0x3e8/0xf8c [<00219fdc>] tiqdio_thinint_handler+0xde0/0x2234 [<0020448c>] do_adapter_IO+0x5c/0xa8 [<0020842c>] do_IRQ+0x13c/0x18c [<000208a2>] io_no_vtime+0x16/0x1c [<0001978c>] cpu_idle+0x1d0/0x20c irq event stamp: 1694 hardirqs last enabled at (1693): [<003629c2>] _spin_unlock_irqrestore+0x92/0xa8 hardirqs last disabled at (1692): [<00362074>] _spin_lock_irqsave+0x3c/0x84 softirqs last enabled at (1682): [<0028c7c4>] release_sock+0xe4/0xf4 softirqs last disabled at (1694): [<00361f7e>] _spin_lock_bh+0x2e/0x70
other info that might help us debug this:
no locks held by syslogd/739.
stack backtrace:
000000000fd6c148 000000000de2f960 0000000000000002 0000000000000000
000000000de2fa00 000000000de2f978 000000000de2f978 000000000001737c
0000000000000000 0000000000000000 0000000000000000 0000000000000000
000000000de2f960 000000000000000c 000000000de2f960 000000000de2f9d0
000000000036fe70 000000000001737c 000000000de2f960 000000000de2f9b0
Call Trace:
([<000000000001730a>] show_trace+0x166/0x16c)
[<00000000000173d6>] show_stack+0xc6/0xf8
[<0000000000017436>] dump_stack+0x2e/0x3c
[<000000000005f978>] print_usage_bug+0x23c/0x250
[<00000000000607cc>] mark_lock+0x594/0x714
[<00000000000613be>] __lock_acquire+0x252/0xf20
[<0000000000062128>] lock_acquire+0x9c/0xc0
[<0000000000361fa8>] _spin_lock_bh+0x58/0x70
[<00000000002e36d6>] udp_ioctl+0x96/0x100
[<00000000002eadd6>] inet_ioctl+0x72/0x11c
[<00000000002893f2>] sock_ioctl+0x1ca/0x2c0
[<00000000000c13ee>] do_ioctl+0x56/0xe0
[<00000000000c14f2>] vfs_ioctl+0x7a/0x384
[<00000000000c184e>] sys_ioctl+0x52/0x84
[<00000000000e80a2>] do_ioctl32_pointer+0x2a/0x3c
[<00000000000e55c8>] compat_sys_ioctl+0x168/0x378
[<0000000000020338>] sysc_noemu+0x10/0x16diffstat:
net/ipv4/udp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/udp.c +2 -2
@@ -740,7 +740,7 @@ int udp_ioctl(struct sock *sk, int cmd,unsigned long amount; amount =0 ; -spin_lock_bh (&sk->sk_receive_queue.lock); +spin_lock_irq (&sk->sk_receive_queue.lock); skb =skb_peek (&sk->sk_receive_queue);if (skb !=NULL ) {/*
@@ -750,7 +750,7 @@ int udp_ioctl(struct sock *sk, int cmd,*/ amount = skb->len -sizeof (struct udphdr ); } -spin_unlock_bh (&sk->sk_receive_queue.lock); +spin_unlock_irq (&sk->sk_receive_queue.lock);return put_user (amount, (int __user *)arg); }
David Miller
maintainerFrom: Heiko Carstens <[email protected]>
Date: Wed, 14 Jun 2006 21:43:05 +0200
Quoted 5 lines
From: Heiko Carstens <[email protected]>
Fix lock usage in
udp_ioctl().Signed-off-by Heiko Carstens <[email protected]>
More likely the qeth driver shouldn't call into the socket code in hardware interrupt context. From your logs that's what it seems is happening.
The socket receive queue should only be touched in software interrupt context, never in hardware interrupt context. That's why the locking does BH disabling at best.
Quoted 10 lines · Heiko Carstens
As reported by the lock validator:
============================
[ BUG: illegal lock usage! ]
----------------------------
illegal {in-hardirq-W} -> {hardirq-on-W} usage. syslogd/739 [HC0[0]:SC0[1]:HE1:SE0] takes:
(&list->lock){++..}, at: [<002e36d6>]udp_ioctl+0x96/0x100{in-hardirq-W} state was registered at:
Quoted 9 lines
[<00062128>] lock_acquire+0x9c/0xc0 [<0036209e>] _spin_lock_irqsave+0x66/0x84 [<002912ce>] skb_dequeue+0x32/0xb0 [<00263160>] qeth_qdio_output_handler+0x3e8/0xf8c [<00219fdc>] tiqdio_thinint_handler+0xde0/0x2234 [<0020448c>] do_adapter_IO+0x5c/0xa8 [<0020842c>] do_IRQ+0x13c/0x18c [<000208a2>] io_no_vtime+0x16/0x1c [<0001978c>] cpu_idle+0x1d0/0x20c
This is bogus. These two locks belong to two different queues and they never intersect.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 2 lines · Herbert Xu
This is bogus. These two locks belong to two different queues and they never intersect.
yeah - qeth does its own skb-queue management here, and it's done in an irq-safe manner.
Heiko, in qeth_main.c, could you do something like:
+ static struct lockdep_type_key qdio_out_skb_queue_key;
...
skb_queue_head_init(&card->qdio.out_qs[i]->bufs[j]. skb_list);
+ lockdep_reinit_key(&card->qdio.out_qs[i]->bufs[j].skb_list,
&qdio_out_skb_queue_key)
Ingo
Quoted 17 lines · Ingo Molnar
Quoted 2 lines · Herbert Xu
This is bogus. These two locks belong to two different queues and they never intersect.
yeah - qeth does its own skb-queue management here, and it's done in an irq-safe manner.
Heiko, in
qeth_main.c, could you do something like:+ static struct
lockdep_type_keyqdio_out_skb_queue_key;...
skb_queue_head_init(&card->qdio.out_qs[i]->bufs[j]. skb_list);(quoted diff) +1
-0+ lockdep_reinit_key(&card->qdio.out_qs[i]->bufs[j].skb_list,
Quoted 1 line
&qdio_out_skb_queue_key)
How about the patch below? The warning goes away and I assume "tmp_list" needs lockdep_reinit_key too, since it should have the same locking rules as the rest of qeth's skb-queue management.
From: Heiko Carstens <[email protected]>
Avoid false positive illegal lock usage message in qeth driver.
---
drivers/s390/net/qeth_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/s390/net/qeth_main.c +6 -0
@@ -85,6 +85,8 @@ static debug_info_t *qeth_dbf_qerr = NULDEFINE_PER_CPU (char[256 ], qeth_dbf_txt_buf); +static struct lockdep_type_key qdio_out_skb_queue_key; +/** * some more definitions and declarations */
@@ -3230,6 +3232,9 @@ qeth_alloc_qdio_buffers(struct qeth_card &card->qdio.out_qs[i]->qdio_bufs[j];skb_queue_head_init (&card->qdio.out_qs[i]->bufs[j]. skb_list); +lockdep_reinit_key ( + &card->qdio.out_qs[i]->bufs[j].skb_list.lock, + &qdio_out_skb_queue_key);INIT_LIST_HEAD (&card->qdio.out_qs[i]->bufs[j].ctx_list); } }
@@ -5273,6 +5278,7 @@ qeth_free_vlan_buffer(struct qeth_card *struct sk_buff_head tmp_list;skb_queue_head_init (&tmp_list); +lockdep_reinit_key (&tmp_list.lock, &qdio_out_skb_queue_key);for (i =0 ; i <QETH_MAX_BUFFER_ELEMENTS (card); ++i){while ((skb =skb_dequeue (&buf->skb_list))){ if (vlan_tx_tag_present(skb) &&
Quoted 3 lines · Heiko Carstens
How about the patch below? The warning goes away and I assume "
tmp_list" needslockdep_reinit_keytoo, since it should have the same locking rules as the rest of qeth's skb-queue management.
yeah, looks good.
Ingo