Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758159Ab2K3MKa (ORCPT ); Fri, 30 Nov 2012 07:10:30 -0500 Received: from merlin.infradead.org ([205.233.59.134]:42343 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888Ab2K3MK2 (ORCPT ); Fri, 30 Nov 2012 07:10:28 -0500 Message-ID: <1354277415.21562.284.camel@shinybook.infradead.org> Subject: Re: [PATCH v2 3/3] pppoatm: protect against freeing of vcc From: David Woodhouse To: Krzysztof Mazur Cc: "Chas Williams (CONTRACTOR)" , David Laight , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, nathan@traverse.com.au Date: Fri, 30 Nov 2012 12:10:15 +0000 In-Reply-To: <20121130095354.GA15126@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> Content-Type: multipart/signed; micalg="sha1"; protocol="application/x-pkcs7-signature"; boundary="=-eq2tmYlSAM52jHJFiK03" X-Mailer: Evolution 3.6.1 (3.6.1-1.fc18) Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11401 Lines: 201 --=-eq2tmYlSAM52jHJFiK03 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2012-11-30 at 10:53 +0100, Krzysztof Mazur wrote: > On Fri, Nov 30, 2012 at 08:25:22AM +0000, David Woodhouse wrote: > > On Fri, 2012-11-30 at 01:57 +0000, David Woodhouse wrote: > > > I think it's actually fixed for pppoatm by the bh_lock_sock() and the > > > sock_owned_by_user() check. As soon as vcc_release() calls lock_sock(= ), > > > pppoatm stops accepting packets. > > >=20 > > > It should be simple enough to do the same in br2684. > >=20 > > Um... but now I come to look at it... Krzysztof, doesn't your 'pppoatm: > > take ATM socket lock in pppoatm_send()' patch actually *break* the case > > of sending via vcc_sendmsg()? >=20 > no,=20 ... oops, sorry. My sleep-deprived brain thought that we were calling pppoatm_send() *from* vcc_sendmsg() with the lock held. But of course we're not; we're calling directly into the driver. So that's OK. In that case I think we're fine. I'll just do the same thing in br2684_push(), fix up the comment you just corrected, and we're all good. > I think that the current order is good, now we have: >=20 > 1. stop_sending_fames to protocol > now TX is shut down > (currently done by > set_bit(ATM_VF_CLOSE, &vcc->flags); > clear_bit(ATM_VF_READY, &vcc->flags); > ) Right, with the caveat the the socket lock is required for synchronisation on this. But that's OK. Or we *could* perhaps introduce an explicit call into the protocol for it, if we really wanted. But I'm inclined not to. > 2. close_device to device > now RX is shut down > 3. device_was_closed to protocol > ugly push(NULL), but we can add some other callback. > we also can do: >=20 > 1. disable RX to device > now RX is shut down > 2. detach to protocol > now TX is shut down > (now protocol can fully detach because RX is disabled) Careful. You have to flush the TX packets which are currently in-flight. It's not sufficient just to stop sending any more. And you have to do it *before* the data structures are torn down. > 3. close_device to device > (device is not used anymore) 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. --=20 dwmw2 --=-eq2tmYlSAM52jHJFiK03 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIUbjCCBjQw ggQcoAMCAQICAR4wDQYJKoZIhvcNAQEFBQAwfTELMAkGA1UEBhMCSUwxFjAUBgNVBAoTDVN0YXJ0 Q29tIEx0ZC4xKzApBgNVBAsTIlNlY3VyZSBEaWdpdGFsIENlcnRpZmljYXRlIFNpZ25pbmcxKTAn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MQswCQYDVQQGEwJJ TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlm aWNhdGUgU2lnbmluZzE4MDYGA1UEAxMvU3RhcnRDb20gQ2xhc3MgMSBQcmltYXJ5IEludGVybWVk aWF0ZSBDbGllbnQgQ0ECAwQmejANBgkqhkiG9w0BAQEFAASCAQCGdH+rzTuCPTrSov6Gt03b1sHI 21+1cl7cEQulRPLz/WxqZvIJXvyofa0zBegBMf4aWGuNLWtVCrO0yoc2wU6Fcwlb/TBE5Xd9joaO Cn3ikBOaajrPC+QfwzlksPvykUfhUHm3SW824DIYGC4+rhBs7MHLItdxDUO+Vj0YdVU0pn/ZHrdW tAVDLFecBGurhkk3FDCOruLkecTzGt+bTWmjaS2Jp5f42bfXhoi1Uj/c1ESgKHgQx8U5oQqgPqK7 KdoaXBqg4SMczbCnmWfYWSDoa5CtjrzcFRfgVDpbOxf4waQClNEND6b0jTPSYVGnvy0JMBSRJIjn auJMvZ1wy+JGAAAAAAAA --=-eq2tmYlSAM52jHJFiK03-- -- 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/