Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5563036ima; Tue, 5 Feb 2019 14:03:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IbMO8amJwFjbCDyz2X/GxplgqTw4dKhqbubxzMtSZm7rVyXMMs7JKUGMI1ZYNQlKV9EhvoW X-Received: by 2002:a63:2141:: with SMTP id s1mr6589741pgm.148.1549404235343; Tue, 05 Feb 2019 14:03:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549404235; cv=none; d=google.com; s=arc-20160816; b=Unl4xDlsOrzNsnyRXbPkxaVfLZsubUY2C5EgjPBqDe9sTWScTE8xWq0SccQKbU1HLp tpaP4ruA3fImBA2HR0w7YbgjFv3StSU3XVyOOY4tirYMwR9ium4cOuEEoJJd32heHswP Pp9bbw6X9DWFZQuByw4UXI5mjIRFe0BGNbcBo44Mp99Fd68PVKZJCm9A5C00pqQbnIYB kmf2n3Q9RND4PmZpQbrOESv6/n8C/6qbdyNsZZKTDg51g1Sg3zlyDk38C7VKJBLn/27u NLwn5RseZzSDmr/xMoyrEmvtGUugMlg4UsXEL2k34YCOFZf9Yql4ZUu/Kng2ibMIi2Gy NHNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MEL22RTFEeHTQ5RB+fLcpec6uTWtlUHjCecnCGUAUyc=; b=KHGE2EO/PdgTfv2Cn4zQzEzDxrlQ58afKWcicT0yoqyxysdyZRrcxFkfwg1R3p6F2F QZxJLOvKLuRrePMUhM55CYTGeVF9fR04I9VcyHWeMHWj04zvZwO9/50Oay18y/CUL5hV t9xQvFM9RnHxCmLPwHWLUOXSv9KIfUEuBynGDSFgpA1rLIH0fnCvjZbfB5aMOxM4Fl6A BHjHWaOxttyBW1gtdNoHdEWvkt9nIAJdOvLbWtUEbQkJSzg4BNMP1GYnv6S6xE+O+8Zt wPsYLAeaoRGPxOlCE9soH6k0MCIET0XqNr/hMv45u3HIE3CS1bkzZ58Y7FTfA+1rfBHF k6Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OgHnQsQO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j24si3976038pgh.362.2019.02.05.14.03.35; Tue, 05 Feb 2019 14:03:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OgHnQsQO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbfBEVnz (ORCPT + 99 others); Tue, 5 Feb 2019 16:43:55 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40065 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbfBEVnz (ORCPT ); Tue, 5 Feb 2019 16:43:55 -0500 Received: by mail-pg1-f193.google.com with SMTP id z10so1973997pgp.7 for ; Tue, 05 Feb 2019 13:43:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MEL22RTFEeHTQ5RB+fLcpec6uTWtlUHjCecnCGUAUyc=; b=OgHnQsQOZ7Pg854Pq9a9go95x6tRR0Eul9DZsdHF+d7TCAgYBJ74lM/lWejtbVjb2A Yl4g5XwoW8StIijPmm2VRD8AraIqsuOa6FQe9l3WkOeyvkIbKTJbaGhysS7L3jzyx0hl qOeB8Q06orObNDV8VDBIruJp6D5dpwAXfpE1rGm+ygjyyBD5qVchcSPx0Y5gQteh/FRZ /5qVzgSklZrNbTP0rdD3rfQd2MKyf0D7g4QcYj5zK59aC3T/8znRTqYWy5mRevbIzWrv tM1NmsMzbl6GtSYUy9QK7CmorZypcOmlqs/0rMfe8BG+grMOYRbuIsydjWGefaRte0Uc 4cPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MEL22RTFEeHTQ5RB+fLcpec6uTWtlUHjCecnCGUAUyc=; b=oiAmvgz6MnliB2DIPg7KWNWecjRj5owO2yEHKXu8oo43RxTiq8/X3eXbwvQ9nt3VLX nTrcsQQdcnwx45ISa+m3Ah0DdZQkw88/iZGZejfo14iRrCMZ1ZpWwQKsu341wYjenuyw gnGditouaGS/qnpLxtRvK0Iv2rsk+d+h4oJHN05bTdVGYUOJvx42gsnY8EYUtH0csxeq Lc+FIfSVot0DOHmh04qEZ0FNk5p9k2upWTZniuERe5DumBL2u5ppcQoAO+Y/R0As3O1l QurLohQWw7kIe/7bazzuPiDr3n95uG/Q6mQZe09OXMDro5AUKD+1pwxdTuIR7XBCKIx5 9+Ag== X-Gm-Message-State: AHQUAuZjyLzeRmeOAX12xlznqfUYKDmvQXifDyt6XErk9YGF8giOYA/D d29W7yCnSCfumDizGSk6Gro= X-Received: by 2002:a62:178f:: with SMTP id 137mr7121813pfx.226.1549403033753; Tue, 05 Feb 2019 13:43:53 -0800 (PST) Received: from dtor-ws ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id t5sm6309016pgo.70.2019.02.05.13.43.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 13:43:52 -0800 (PST) Date: Tue, 5 Feb 2019 13:43:51 -0800 From: Dmitry Torokhov To: Jacek Anaszewski Cc: Sven Van Asbroeck , Tejun Heo , Lai Jiangshan , linux-kernel@vger.kernel.org, Sebastian Reichel , Kees Cook Subject: Re: [RFC v1 3/3] cap11xx: fix potential user-after-free on module unload Message-ID: <20190205214351.GB19151@dtor-ws> References: <20190204220952.30761-1-TheSven73@googlemail.com> <20190204220952.30761-4-TheSven73@googlemail.com> <20190205081846.GA118684@dtor-ws> <6565ec19-b629-c289-2fed-a5f404763b74@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6565ec19-b629-c289-2fed-a5f404763b74@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 05, 2019 at 10:24:47PM +0100, Jacek Anaszewski wrote: > Hi Dmitry, > > On 2/5/19 9:18 AM, Dmitry Torokhov wrote: > > Hi Sven, > > > > On Mon, Feb 04, 2019 at 05:09:52PM -0500, Sven Van Asbroeck wrote: > > > The work which is scheduled by led_classdev->brightness_set() is > > > potentially left pending or running until after the driver module > > > is unloaded. > > > > > > Fix by using resource-controlled version of INIT_WORK(). > > > > I believe this is wrong way of fixing this. The LED classdev objects are > > refcounted, and may live beyond the point where we unwibd devm stack, > > so we are still left with the same use-after-free that we currently > > have. > > Could you please share what LED classdev objects refcounting > do you have on mind? My mind was in a state of confusion when I wrote the above ;) > > > This is a general issue with LED subsystem as it provides no callback > > for properly tearing down device structures, but I think in this > > particular case we can simply switch from set_brightness() to > > set_brightness_blocking() which will use the work item internal to the > > LED classdev and that one is being shut down properly. > > > > Jacek, does the above sound right? > > Yes, since the introduction of brightness_set_blocking op there is no > need for out-of-led-core workqueues for deferring brightness setting. > And we do flush_work() in led_classdev_unregister(). OK, great, I'll write up a patch for cap11xx and others if I find them. Thanks. -- Dmitry