All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Mazur <krzysiek@podlesie.net>
To: chas williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Cc: davem@davemloft.net, dwmw2@infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] pppoatm: fix race condition with destroying of vcc
Date: Wed, 31 Oct 2012 23:04:35 +0100	[thread overview]
Message-ID: <20121031220435.GA25157@shrek.podlesie.net> (raw)
In-Reply-To: <20121031160352.68353ecc@thirdoffive.cmf.nrl.navy.mil>

On Wed, Oct 31, 2012 at 04:03:52PM -0400, chas williams - CONTRACTOR wrote:
> 
> reversing the order of the push and close certainly seems like the right
> thing to do. i would like to see if it would fix your problem.  making
> the minimal change to get something working would be preferred before
> adding additional complexity.  i am just surprised we havent seen this
> bug before.

Yes, it fixes the problem and it's probably the best fix for original
issue.

There are also some minor potential issues in pppoatm driver:

	- locking issues, but now only between pppoatm_send() and
	  vcc_sendmsg() and maybe some other functions,

	- missing check for SS_CONNECTED in pppoatm_ioctl,

	- problem described in comment in pppoatm_may_send() when
	  sk->sk_sndbuf < MTU, sk_wmem_alloc_get() should be added
	  there

but I think that for now the patch that changes the order of push
and close is sufficient.

I probably saw that bug a log time ago (around 2.6.30), but it was
too rare to see what caused panic, but after 
9d02daf754238adac48fa075ee79e7edd3d79ed3 (pppoatm: Fix excessive queue bloat)
this bug occurs much more frequently.

Thanks.

Krzysiek

-- >8 --
Subject: [PATCH] atm: detach protocol before closing vcc

The vcc_destroy_socket() closes vcc before the protocol is detached
from vcc by calling vcc->push() with NULL skb. This leaves some time
window, where the protocol may call vcc->send() on closed vcc.

It happens at least with pppoatm protocol and usbatm driver, and causes
an Oops:

Oops: 0000 [#1] PREEMPT
Pid: 0, comm: swapper Not tainted 3.6.0-krzysiek-00001-gb7cd93b-dirty #60    /AK32
EIP: 0060:[<c01413c6>] EFLAGS: 00010082 CPU: 0
EIP is at __wake_up_common+0x16/0x70
EAX: 30707070 EBX: 00000292 ECX: 00000001 EDX: dca75fc0
ESI: 00000000 EDI: de7f500f EBP: df409f24 ESP: df409f08
 DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
CR0: 8005003b CR2: 30707070 CR3: 1c920000 CR4: 000007d0
DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
DR6: ffff0ff0 DR7: 00000400
Process swapper (pid: 0, ti=df408000 task=c07bd4e0 task.ti=c07b0000)
Stack:
 00000000 00000001 00000001 dca75fc0 00000292 00000000 de7f500f df409f3c
 c0143299 00000000 00000000 dc84f000 dc84f000 df409f4c c0602bf0 00000000
 dc84f000 df409f58 c0604301 dc840cc0 df409fb4 c04672e5 c076a240 00000000
Call Trace:
 [<c0143299>] __wake_up+0x29/0x50
 [<c0602bf0>] vcc_write_space+0x40/0x80
 [<c0604301>] atm_pop_raw+0x21/0x30
 [<c04672e5>] usbatm_tx_process+0x2a5/0x380
 [<c0126cf9>] tasklet_action+0x39/0x70
 [<c0126f1f>] __do_softirq+0x7f/0x120
 [<c0126ea0>] ? local_bh_enable_ip+0xa0/0xa0
 <IRQ>

Now the protocol is detached before vcc is closed.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
---
 net/atm/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/atm/common.c b/net/atm/common.c
index 0c0ad93..a0e4411 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -171,10 +171,10 @@ static void vcc_destroy_socket(struct sock *sk)
 	set_bit(ATM_VF_CLOSE, &vcc->flags);
 	clear_bit(ATM_VF_READY, &vcc->flags);
 	if (vcc->dev) {
-		if (vcc->dev->ops->close)
-			vcc->dev->ops->close(vcc);
 		if (vcc->push)
 			vcc->push(vcc, NULL); /* atmarpd has no push */
+		if (vcc->dev->ops->close)
+			vcc->dev->ops->close(vcc);
 
 		while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
 			atm_return(vcc, skb->truesize);
-- 
1.8.0.172.g62af90c


  reply	other threads:[~2012-10-31 22:04 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 17:14 [PATCH v2 1/3] pppoatm: don't send frames to destroyed vcc Krzysztof Mazur
2012-10-22 17:14 ` [PATCH v2 2/3] pppoatm: fix race condition with destroying of vcc Krzysztof Mazur
2012-10-30  9:37   ` David Woodhouse
2012-10-30 19:07     ` Krzysztof Mazur
2012-10-30 19:52       ` Krzysztof Mazur
2012-10-31 10:16         ` David Woodhouse
2012-10-31 11:30           ` Krzysztof Mazur
2012-10-31 11:52             ` David Woodhouse
2012-10-30 14:26   ` Chas Williams (CONTRACTOR)
2012-10-30 18:20     ` Krzysztof Mazur
2012-10-31  9:41       ` Krzysztof Mazur
2012-10-31 10:22         ` Krzysztof Mazur
2012-10-31 20:03         ` chas williams - CONTRACTOR
2012-10-31 22:04           ` Krzysztof Mazur [this message]
2012-11-01 14:26             ` chas williams - CONTRACTOR
2012-11-02  9:40               ` Krzysztof Mazur
2012-11-02 10:54                 ` Krzysztof Mazur
2012-10-22 17:14 ` [PATCH v2 3/3] pppoatm: protect against freeing " Krzysztof Mazur
2012-10-30  9:39   ` David Woodhouse
2012-10-30 19:26     ` Krzysztof Mazur
2012-11-27 17:16   ` David Woodhouse
2012-11-27 17:39     ` Krzysztof Mazur
2012-11-27 18:02       ` David Woodhouse
2012-11-27 18:28         ` Krzysztof Mazur
2012-11-28 20:18           ` Krzysztof Mazur
2012-11-28 20:44             ` David Woodhouse
2012-11-28 21:24               ` Krzysztof Mazur
2012-11-28 21:20             ` chas williams - CONTRACTOR
2012-11-28 21:45               ` [PATCH] atm: introduce vcc_pop() Krzysztof Mazur
2012-11-28 21:59                 ` chas williams - CONTRACTOR
2012-11-28 22:10                   ` Krzysztof Mazur
2012-11-28 22:33                     ` [PATCH] atm: introduce vcc_pop_skb() Krzysztof Mazur
2012-12-03 13:22                       ` David Woodhouse
2012-12-03 20:11                         ` Krzysztof Mazur
2012-11-27 18:39         ` [PATCH v2 3/3] pppoatm: protect against freeing of vcc Krzysztof Mazur
2012-11-27 18:54         ` chas williams - CONTRACTOR
2012-11-27 22:36           ` [PATCH] solos-pci: Wait for pending TX to complete when releasing vcc David Woodhouse
2012-11-27 23:28             ` [PATCH] br2684: don't send frames on not-ready vcc David Woodhouse
2012-11-27 23:51               ` Krzysztof Mazur
2012-11-28  0:54                 ` David Woodhouse
2012-11-28  8:08                   ` Krzysztof Mazur
2012-11-28  9:58                     ` David Woodhouse
2012-11-28 16:41               ` David Miller
2012-11-28 17:01                 ` David Woodhouse
2012-11-28 17:04                   ` David Miller
2012-11-28 17:09                     ` David Woodhouse
2012-11-28 17:11                       ` David Miller
2012-11-30  1:18                       ` Nathan Williams
2012-11-30  1:34                         ` David Woodhouse
2012-11-28  9:21           ` [PATCH v2 3/3] pppoatm: protect against freeing of vcc David Laight
2012-11-28 10:04             ` Krzysztof Mazur
2012-11-28 10:24               ` David Woodhouse
2012-11-28 15:18                 ` chas williams - CONTRACTOR
2012-11-28 22:18             ` David Woodhouse
2012-11-29 10:57               ` Krzysztof Mazur
2012-11-29 11:55                 ` David Woodhouse
2012-11-29 12:43                   ` [PATCH] solos-pci: don't call vcc->pop() after pclose() Krzysztof Mazur
2012-11-29 12:57                     ` David Woodhouse
2012-11-29 13:20                       ` Krzysztof Mazur
2012-11-29 14:42                         ` David Woodhouse
2012-11-29 14:55                           ` Krzysztof Mazur
2012-11-29 14:41                     ` chas williams - CONTRACTOR
2012-11-29 14:29                 ` [PATCH v2 3/3] pppoatm: protect against freeing of vcc chas williams - CONTRACTOR
2012-11-29 15:09               ` Krzysztof Mazur
2012-11-29 15:47                 ` David Woodhouse
2012-11-29 15:59                   ` chas williams - CONTRACTOR
2012-11-29 16:24                     ` David Woodhouse
2012-11-29 17:17                       ` chas williams - CONTRACTOR
2012-11-29 18:11                         ` David Woodhouse
2012-11-29 18:29                           ` chas williams - CONTRACTOR
2012-11-29 22:17                             ` David Woodhouse
2012-11-30  1:38                               ` Chas Williams (CONTRACTOR)
2012-11-30  1:57                                 ` David Woodhouse
2012-11-30  8:25                                   ` David Woodhouse
2012-11-30  9:53                                     ` Krzysztof Mazur
2012-11-30 12:10                                       ` David Woodhouse
2012-11-30 16:23                                         ` David Woodhouse
2012-11-30 17:00                                           ` Krzysztof Mazur
2012-11-30 18:33                                             ` David Woodhouse
2012-11-30 17:12                                           ` chas williams - CONTRACTOR
2012-11-30 17:39                                             ` Krzysztof Mazur
2012-11-29 16:28                   ` Krzysztof Mazur
2012-11-29 15:37               ` chas williams - CONTRACTOR
2012-11-29 15:59                 ` David Woodhouse
2012-11-29 16:11                   ` chas williams - CONTRACTOR
2012-10-23  6:52 ` [PATCH v2 1/3] pppoatm: don't send frames to destroyed vcc David Miller
2012-10-23  8:12   ` David Woodhouse
2012-10-30  9:35 ` David Woodhouse
2012-10-30 20:19   ` Krzysztof Mazur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121031220435.GA25157@shrek.podlesie.net \
    --to=krzysiek@podlesie.net \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=davem@davemloft.net \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.