Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5532970ima; Tue, 5 Feb 2019 13:26:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IbRJRMkUmhcP5hmhTYZVtCsqhgyWMJt0PV4Y6arjOY69ndCrkuQ/KEyHV0ZWWokCsQ8NTzc X-Received: by 2002:a17:902:9a02:: with SMTP id v2mr7346525plp.180.1549401979558; Tue, 05 Feb 2019 13:26:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549401979; cv=none; d=google.com; s=arc-20160816; b=LF8S2wtyJ0RWJN555me6aurwYyv0Sc2r4XFQBqqeclHJ1bZtLOOGMlUJbmsUQj0UB9 behFmz3hiZGJoc42YYQvtV922ctvHfSoEOYDy/rNNF9/eQL+fVLsYB0agb2ZY4VTxwUu y6Ti/swTtRyg8leRYBIgdcPfQ5UtPMcA+u3xBzZxeyETNBjDmH82TOl0esKjs+/6Eke5 /SzISowzYBSs5Xmi2bcHz6C6edJ1etEOkQbZGEX9/DGuZQC5fgdeIiYHpfuUO5X1ln9f +Rm7WUOJKRxoGr5JRnj3BlvTLRaLoDfkBwy3Us/v5vcTw8ZyF5KJ06u5zStr8QaSMzRl qisQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=lP4RoDnMTU+pVD+Pfm3EH+dprELT4ls4Vuao9Og8Qps=; b=hltDivxsyeYXGwi7NwWP7oggnJ/sSfHSwLgsLL0l1vIJbEKUOIBL2sirxXJGGjVJE+ 38YKi1ejh9wshrFMzWaFJy9LBJJ3TGuulsS64BHExKm3aAxA2CnUANY71h+E+OhUQI7p EbXm4LgMHkg6P9X6nIiPuFiIIOa8CTkfyieahABAvbpJNraWjv5omMvhBdKupvT45DrM PRc4zBv5rbhEJ0868E6jhh05eqtH9BjWjQ/D5s/wyr0lD+pauq1TN0mjZmTtjY6at+fu Hsnw/2JeBe5L6C+md6SzgHE3HIcVyFZdEFFqpOnmJZqyHW7a0XeGRQdltdfmAQf54Oxy T05Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rURtGQiW; 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 u9si1287191pgr.550.2019.02.05.13.26.01; Tue, 05 Feb 2019 13:26:19 -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=rURtGQiW; 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 S1727980AbfBEVYy (ORCPT + 99 others); Tue, 5 Feb 2019 16:24:54 -0500 Received: from mail-lj1-f170.google.com ([209.85.208.170]:38191 "EHLO mail-lj1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726062AbfBEVYx (ORCPT ); Tue, 5 Feb 2019 16:24:53 -0500 Received: by mail-lj1-f170.google.com with SMTP id c19-v6so4211004lja.5 for ; Tue, 05 Feb 2019 13:24:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lP4RoDnMTU+pVD+Pfm3EH+dprELT4ls4Vuao9Og8Qps=; b=rURtGQiWgRxtM5L1YBuYBR++Ymz9ZVaL1AuJIbFprIh+hex+VdWboChgDwXE4yxPcx iDZ77h+kdUSOl//wAIth/9PfbjOU51up25rYWC9/v84X/o+cnUYuGqJA+k/SQ2d/6zrE mA3873FEaB9W/Vf7o6ewp+FtPjr1XkPXA6JvWw/hclAaUGRhHQ2X1fe4Kohpx2wIY0pL 7BromZ8TuLyQ4sDUmtfO/NFwFRGYs8+2Gj+jM2Uxw48uXc6gOSi3uWQfGQU85rmbi3V8 LsCYtxVl3cpdEIAH/deIGC6WYVY8W+Sj8U+zciW2UzWDsuEmftbpV5hT7GPThxt7mKVy bgTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lP4RoDnMTU+pVD+Pfm3EH+dprELT4ls4Vuao9Og8Qps=; b=OM+Er0kUAPTj9JJDlircc6cQ08sRBSFfgUWwpdmThbgVvOtQRiRJrR+m28UsQIsSuD mskI/HSI8n0RGH7vV3lZ9GpSQJbCnLMdDJ+Bpw8zXWLnwIrnezouwV15T5C5ZAXoaIXJ 9CXgchX2ZRlDZFuQkkEzZNINabL70fccoZJyUIrIMvXhqaWV7K3qgnzfJIQ3gxIOoK35 5/q34VQnq7UKgEDHf6xcrO94N6TFJOYBOzORbMGZNdicyKC5avdtXSkTQBRxdk0fM5S4 mKX6gVd7T4KNekUi6ZsHHZvBNPpC60x2yEcOdAGXWtIhF1/bc8GYmnyCkB0MHV1Q8zgK 51Zw== X-Gm-Message-State: AHQUAub2BxU962pk20D1a4uh/7aBLZyFtMl7dVmN6CsFYbT3qwaFNLFK MOjIR/gR3X8SS0PsaWMx1QB7Xn6S X-Received: by 2002:a2e:5dd9:: with SMTP id v86-v6mr4142817lje.86.1549401891560; Tue, 05 Feb 2019 13:24:51 -0800 (PST) Received: from [192.168.1.18] (dnn189.neoplus.adsl.tpnet.pl. [83.24.95.189]) by smtp.gmail.com with ESMTPSA id y25sm3919143lfg.4.2019.02.05.13.24.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 13:24:50 -0800 (PST) Subject: Re: [RFC v1 3/3] cap11xx: fix potential user-after-free on module unload To: Dmitry Torokhov , Sven Van Asbroeck Cc: Tejun Heo , Lai Jiangshan , linux-kernel@vger.kernel.org, Sebastian Reichel , Kees Cook References: <20190204220952.30761-1-TheSven73@googlemail.com> <20190204220952.30761-4-TheSven73@googlemail.com> <20190205081846.GA118684@dtor-ws> From: Jacek Anaszewski Message-ID: <6565ec19-b629-c289-2fed-a5f404763b74@gmail.com> Date: Tue, 5 Feb 2019 22:24:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190205081846.GA118684@dtor-ws> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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(). -- Best regards, Jacek Anaszewski