Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp118423imj; Fri, 8 Feb 2019 16:15:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IaulSmCe7irbrcljpbCOlTr8JFuUyZkD5A86KWseo2pq79z2KfXb8R46nqflrlyD3FdEANh X-Received: by 2002:a62:3305:: with SMTP id z5mr25316281pfz.112.1549671353143; Fri, 08 Feb 2019 16:15:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549671353; cv=none; d=google.com; s=arc-20160816; b=DEg43T7fL+kl6gVYQICC4HsWjjPo0HesY6U1EK4o44wKODQq++wmEcuCKdePBD6G0j SidSsXC9yehVjGrvNFcRJ0l9HXFd9pycE/8YVqKM54ltKIdnnBYZZgAe9aiyH1n8z9y2 AaQ2V1N9X6XuYynw/jbZMsoZJWzORA3Es/G/UwFvAgQ7IltrVXGUE4fsrHxE8bAvT8H4 nMhY4WN27F3sC1NPr+Q2g8P7n9QY6jjF74dQlAjpbcBneuqwAGGTxWubbhuCDkCu6kH6 ptLHJQvn/60FzX03/8aj7FHADH3uoUAmwkxPmyYHGP6f3qoLbHASAyWIAh0qhTVmeoSO y9aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=wyReugPXrxIiS774VlKOeus0XlUa4VY30FlEPNXHAyg=; b=dNAgGH08IKQW9Kn+VD+K8MO2gEucq4V65OPcRrExYeCep7RBZZZ4QzP8OKBYNYkYpU AnmTt66Q1Ku5U/lAoT6WOh72Bxl10srBoSyxDBW+JDpeRjDY9u0rEfYw3AGB88PXaGoT v0rw5qbkOaYZVrmXNkwTAKv4InQT3VaIEZDPSXvIJuCgjqpGPB7d/Kb1AckfXiNxQh5l DVV8thITD3NtJYtQ0DccB5l6sc4P6QQ0yAo43dYG0um8RfpunAsnfEonkJtq0EJ57QcW ctIms3enEFMeDasDyyQlcC9KsncapF0IIqDKi4DuAwJcOB3Sx0dkwqgsZYg+IpYQg+XG fB4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="o/0Fmcm8"; 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 n4si2037332pgp.318.2019.02.08.16.15.36; Fri, 08 Feb 2019 16:15:53 -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="o/0Fmcm8"; 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 S1726700AbfBIAPc (ORCPT + 99 others); Fri, 8 Feb 2019 19:15:32 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:51324 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbfBIAPb (ORCPT ); Fri, 8 Feb 2019 19:15:31 -0500 Received: by mail-wm1-f67.google.com with SMTP id b11so6309441wmj.1 for ; Fri, 08 Feb 2019 16:15:29 -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:mime-version:content-disposition :user-agent; bh=wyReugPXrxIiS774VlKOeus0XlUa4VY30FlEPNXHAyg=; b=o/0Fmcm87YMga4x6C8XfsoX8sIlAjswRgK2YhRPfwuCLV30yCBSIuRJJ7QiIOWCfMN shWksOAsWQzyvXB8ucSAmGGU/ys+uWb+updPeL1B8hzcjpHqLV7KtZdhMo/QLscK43sP /5InNCTrYlIX3rt2xxFw9+gbV33Fx+/NJm9h4s9sNrPUgWACHNAHypWpHo62L33E8geb ujAdHjZPC7BliI8jnvA3d055z09KOG0ozRmKuQp41AOQO49Msf3YVIds2rstYGXGagsI eSl/iGRpaj9xauF3OvRPFJlbceqbUWY51LtJACO5+mFhkaxaD9mkl0uiLB5r91RMtGlR BpiQ== 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:mime-version :content-disposition:user-agent; bh=wyReugPXrxIiS774VlKOeus0XlUa4VY30FlEPNXHAyg=; b=f0JKEQMnfQYCyGr+6Tew/MniUofdmPmzluS3CGtMhLjpv5QDe41pPmsGs6MdZK2UCS KYPu4VkhTrmgQnY6QOn69v4MWuInIJAY/4Y5l/40sXuWQOcrxW6dZj3ziMVu2farzn/n Qn71Y0l6E1wi3QMnQ3i8hSPjwlnu0NnurKLuEkZjpisAd87chmiYsvRrKk48lvvrtZBA AKbvPBJg4iMRbLkfzVaLY5BnCmcAHcJIUakKL7v9LFJynAIiKipagZz0I2Zpq+WMYUdB TdMQ+XF5R5vuQTskMCe1JQwBnpj25cbKPqVqY9nvIV+Uim032SGMxYpOW4bL0aDrkEjF nZ9Q== X-Gm-Message-State: AHQUAuanrD6JmR11KEXtlXa/80AJuv+c3vZC94NbNz8Htam7ch91s6y0 g9mKHGRKuu/7kQPkEgkQS8U= X-Received: by 2002:adf:f692:: with SMTP id v18mr17492386wrp.229.1549671329355; Fri, 08 Feb 2019 16:15:29 -0800 (PST) Received: from gmail.com (79.108.96.12.dyn.user.ono.com. [79.108.96.12]) by smtp.gmail.com with ESMTPSA id o64sm4975481wmo.47.2019.02.08.16.15.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Feb 2019 16:15:28 -0800 (PST) Date: Sat, 9 Feb 2019 01:15:22 +0100 From: Miguel Ojeda To: Robin van der Gracht Cc: Sven Van Asbroeck , Tejun Heo , Lai Jiangshan , Sebastian Reichel , Dmitry Torokhov , Kees Cook , linux-kernel@vger.kernel.org Subject: [PATCH] auxdisplay: ht16k33: fix potential user-after-free on module unload Message-ID: <20190209001522.GA11769@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: elm/2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On module unload/remove, we need to ensure that work does not run after we have freed resources. Concretely, cancel_delayed_work() may return while the callback function is still running. From kernel/workqueue.c: The work callback function may still be running on return, unless it returns true and the work doesn't re-arm itself. Explicitly flush or use cancel_delayed_work_sync() to wait on it. Link: https://lore.kernel.org/lkml/20190204220952.30761-1-TheSven73@googlemail.com/ Reported-by: Sven Van Asbroeck Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/ht16k33.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c index a43276c76fc6..21393ec3b9a4 100644 --- a/drivers/auxdisplay/ht16k33.c +++ b/drivers/auxdisplay/ht16k33.c @@ -509,7 +509,7 @@ static int ht16k33_remove(struct i2c_client *client) struct ht16k33_priv *priv = i2c_get_clientdata(client); struct ht16k33_fbdev *fbdev = &priv->fbdev; - cancel_delayed_work(&fbdev->work); + cancel_delayed_work_sync(&fbdev->work); unregister_framebuffer(fbdev->info); framebuffer_release(fbdev->info); free_page((unsigned long) fbdev->buffer); -- 2.17.1