Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5169118ima; Tue, 5 Feb 2019 07:25:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IZvo88FRVWz+mAahAY5ZgIaKt6xezTbC1pRtOx9tsJq5lACDDlpqrKlJeJJpJYLc4heQv9v X-Received: by 2002:a63:484c:: with SMTP id x12mr5004829pgk.375.1549380315199; Tue, 05 Feb 2019 07:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549380315; cv=none; d=google.com; s=arc-20160816; b=IM7LqMyAO5W/I3+OkOzI6RT/0QSQiFB6m9hP3FrhfvjyN9Wmv0C3FTSMq+z9NtXAcZ J/k2zRDPSiM34oiTKaINErbkPZ908iAoiSLoWmXudCAQFsR1IN+HeGTeISPxmlg3fDBO u8HmFbnplYTv4qmBCSN3+C/vpGAIyD+s95IaJkGCoroKZ72DMFaOU9tcH6I2CVUx05eh 2g6ao0Jq/TwF7FnQb/aJY4fWvoBwzTkqNR6ha0/WDiVrgYXsuDCWJ+ih3iiw0qriRk2M 1CD0szQBtZz/X1MHWxN1QB1nAh+OdU5bM5I7NvaUCOyrr7jo5zTwGYjIWpg8OgddGFn2 /eNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JHvrpSBtrE0fka2owfLPmjsKj68frWtOpkzmFj2aAJc=; b=yK2sE5WYKHSVT/gSqcS5uElxJQzvAtvn42J4JM2YKN02MuRJ9tfmfcO2kGnzgKTo3d +IcdRUggUvqb95KGRwqzDUSdDkSeRG3GyhittRgTRzd4GZOxQq5R76ouQcs71xc8EGiv DfZePhSu/nCJtVu7BEnG23wNA3xqNLwrLB952o0Kdkz9QEipNFomFkN96V1UjfUoKjMS 7PrN2zlIF77Y7RZ8XYVY2IK+NSAXO3jbcHm8G98mi5NyXbD17N0wkHpvHgW7DpFmEGVK Kl2xG92NPjyQ6wcQsY9vOmdUdyQ+vurh0YRqqSHhrtWaVsqJHgBakHxy6YJOPW84axnc +dfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CX2WI5B7; 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 o11si3265897pll.160.2019.02.05.07.24.58; Tue, 05 Feb 2019 07:25:15 -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=CX2WI5B7; 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 S1729724AbfBEPXD (ORCPT + 99 others); Tue, 5 Feb 2019 10:23:03 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:36587 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729425AbfBEPXC (ORCPT ); Tue, 5 Feb 2019 10:23:02 -0500 Received: by mail-ot1-f67.google.com with SMTP id k98so6297487otk.3 for ; Tue, 05 Feb 2019 07:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JHvrpSBtrE0fka2owfLPmjsKj68frWtOpkzmFj2aAJc=; b=CX2WI5B7R1tFq8HgCn67HEoiwkURvV7Umg9NoWZb/A0fLsGrJV/Sv/cT01T8IVU6Su ro20m6i/XORZwUOdXfkpExaygQU63o/RqmotZuQaHvcuVEZNZ4+fCNRREYrWDnrbg0/r 8C8gfaIC+4diRDPd0yD3ooRDeofIDlW6inL+bgGmumkHzYQKgLgUJ1+vZh3AyTCAvPcq 4xxInuNn9ygFsNsLR9AEPABSs4wweRAhFYt2af7AXpiAKWeKFocLJhrRCvjqPexmeEYD nFnQ6zwyv5M6G7VthpFzcModOhaGSbemL0/+VYzENgFb7/KgCkyIntEKXIwtn76WnAfU hsUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JHvrpSBtrE0fka2owfLPmjsKj68frWtOpkzmFj2aAJc=; b=tkAhx+4xYCm46MQ75WNiyWRjEbMZ6j7LG6/K7FOEmeehseUg2oVLzobifmLvZQnKF7 iqLzsHHrGp4+FC5juO5nBR9G3AWc8EjN4vjowmK7nEeXQEfRYcN4fzyFqIrns/X1r1wc p6WA7VdAP2ZfJpdUoQNL4sGo8aVFI4JfpzTHaEW5+dRl1heLlDrdn80usdeWe2Gn8KeQ 5vSZrZzl5HKY/Qmu50r/JfFqtcPXiwrgAPNwoPo35TIMR+VBLZDSawByCkYbbYhdenzy pZCEMq8VcRw4zO6KHZ/AHGj3L5EmV02/jcX7mkzGFgGflVpC3yUjLFdBqP0jegc8T/+B i+sw== X-Gm-Message-State: AHQUAubcjdYsGe8MplVNZaMjY/SgcoXqkRErwhcllKeJAq4yZZZAAQzs dOoztQmnv3z1XmOmyOkdsg1yfw+H4UKgUDxztmc= X-Received: by 2002:a9d:7e87:: with SMTP id m7mr3119816otp.225.1549380181709; Tue, 05 Feb 2019 07:23:01 -0800 (PST) MIME-Version: 1.0 References: <20190204220952.30761-1-TheSven73@googlemail.com> In-Reply-To: From: Sven Van Asbroeck Date: Tue, 5 Feb 2019 10:22:50 -0500 Message-ID: Subject: Re: [RFC v1 0/3] Address potential user-after-free on module unload To: Kees Cook Cc: Tejun Heo , Lai Jiangshan , LKML , Sebastian Reichel , Dmitry Torokhov , Greg KH Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.