Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1348682pxm; Sat, 26 Feb 2022 12:34:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx15zqIwdvRvGKuT0PWcbIAYcw2tT6B95azSIN/PlvAGCv/+vM2yGg898btMz3Yz/v4wriq X-Received: by 2002:a17:903:244d:b0:150:18f3:8e98 with SMTP id l13-20020a170903244d00b0015018f38e98mr12795963pls.28.1645907643111; Sat, 26 Feb 2022 12:34:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645907643; cv=none; d=google.com; s=arc-20160816; b=lCTPI5lmZ0NtyuXbIgVsrZpK87rWptrhTIVTIko0IFEpnsb7hUJNu7KXoqyL6Q38nd F4UPev2YXgbj+pZpovD0NRXLwpqLWbQZLJ/36hkMH7tj8oAXACIy52DJsD8qzeCJFpI4 9zYV/ZVVyo492ckLnL4WO+reaxw1U2tMbZKVElgiWjqZ+/tu3wKXQHRuh490WpbWvMEH wk8GLdZcZDhY4OGWc43641+1ImbttVljqsN5NDnOfiv5vrl87axb2tpkaMKJ0e/+O3ev I8NfBJ2EVQw0tTeGS198F3cC1xw+OUV94nKXkXb89fAKPgPp4OoyS+7lRlGkRI26bARI OVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9yCcSGVYN3jLB7eJbP2OW/SZZ9s+/VmmHUtUePxZZew=; b=sb/GCp0q2Q333JrWDK2+yN7VMB28I+HkugIsaLfG0hT3RJ+AG6xXdbOdCSmpbRk4bO 48HWI3/fIJTj5AyQ1lFsK5an0SslDm3oMn1ipq8hj4WrV07OWRL7K63zMD4T+BTVfk5H v5Mrf8CuJB4+VLHGcx5/98sSMzMYvKnOw2bJteXaVKT0Cw8ALF8aWaBlVSd0A8ngK6/v YI0+omaBhMyaLpAsSdFIf5QqOYtXjY2/iZ0109iCqA9VrGGKazerzZKOKxvA5TkxAzMg qvxTBauvjPz2TOEVyB9CyiiapgbPSubcRGGa5vFSZ7bnJDjX5nzjHQCYl9Tj1PCRjKPX fJng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=KQracF7U; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id co6-20020a17090afe8600b001bd0ee94839si3055805pjb.2.2022.02.26.12.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 12:34:03 -0800 (PST) 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=bombadil.20210309 header.b=KQracF7U; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B74048E48; Sat, 26 Feb 2022 12:28:13 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbiBZU2j (ORCPT + 99 others); Sat, 26 Feb 2022 15:28:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiBZU2g (ORCPT ); Sat, 26 Feb 2022 15:28:36 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9050643ADE; Sat, 26 Feb 2022 12:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description; bh=9yCcSGVYN3jLB7eJbP2OW/SZZ9s+/VmmHUtUePxZZew=; b=KQracF7UT2+2lVsCGP4/4gnqHh y1qif2Yv++GeyzOY/D/0H13vrs4I4WQN6WbY/U/vP7bkECgz1Z+qs6lnM71dc6UQS0GIsUyb5WS59 Je0aey7gbY/GRxAbTAzlmp8w98YpFaAy9Mb3sjNuZRSWyVqZXz5H9+vNO0WSvH/lvOoXUgyS0dFLV 1+pEbKIlBt+FwAQq4/LAv/z93LctaIJ/cxJSWUSvDxQKmcf6iC1ELaFDdbz5zoxsaML9ZGcZVFkS5 rJCoM0E+eaSgpJPZpDEzTp90pIk3UfqwQNZ01w1jD+I8Q16o1eTVOTFfRrGAFrstZCC/kPTfA6MBw t6S0IFig==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nO3fS-008UKJ-4C; Sat, 26 Feb 2022 20:27:50 +0000 Date: Sat, 26 Feb 2022 12:27:50 -0800 From: Luis Chamberlain To: Christophe Leroy Cc: Aaron Tomlin , Petr Mladek , "cl@linux.com" , "mbenes@suse.cz" , "akpm@linux-foundation.org" , "jeyu@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-modules@vger.kernel.org" , "void@manifault.com" , "atomlin@atomlin.com" , "allen.lkml@gmail.com" , "joe@perches.com" , "msuchanek@suse.de" , "oleksandr@natalenko.name" Subject: Re: [PATCH v8 09/13] module: Move kallsyms support into a separate file Message-ID: References: <20220222141303.1392190-1-atomlin@redhat.com> <20220222141303.1392190-10-atomlin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 Fri, Feb 25, 2022 at 12:57:34PM +0000, Christophe Leroy wrote: > > > Le 25/02/2022 ? 13:21, Aaron Tomlin a ?crit?: > > On Fri 2022-02-25 10:27 +0000, Aaron Tomlin wrote: > >> On Fri 2022-02-25 11:15 +0100, Petr Mladek wrote: > >>> rcu_dereference_sched() makes sparse happy. But lockdep complains > >>> because the _rcu pointer is not accessed under: > >>> > >>> rcu_read_lock_sched(); > >>> rcu_read_unlock_sched(); > >> > >> Hi Petr, > >> > >>> > >>> This is not the case here. Note that module_mutex does not > >>> disable preemtion. > >>> > >>> Now, the code is safe. The RCU access makes sure that "mod" > >>> can't be freed in the meantime: > >>> > >>> + add_kallsyms() is called by the module loaded when the module > >>> is being loaded. It could not get removed in parallel > >>> by definition. > >>> > >>> + module_kallsyms_on_each_symbol() takes module_mutex. > >>> It means that the module could not get removed. > >> > >> Indeed, which is why I did not use rcu_read_lock_sched() and > >> rcu_read_unlock_sched() with rcu_dereference_sched(). That being said, I > >> should have mentioned this in the commit message. > >> > >>> IMHO, we have two possibilities here: > >>> > >>> + Make sparse and lockdep happy by using rcu_dereference_sched() > >>> and calling the code under rcu_read_lock_sched(). > >>> > >>> + Cast (struct mod_kallsyms *)mod->kallsyms when accessing > >>> the value. > >> > >> I prefer the first option. > >> > >>> I do not have strong preference. I am fine with both. > >>> > >>> Anyway, such a fix should be done in a separate patch! > >> > >> Agreed. > > > > Luis, > > > > If I understand correctly, it might be cleaner to resolve the above in two > > separate patches for a v9 i.e. a) address the sparse and lockdep feedback > > and b) refactor the code, before the latest version [1] is merged into > > module-next. I assume the previous iteration will be reverted first? > > > > Please let me know your thoughts > > > > [1]: https://lore.kernel.org/all/20220222141303.1392190-1-atomlin@redhat.com/ > > > > I would do it the other way: first move the code into a separate file, > and then handle the sparse __rcu feedback as a followup patch to the series. I want to avoid any regressions and new complaints, fixes should be submitted before so that if they are applicable to stable / etc they can be sent there. > Regarding module-next, AFAICS at the moment we still have only the 10 > first patches of v6 in the tree. I guess the way forward will be to > rebase module-next and drop those patches and commit v9 instead. Right, I'll just git fetch and reset to Linus' latest tree, so I'll drop all of the stuff there now. And then the hope is to apply your new fresh new clean v9. Thanks for chugging on with this series! Luis