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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 1BD32C63777 for ; Tue, 24 Nov 2020 18:32:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8201208FE for ; Tue, 24 Nov 2020 18:32:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ELUJcJFa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390950AbgKXSbp (ORCPT ); Tue, 24 Nov 2020 13:31:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390911AbgKXSbn (ORCPT ); Tue, 24 Nov 2020 13:31:43 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1EB1C0617A6 for ; Tue, 24 Nov 2020 10:31:43 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id t8so19332338pfg.8 for ; Tue, 24 Nov 2020 10:31:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3pDNDxEpeYYvG914Ntyi16QK2xKi5rl8BfIONS+Vyeg=; b=ELUJcJFa5YynV0JyRD0UJRvb02Kq/8+szcZ74mPsjminVRYns9l5GjTqtDeD56vdba /Vq45RCeCw5y+xBvdcDxpAZhRMo9XCozUXBS0s50mktV6vzOOrrhn5JYNj3KfQN/kITA c7pKuuPug34WduB9P1254ddZ3C6QpbRBSFqCbkvDZxN1JW767q9XAlj1y87Vm+U0N23M YA9qjlZG3Uy7FmfiAqZ3WQ87Wf1TRG//aomGQugTH0QWcHbyuMMvSvPRRj08Ty5mDtPo c1e34nWq0ZeLTeKodqZXNOEQPuxWVtB3mH1q6US9nWc5h3nY+sN4kbzFtVREl1c6Hhu0 L35A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3pDNDxEpeYYvG914Ntyi16QK2xKi5rl8BfIONS+Vyeg=; b=Eq6Ls1hycI2RBKETzUo7KHRR1qzrkvXMu1LnHXQwNZ1arOqpCrGnkjNMQ/OsUw+pgI TCCHUFBVwocS5sRxBq+l7NahVrSyBWvvgx8E3tGuQ3v/0eWjaCSavhgrLDYJDt91uRLB HuLSeNnDaK19l9R/higSyu4QYFY7GghDfz98E5YpRSLT8pgNscDIliFuIozTltdcso94 XgDP59fiJiP/IjetLlc0EzBvl2Gp0kXRj83eAmTP5yCLrcWpLRv5iVpYcQsxxubt9YIL Buh56HjUx7b63pURmz0XYf5CJ1ybmIIRPsjYtlg6MvXv6Wg8w1+PhuyMIGA1y982jXBp a+Mg== X-Gm-Message-State: AOAM530Gt8XE4jRH24y8l3jkcUNXCQLrIRYho07Hee3+bjx6QrEPekOY DAc3Cqqf+cyPIVXKLFcHZOIuFg== X-Google-Smtp-Source: ABdhPJyghN+EqQmUdCa4cnajESqcIMR9Xebl3t9XLppVtosvtPKWGGg0RUN3t+ytILKbLhb4mu2ytQ== X-Received: by 2002:a62:1455:0:b029:18b:83a2:768b with SMTP id 82-20020a6214550000b029018b83a2768bmr5154475pfu.3.1606242702917; Tue, 24 Nov 2020 10:31:42 -0800 (PST) Received: from google.com (h208-100-161-3.bendor.broadband.dynamic.tds.net. [208.100.161.3]) by smtp.gmail.com with ESMTPSA id 64sm15739121pfe.0.2020.11.24.10.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 10:31:42 -0800 (PST) Date: Tue, 24 Nov 2020 10:31:39 -0800 From: William Mcvicker To: Greg Kroah-Hartman Cc: Jessica Yu , Christoph Hellwig , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, kernel-team@android.com, Saravana Kannan Subject: Re: [PATCH v1 0/2] Add support to capture external module's SCM version Message-ID: <20201124183139.GB737971@google.com> References: <20201121011652.2006613-1-willmcvicker@google.com> <20201123090257.GB6334@infradead.org> <20201123221338.GA2726675@google.com> <20201124093117.GA21089@linux-8ccs> <20201124180516.GA737971@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 24, 2020 at 07:12:40PM +0100, Greg Kroah-Hartman wrote: > On Tue, Nov 24, 2020 at 10:05:16AM -0800, William Mcvicker wrote: > > On Tue, Nov 24, 2020 at 10:31:18AM +0100, Jessica Yu wrote: > > > +++ William Mcvicker [23/11/20 14:13 -0800]: > > > > On Mon, Nov 23, 2020 at 09:02:57AM +0000, Christoph Hellwig wrote: > > > > > On Sat, Nov 21, 2020 at 01:16:49AM +0000, Will McVicker wrote: > > > > > > These two patches add module support to capture an external module's SCM > > > > > > version as a MODULE_INFO() attribute. This allows users to identity the SCM > > > > > > version of a given kernel module by using the modinfo tool or on the device > > > > > > via sysfs: > > > > > > > > > > As this obviously is of no use for in-tree modules it falls under the we > > > > > don't add code to support things that are not in tree rule and has no > > > > > business in the kernel. > > > > > > > > Hi Christoph, > > > > > > > > Ah sorry, I didn't intend this to come across as only for external modules. > > > > That just seemed like the easiest way to explain how the scmversion attribute > > > > can be different from the vermagic. We mainly need this for in-tree kernel > > > > modules since that's where most our drivers are. Let me re-phrase this with > > > > that in mind. Basically, I like to look at this as an improved version of the > > > > existing srcversion module attribute since it allows you to easily identify the > > > > module version with a quick SCM version string check instead of doing a full > > > > checksum on the module source. > > > > > > > > For example, we have a setup to test kernel changes on the hikey and db845c > > > > devices without updating the kernel modules. Without this scmversion module > > > > attribute, you can't identify the original module version using `uname > > > > -r`. And for kernel modules in the initramfs, you can't even use modinfo to get > > > > the module vermagic. With this patch, you are able to get the SCM version for > > > > *all* kernel modules (on disk and in the initramfs) via the sysfs node: > > > > /sys/module//scmversion. This also works the other way around when > > > > developers update their kernel modules to fix some bug (like a security > > > > vulnerability) but don't need to update the full kernel. > > > > > > Hi Will, > > > > > > If this were also intended for in-tree kernel modules, then why do > > > intree modules only get the UTS_RELEASE string in their scmversion > > > field, which basically already exists in the vermagic? Or do you plan > > > to change that? > > > > > > Jessica > > > > Hi Jessica, > > > > Thanks for asking! The reason in-tree kernel modules get the UTS_RELEASE string > > is for a few reasons: > > > > (1) It contains the SCM version (since UTS_RELEASE has that). > > (2) It allows you to get the SCM version via the sysfs node (useful for modules > > in the initramfs). > > (3) It helps identify that that particular kernel module was in-tree when > > originally compiled. > > (4) Using UTS_RELEASE also allows us to respect the privacy of kernels with > > "# CONFIG_LOCALVERSION_AUTO is not set" by not including the SCM version in the > > module scmversion attribute. > > > > Now, if we don't care about knowing if a module was in-tree or not (since > > we only care about in-tree modules here anyway), I can update the patch to have > > a consistent format regardless of in-tree or external. Personally, I like the > > UTS_RELEASE version better because it gives me more information from the sysfs > > node which is useful when debugging issues related to modules loaded in > > initramfs. > > We already know if a module was built in-or-out of tree, the "O" taint > flag is set, so that information is already in the module today, right? > Can't that be used somehow here? > > thanks, > > greg k-h Hi Greg, Let me prefix this with this, I do see the benefits of having a consistent scmversion format for intree and out-of-tree modules. So I'm happy to fix that in the next patchset. Now, I could be wrong, but I believe the taint flag is only printed when the module is loaded: XXX: loading out-of-tree module taints kernel. or when there's a kernel WARNING or kernel crash. But that assumes you have the full logs when the kernel booted or you have a full crash stack in the kernel. Modinfo does have an attribute that indicates if the module is intree or not: $ modinfo -F intree out_dir/./net/netfilter/nf_log_common.ko Y But that is not queriable via sysfs. Ideally, we'd like to be able to get all this information via sysfs so that it can be captured in our bug reports. Thanks, Will