From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26051C433F5 for ; Tue, 14 Sep 2021 17:46:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07EC9604AC for ; Tue, 14 Sep 2021 17:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229861AbhINRrt (ORCPT ); Tue, 14 Sep 2021 13:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbhINRrt (ORCPT ); Tue, 14 Sep 2021 13:47:49 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A34BAC061764 for ; Tue, 14 Sep 2021 10:46:31 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id f65so13038776pfb.10 for ; Tue, 14 Sep 2021 10:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=30/B84g0scVe64w1jrJPAZx8Vu/dGGlZHuOB6QGy0Rs=; b=RX+Ricnc4mmAv/2u3XbIfohQD7aUkR5aJ5OTlSvGLp5M85x/LTP2P05AipcYelIDJ3 wLfcoD+QlsV7Uq+8fE3q1QnE+7ZcIf+kjtWCEHmbbp+eJ0e7f7R1Gky7wN33PU3WWQl1 QcFTHx+ryxw+dJM2lQRfrPwczd0yif6mVX59ueVVZV3O+HnXX+qgT7J09v7koiTcmxTA jElVUo7qtfnXc58sreR7P5KN7wURFXbIEyT1agjHoU4YgRXZA9KDRljEfwd6ppOEKA5c qxgaA3g4hne6kR9VbCp6GoaQs1pFsNtR2XsIcoDTgnd4onlGk6P1LhtneyRs6sJWs1zJ yj6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=30/B84g0scVe64w1jrJPAZx8Vu/dGGlZHuOB6QGy0Rs=; b=E0O/i0mdI1BUeAbEih2Q7HC0YOmluY94SstQ/EH8qFAdpeTUx0nHPhfip6Xkbn3LYV gMTkJXx8jF1g+qgVk1QKOABjYOcjw3yeIuob5vv52xMHvRwvsBI+sWMtDeYv/WXgwAzd 8eU33sDKX2KOctIzQl0AySXbf3kqq84XH7fQxyD3/owGUeq6vymGsxrY6+URiBVjgNpA Kzt2U2aL+69GUTSevOBCOb3PwJfSrlfMhB0eOYp0/DqS4XRD8Gq4qKBhRfIuPjR8571t WzcGzwd8sjO/xmnzJaHzUGuPptStIOcWweCwY1Hlv61nRuf1fx0Ie/qtZW6i0g8vSaQt j1YQ== X-Gm-Message-State: AOAM532sFXoYd/779/04Fs/XeVqlMzxRAQzWPQeihuhmS2sjcZ9zbFaq XBKpUFE9EKEi9uQ+3n4RLXGay12aiOyB1xpQnmJFUw== X-Google-Smtp-Source: ABdhPJxUeTTwLZ7dZVb7Aqg1iR36DJipbk6h5IrKFiR+Fg8R/Iea/pxUrveUY66JJyNJIBPnyaH0QEdNGlp4fR3d7bg= X-Received: by 2002:a63:3545:: with SMTP id c66mr16405202pga.377.1631641591034; Tue, 14 Sep 2021 10:46:31 -0700 (PDT) MIME-Version: 1.0 References: <20210913223339.435347-1-sashal@kernel.org> <20210913223339.435347-4-sashal@kernel.org> In-Reply-To: From: Dan Williams Date: Tue, 14 Sep 2021 10:46:20 -0700 Message-ID: Subject: Re: [PATCH AUTOSEL 5.14 04/25] cxl/pci: Introduce cdevm_file_operations To: Sasha Levin Cc: Linux Kernel Mailing List , stable , Ben Widawsky , Jonathan Cameron , linux-cxl@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org On Tue, Sep 14, 2021 at 10:01 AM Sasha Levin wrote: > > On Tue, Sep 14, 2021 at 08:42:04AM -0700, Dan Williams wrote: > >On Mon, Sep 13, 2021 at 3:33 PM Sasha Levin wrote: > >> > >> From: Dan Williams > >> > >> [ Upstream commit 9cc238c7a526dba9ee8c210fa2828886fc65db66 ] > >> > >> In preparation for moving cxl_memdev allocation to the core, introduce > >> cdevm_file_operations to coordinate file operations shutdown relative to > >> driver data release. > >> > >> The motivation for moving cxl_memdev allocation to the core (beyond > >> better file organization of sysfs attributes in core/ and drivers in > >> cxl/), is that device lifetime is longer than module lifetime. The cxl_pci > >> module should be free to come and go without needing to coordinate with > >> devices that need the text associated with cxl_memdev_release() to stay > >> resident. The move will fix a use after free bug when looping driver > >> load / unload with CONFIG_DEBUG_KOBJECT_RELEASE=y. > >> > >> Another motivation for passing in file_operations to the core cxl_memdev > >> creation flow is to allow for alternate drivers, like unit test code, to > >> define their own ioctl backends. > > > >Hi Sasha, > > > >Please drop this. It's not a fix, it's just a reorganization for > >easing the addition of new features and capabilities. > > I'll drop it, but just to satisfy my curiousity: the description says it > fixes a use-after-free bug in the existing code, is it not the case? It does fix a problem if the final put_device() happens after the module text has been unloaded. However, I am only aware of the artificial trigger for that (CONFIG_DEBUG_KOBJECT_RELEASE=y). I.e. if CONFIG_DEBUG_KOBJECT_RELEASE=n I am not aware of any agent that will hold a device reference besides the driver itself. That was the rationale for not tagging this for -stable.