From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756139AbcBCMWe (ORCPT ); Wed, 3 Feb 2016 07:22:34 -0500 Received: from smtp-out6.electric.net ([192.162.217.191]:64767 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754462AbcBCMWc (ORCPT ); Wed, 3 Feb 2016 07:22:32 -0500 From: David Laight To: "'Linus Torvalds'" , Hannes Frederic Sowa CC: David Herrmann , Willy Tarreau , "David S. Miller" , netdev , linux-kernel , Eric Dumazet , ???? ????????? , Tetsuo Handa , Simon McVittie Subject: RE: [PATCH v2] unix: properly account for FDs passed over unix sockets Thread-Topic: [PATCH v2] unix: properly account for FDs passed over unix sockets Thread-Index: AQHRXfolDYMoHW6P70ShX38Sckh1zJ8aPF0A Date: Wed, 3 Feb 2016 12:19:11 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CCD516C@AcuExch.aculab.com> References: <201601100657.u0A6vk1B025554@mail.home.local> <56B0F574.5080105@stressinduktion.org> <56B11278.8000805@stressinduktion.org> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u13CMdTm028324 From: Linus Torvalds > Sent: 02 February 2016 20:45 > On Tue, Feb 2, 2016 at 12:32 PM, Hannes Frederic Sowa > wrote: > > > > Unfortunately we never transfer a scm_cookie via the skbs but merely use it > > to initialize unix_skb_parms structure in skb->cb and destroy it afterwards. > > Ok, I obviously didn't check very closely. > > > But "struct pid *" in unix_skb_parms should be enough to get us to > > corresponding "struct cred *" so we can decrement the correct counter during > > skb destruction. > > Umm. I think the "struct cred" may change in between, can't it? > > So I don't think you can later look up the cred based on the pid. > > Could we add the cred pointer (or just the user pointer) to the unix_skb_parms? > > Or maybe just add it to the "struct scm_fp_list"? Is that going to work if the sending process exits before the message is read? You need a reference count against the structure than contains the count. I think this is 'struct user' not 'struct cred' David