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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64281CCA479 for ; Fri, 1 Jul 2022 22:30:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231485AbiGAWa0 (ORCPT ); Fri, 1 Jul 2022 18:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbiGAWaZ (ORCPT ); Fri, 1 Jul 2022 18:30:25 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0573937A98; Fri, 1 Jul 2022 15:30:25 -0700 (PDT) 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-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=9O5j33Z914tFpbCXpa4v+qZMFFJPctSd1TN8hyoMF4E=; b=rqeiOAEU04f+V/NHT62hLFeSlL S9eQmVkYYjgB9/TlZzOb8pG8xfsrQyB3qlEkA+b4ex0CuZpV5FuNPpms4r6hpWjggSO7YfS6lhiWx NN+KLo8Wjv5wre1Bz+i1sRfTAFJBbTZ3PdgEtrt83ezthe3nHazkBcjcH/0JNuv9u7n2jmjQa+biA E7ay8EzflkblkJ3OVh3lj7EOhjl+awOZ1Td708Wqackdvj/AIOUVFI68d574UPL4wW14TcB+qF8ra wKq/bBdCtLWYrmi7JnD/aTm00KnPYSU0toIRvFz+OdSHSGXnhQO8Qw+X3qqYrAtv2mLvgE+92Tf/l Jjlf8SAg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7P9R-007E7p-U8; Fri, 01 Jul 2022 22:30:13 +0000 Date: Fri, 1 Jul 2022 15:30:13 -0700 From: Luis Chamberlain To: David Gow Cc: Brendan Higgins , Andy Shevchenko , Jonathan Corbet , Andrew Morton , Kees Cook , Shuah Khan , Greg KH , Masahiro Yamada , "Guilherme G . Piccoli" , Sebastian Reichel , John Ogness , Joe Fradley , Daniel Latypov , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Jani Nikula , Lucas De Marchi , Aaron Tomlin , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Michal Marek , Nick Desaulniers , linux-kbuild@vger.kernel.org Subject: Re: [PATCH v4 2/4] module: panic: Taint the kernel when selftest modules load Message-ID: References: <20220701084744.3002019-1-davidgow@google.com> <20220701084744.3002019-2-davidgow@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220701084744.3002019-2-davidgow@google.com> Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Jul 01, 2022 at 04:47:42PM +0800, David Gow wrote: > Taint the kernel with TAINT_TEST whenever a test module loads, by adding > a new "TEST" module property, and setting it for all modules in the > tools/testing directory. This property can also be set manually, for > tests which live outside the tools/testing directory with: > MODULE_INFO(test, "Y"); > > Signed-off-by: David Gow > --- > > This patch is new in v4 of this series. > > --- > kernel/module/main.c | 8 ++++++++ > scripts/mod/modpost.c | 3 +++ > 2 files changed, 11 insertions(+) > > diff --git a/kernel/module/main.c b/kernel/module/main.c > index fed58d30725d..f2ca0a3ee5e6 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -1988,6 +1988,14 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags) > /* Set up license info based on the info section */ > set_license(mod, get_modinfo(info, "license")); > > + if (!get_modinfo(info, "test")) { > + if (!test_taint(TAINT_TEST)) > + pr_warn("%s: loading test module taints kernel.\n", > + mod->name); That seems pretty chatty, maybe just pr_warn_once() and make indicate which is the first one? For kernel builds where their goal is to just loop testing this will grow the kernel log without not much need. Luis > + add_taint_module(mod, TAINT_TEST, LOCKDEP_STILL_OK); > + } > + > + > return 0; > } > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 29d5a841e215..5937212b4433 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -2191,6 +2191,9 @@ static void add_header(struct buffer *b, struct module *mod) > > if (strstarts(mod->name, "drivers/staging")) > buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); > + > + if (strstarts(mod->name, "tools/testing")) > + buf_printf(b, "\nMODULE_INFO(test, \"Y\");\n"); Otherwise looks good, thanks for doing this! Reviewed-by: Luis Chamberlain Luis