Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp485465imn; Fri, 1 Jul 2022 21:34:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tVFUOSkGMWxujxUone3OlYRfTSkJ9jzGQpUqgb5XlqitnWpq5UYzc66n+MdhtiHYY56B9/ X-Received: by 2002:aa7:d6c9:0:b0:435:6698:589a with SMTP id x9-20020aa7d6c9000000b004356698589amr23387461edr.59.1656736451752; Fri, 01 Jul 2022 21:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656736451; cv=none; d=google.com; s=arc-20160816; b=gJgvyUYNhO6nzS6uuSiLTrJnRAxfPHYsz0M1+oMM/LkkkjzrUtFiCudAtT/5kRk1lX oF0ktyYHv9uejK7Uf8/6JcSxTOPra03A9oY1gspqC9m4fbIN9RGH3sHY193SnIRwRI6F kbfkwOMVban/8H1H80LHmZGovDORjoE+O9WBmj/O03fgduFuzWojqb9qXj/tMnfm+u5a 6gZa8eTmeplTHUUz2fDzKPQHuqgeOlntgwl4nhFJQjQy2OOJ1qB5FvpVYwS1MjY/A+hN tjs5tjZM6hruiy/GAk7Z5meXC/neaeyHjxlS1eVZIoJxQdlVbOAdFEiqM6xwm/Qe4xj4 kSsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=2l3RLFgAAfB5gJrS1WFhkf1GPwe6iqzG1+pocvCkvn8=; b=UA9SWKi8J4SjUCr7N0dluiZSJJPC4pxF0pwROz16Q1V9f0MkcjzFs+X/jyJMEbNXtx 92Zq0fywy4Jk81QIeiV16zXyII2IrdXhEH2B9npyXCOZna7T39iTB2roJUCqgkhyFIOu eknhWzmslxZWENQqk60x8bL0l93EbvXD1ecN155S+d95oZgZKhpsiTKGk/tVVspYK9i7 PbsCQ5Q86SlnVPbnV9g16p7CV14ckUrpkWZuWD2bcCGPDKlcX5xlqVJpPx1Tlb4tpG/V D55WZAm/yHizGlBJQUW6GbJ68FKCWceHsW9RktgWEgLohLTPdshOCLw+1II/9QE96zVm Myrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=n85fmgV8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020aa7d410000000b0043559d9ed5dsi1668060edq.64.2022.07.01.21.33.42; Fri, 01 Jul 2022 21:34:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=n85fmgV8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231897AbiGBEKQ (ORCPT + 99 others); Sat, 2 Jul 2022 00:10:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231753AbiGBEKL (ORCPT ); Sat, 2 Jul 2022 00:10:11 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 335A62F001 for ; Fri, 1 Jul 2022 21:10:10 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id f9-20020a636a09000000b00401b6bc63beso2065884pgc.23 for ; Fri, 01 Jul 2022 21:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=2l3RLFgAAfB5gJrS1WFhkf1GPwe6iqzG1+pocvCkvn8=; b=n85fmgV8YL13NHOXAmDkw3hynV0Gh5QmNiSYsQm9jCdqtwslpAV93ZkYc8QzXG/8ep v9U2XDzaCoZBQ8BppCGZehEzLXTSKwGi+Zpi4ojVgQAxgVqVHZXNO0duA3b4gAoTMt80 +sHwKmRZxha0fJjw+Qztxf8qBWq1NZ/3BSsSp0HINUSML2vIsTS0UIbfMcbG+aeYsgD4 sPJ6AgB6kCdT7jUGinD6jUuhntlOLxQ0Be12GKo/Ra20XkoVtDN1yGG6N6aadBczZ4dQ WsL/dZ1TVlt+6M9D6Oeoci3tRrtxwPx+1Ii+kKcRy9o4ydGTIlLMjK0kgyXLl4CcWRNI 2q1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2l3RLFgAAfB5gJrS1WFhkf1GPwe6iqzG1+pocvCkvn8=; b=LaXfVjKa5/nY2Ma8QrV/lWssyAlb0AkA1tIeqk5bAUgfCy3zGb4SYQBp5exFj3FCre J9vYyHEMZPkjB6Mdu5hcgWdjM1uHSKr1LbJirZf9VOM8xM+zKD50BCfjxy7FgKj/HVG4 zaBA97IpK/ya1JjVpGuuo7w4cKdnlev7L9NuOWYbn3wrjH6+G/blJ0r6Br9FM9AUVrux s0v+hL5tfXvOjRmLNVkb/xqrQk3aoKk7DCDIxZ0i3peGYF6zVm2Ci/OrqGDz908enYIH gYCnToX+oX9bU8ErwznQ4n4YwkL9gT3baEtoewnkHuT6DQiZ/iduQ2h9B4AtbGWnKcM3 511w== X-Gm-Message-State: AJIora/ssDnBOOMoSySAjL5Q5Rm8mE3QLIz1foHlXpmgNYDHrgmpeuML /I5Wq0rYcLEGTwkE/hqoWFQ/mO2FX0O1HA== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a17:902:e5cd:b0:16a:6f96:eb9 with SMTP id u13-20020a170902e5cd00b0016a6f960eb9mr23833900plf.69.1656735009687; Fri, 01 Jul 2022 21:10:09 -0700 (PDT) Date: Sat, 2 Jul 2022 12:09:57 +0800 In-Reply-To: <20220702040959.3232874-1-davidgow@google.com> Message-Id: <20220702040959.3232874-2-davidgow@google.com> Mime-Version: 1.0 References: <20220702040959.3232874-1-davidgow@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v5 2/4] module: panic: Taint the kernel when selftest modules load From: David Gow To: Brendan Higgins , Andy Shevchenko , Jonathan Corbet , Andrew Morton , Kees Cook , Shuah Khan , Greg KH , Luis Chamberlain , Masahiro Yamada Cc: David Gow , "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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 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"); Reviewed-by: Luis Chamberlain Signed-off-by: David Gow --- kernel/module/main.c | 7 +++++++ scripts/mod/modpost.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/kernel/module/main.c b/kernel/module/main.c index fed58d30725d..730503561eb0 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -1988,6 +1988,13 @@ 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_once("%s: loading test module taints kernel.\n", + mod->name); + 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"); } static void add_exported_symbols(struct buffer *buf, struct module *mod) -- 2.37.0.rc0.161.g10f37bed90-goog