Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758986Ab2K3Rjl (ORCPT ); Fri, 30 Nov 2012 12:39:41 -0500 Received: from shrek-wifi.podlesie.net ([93.179.225.50]:60551 "EHLO shrek.podlesie.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758878Ab2K3Rjk (ORCPT ); Fri, 30 Nov 2012 12:39:40 -0500 Date: Fri, 30 Nov 2012 18:39:36 +0100 From: Krzysztof Mazur To: chas williams - CONTRACTOR Cc: David Woodhouse , David Laight , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, nathan@traverse.com.au Subject: Re: [PATCH v2 3/3] pppoatm: protect against freeing of vcc Message-ID: <20121130173936.GA11668@shrek.podlesie.net> References: <201211300138.qAU1c8sE003388@thirdoffive.cmf.nrl.navy.mil> <1354240620.21562.256.camel@shinybook.infradead.org> <1354263922.21562.270.camel@shinybook.infradead.org> <20121130095354.GA15126@shrek.podlesie.net> <1354277415.21562.284.camel@shinybook.infradead.org> <1354292626.21562.298.camel@shinybook.infradead.org> <20121130121256.77685fef@thirdoffive.cmf.nrl.navy.mil> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121130121256.77685fef@thirdoffive.cmf.nrl.navy.mil> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1829 Lines: 44 On Fri, Nov 30, 2012 at 12:12:56PM -0500, chas williams - CONTRACTOR wrote: > >Really, what we're saying is that *one* of the driver or protocol close > >functions needs to be split, and we need to do DPD or PDP. Since the > >device driver *can* abort/flush the TX queue and also any pending RX > >being handled by a tasklet, I think it makes most sense to keep it in > >the middle, with the protocol being handled first and last... which is > >the current order, as long as we consider setting ATM_VF_CLOSE to be the > >first part. > > i believe this is essentially already done with the release_cb() > implementation right? that is splitting the protocol detach/shutdown > into two parts. partially, release_cb() is about ATM socket locking. To avoid some races we need to take the ATM socket lock in protocol send function (br2684_start_xmit, pppoatm_send, ...). That functions are executed in bh context and we cannot sleep and wait for releasing the ATM socket lock, so we just block sending and when the ATM socket is unlocked release_cb() is called and we re-enabling sending. Currently the first part of detach is just: lock_sock(sk) (without latest "br2684: don't send frames on not-ready vcc" the first part was set_bit(ATM_VF_CLOSE, &vcc->flags); clear_bit(ATM_VF_READY, &vcc->flags); for br2684) After that the protocol stops sending new packets so the vcc may be fully closed by ATM driver. The protocol is still ready to process received packets. After vcc is closed the protocol can safely detach knowing that no new packets will be received. Krzysiek -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/