Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp987734pxb; Fri, 15 Apr 2022 17:31:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv5ADI4dw7QPOC5V6MYMI/fCMYfsXPibkZhF50gc2kp5mmE/5Ri79khdmWIVxGdt0hgyQj X-Received: by 2002:a17:90b:314b:b0:1cd:5ffc:ca95 with SMTP id ip11-20020a17090b314b00b001cd5ffcca95mr6712616pjb.148.1650069075482; Fri, 15 Apr 2022 17:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069075; cv=none; d=google.com; s=arc-20160816; b=JlgOqLl/VRVipzp3lh+WtO43OhnvjcuP37ZwgXAi0h+YZzyRnwAzmqstrsQSyvMx4v C+gPoW9uFrblLrrv0uARR0Voyc2UPVfpogj5rMT+X5GoyeZbGZG+PBSJkiyONNxkxtvd Uhd/PyO0X9VDMwcBt6Ml+mwwhV2AO+3yD5MRQ7/n4ikQVkqHPetZA+TOSdrpBbnAUMOw OJH2dJPz0aNf7JHdPy8V2JBBg8RO23ZA6i2/q42lQWxwtPy2tDzrqofwCRvq2dMKler0 pFyrShk0vEh6IhTcRaoGHn6h3Lsxud/mQpXeusWMi1bOtsq7YENaDwGIQTUeNA8oQprA kO6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TY7QrgqvgkH5i76LkYOioJ0Vkl4t7pW84wpQ7D92y58=; b=rQHEC49gJREowxfAHGlEabYwPSecu35zSYk+9aI4Fc+nSyhsAqAt1OEQYzZcQXiKgl fZAX7d49sAUpqABqoyTGpO2FVH3s26IzoJFAV/uUwrGzNP2WDFIuVW/bOEj6r9Ni7/6z CELHShL4/XGNgEuXBP0VCi7cR03eqPIddCDkwZrE0sFXAK8sQUU6yWj1wKzJ7G40sUFt MavCcMgGSFEkLRLMSa0+e9e7chl9OekGcUIDAoudowGICpS75OS2YfKazZEbAF3nskNZ oDmRMo0l2+/Cv5OwtBs+cFbOX32hMRnzU7Y4BsuxYz+cYYsfNeBwJ/dRg5IdA5ViqwW5 m72w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=AcTLpeAa; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n2-20020a654882000000b003992df07a71si2771169pgs.662.2022.04.15.17.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:31:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=AcTLpeAa; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A86B8F3A6A; Fri, 15 Apr 2022 17:28:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351263AbiDOH4Y (ORCPT + 99 others); Fri, 15 Apr 2022 03:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbiDOH4X (ORCPT ); Fri, 15 Apr 2022 03:56:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D2959BB84; Fri, 15 Apr 2022 00:53:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=TY7QrgqvgkH5i76LkYOioJ0Vkl4t7pW84wpQ7D92y58=; b=AcTLpeAaH8w+tdpl/NmhorrElG atvXYjPxEjQikC6x8SE+8HDVNTKWoEM+FsvUcvG076jAx7xNIBIvcqgiwE0V3stZBhNYOXvvA8vnZ zc4gx12b/A49yO4WhN6hQsKF84PF1ZIKeDYCKEyTke1hgE7VU8FSAQ7J9g203MaXF6QO8AGljarVP CiPXaijMzIGIDUDOW4kMw/7ezQFealbxmBG93M5cbBcYs9iGkeAWRYzU3JLVT2kx8bAwbi1fzS0Tr 4+8w56oKLwIqD+IPKGefsfHR8DOgu51TXQliqANImjXt/+Xm+usnuab0TgQGxZ+xFgwj5I68klTUD SZQ9CvVg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfGm5-00Fwly-Ay; Fri, 15 Apr 2022 07:53:49 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E02683001AE; Fri, 15 Apr 2022 09:53:48 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9D2DF2025D913; Fri, 15 Apr 2022 09:53:48 +0200 (CEST) Date: Fri, 15 Apr 2022 09:53:48 +0200 From: Peter Zijlstra To: Dan Williams Cc: linux-cxl@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Dave Jiang , Kevin Tian , Vishal L Verma , "Schofield, Alison" , Linux Kernel Mailing List , Linux NVDIMM Subject: Re: [PATCH v2 02/12] device-core: Add dev->lock_class to enable device_lock() lockdep validation Message-ID: References: <164982968798.684294.15817853329823976469.stgit@dwillia2-desk3.amr.corp.intel.com> <164982969858.684294.17819743973041389492.stgit@dwillia2-desk3.amr.corp.intel.com> <20220413084309.GV2731@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 14, 2022 at 12:43:31PM -0700, Dan Williams wrote: > On Thu, Apr 14, 2022 at 12:34 PM Peter Zijlstra wrote: > > > > On Thu, Apr 14, 2022 at 10:17:13AM -0700, Dan Williams wrote: > > > > > One more sanity check... So in driver subsystems there are cases where > > > a device on busA hosts a topology on busB. When that happens there's a > > > need to set the lock class late in a driver since busA knows nothing > > > about the locking rules of busB. > > > > I'll pretend I konw what you're talking about ;-) > > > > > Since the device has a longer lifetime than a driver when the driver > > > exits it must set dev->mutex back to the novalidate class, otherwise > > > it sets up a use after free of the static lock_class_key. > > > > I'm not following, static storage has infinite lifetime. > > Not static storage in a driver module. > > modprobe -r fancy_lockdep_using_driver.ko > > Any use of device_lock() by the core on a device that a driver in this > module was driving will de-reference a now invalid pointer into > whatever memory was vmalloc'd for the module static data. Ooh, modules (I always, conveniently, forget they exist). Yes, setting a lock instance from the core kernel to a key that's inside a module and then taking the module out will be 'interesting'. Most likely you'll get a splat from lockdep when doing this.