Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5396813ima; Tue, 5 Feb 2019 11:03:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ3S8PHfKmpPKQMKA4+ljg2G/S0+NEGdj/+y3KruUG9mA7fHZ/nGunuN+0jcP5kMWAWR5Gy X-Received: by 2002:a65:6542:: with SMTP id a2mr5805057pgw.389.1549393405539; Tue, 05 Feb 2019 11:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549393405; cv=none; d=google.com; s=arc-20160816; b=ORXNeMzoXtNiWh0b1SG1cakxCfxhrjxX+iKYI2WoeNvkZ6Uq2YLpEpW9IySokFYJwW qHwEiDU+E2obyVlMlCe3Y7653HLNAmRASWY0ISknsG5Nsc6BdRb/nLj6L09EZDcqQ8dU J8bUYeaU6qWBEXo7RVLeKBMY9GKBXku9aAVDf+Et8AKmqb5wllS6XOsYATtLJrwm5rwq 1cqAYMUqVDICZRuUqG7Key8YM0GQo2m+SQzqMTvGe6+cOUteyjbrn4iNn3X+6YNytiHK 90rdN7iwVDRPzCHnUuCq7UCL8SJuk6U/o7sirx/4udCyrIuR2CaSkEyc7HTtSKNDVEKd XlDg== 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=z6yD4VTjsjs5vHJIyoHdO2uNYcVKqlSLXGkiIhV5sPU=; b=EFMd/4oi3Op2JKj16+GogZeXa0e7/2CWFW6u/7nwtqEutzjEeDd3ACF5lGrHraoYqr T8QSgTA61A9lWwMr5xzGM3waBO/8v4NujB853NVLBp5GDwg/cdMaN/fG1ZmyKENj+5j6 pZoveqop5ZEmrEAhg6zXsZe0JmHKI1QzaP+Wv2AlP7E8RdkseSyEwkQlub3N2PQtKlN5 nWg/sfPxpiQ/nYGiaq39Uau6BQ+KDpkouHzsRDpt7b7jHLH/5Ac0gZPlbA0FlmKEN/He U1UP3AOtW5la8UKPLCl4KFRjmT8b4aS+5hhKA6Njdtncbee/pB3RfMMD8MgpJnFEcTPB DZ8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lcqk6mwS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si3476813pgq.36.2019.02.05.11.03.09; Tue, 05 Feb 2019 11:03:25 -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=@kernel.org header.s=default header.b=Lcqk6mwS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729404AbfBESn7 (ORCPT + 99 others); Tue, 5 Feb 2019 13:43:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:42162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbfBESn7 (ORCPT ); Tue, 5 Feb 2019 13:43:59 -0500 Received: from localhost (unknown [167.98.85.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A303420811; Tue, 5 Feb 2019 18:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549392238; bh=efIApx4917Iza3mL9mRxqSTNdRRyvX7xbsA4PuiXWJM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Lcqk6mwS6fNyrrtkM5Sd0+4iuQWg+jK3+pTMeCNd2SBr8YKP290630hwBoyvf6Bv7 JAfV8IrpqKFg63B7cW9d8Z/pryxL8DOlzBoua2ouIZ1o6gtyb242wdSN6siJS46Z9g T81UCQmfczNzMjfdAma+zHu9dRMqsEo33yh6IDgI= Date: Tue, 5 Feb 2019 19:43:55 +0100 From: Greg KH To: Sven Van Asbroeck Cc: Kees Cook , Tejun Heo , Lai Jiangshan , LKML , Sebastian Reichel , Dmitry Torokhov Subject: Re: [RFC v1 0/3] Address potential user-after-free on module unload Message-ID: <20190205184355.GC22198@kroah.com> References: <20190204220952.30761-1-TheSven73@googlemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) 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:22:50AM -0500, Sven Van Asbroeck wrote: > On Tue, Feb 5, 2019 at 9:57 AM Kees Cook wrote: > > > > > > Can a Coccinelle script get written to find module-use of the non-devm > > work init? > > My thoughts exactly ! But sadly I'm not a Coccinelle expert. I did > look briefly at > its syntax, but I didn't immediately "get" how Cocci could find this class of > errors, without a huge false positive rate (which would make it worse than > useless). > > > > > It seems like finding these in __init functions should be relatively > > easy? (Or can we add runtime detection in the existing INIT_*WORK() > > code to see if it is running from the wrong place?) > > > > IMHO the problem isn't that they're called from __init functions. > Also, nothing is > wrong with the location of INIT_*WORK per se. > > The real problem is that developers overlook calling cancel_work_sync() > on unload. I'm not sure how we could bolt on runtime detection to catch > a *missing* function. Again, without causing tons of false positives. It really should happen when the device is removed (if it is a driver that binds to a device.) If this is not a driver, then there should be some way to scan that cancel_work_sync() is never called or not, right? thanks, greg k-h