Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp492440imn; Fri, 1 Jul 2022 21:48:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1siIhhZ6Zrn712iLOb3quaHli71HIc13z59Ywsb0qH/2/5Josw8zM4vfj5qn49qfpH47Uiq X-Received: by 2002:a63:8643:0:b0:40d:464c:971f with SMTP id x64-20020a638643000000b0040d464c971fmr15078769pgd.367.1656737311419; Fri, 01 Jul 2022 21:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656737311; cv=none; d=google.com; s=arc-20160816; b=cDHwrqVtRZpx2pQgizjpvlwJdUZjO7thiz7qudaBDUtFwSiRTySg5qQ79yOxe2o0m/ WC9PhiHRHxleN4+YQWWhfR91wVSU5O2VzkiwaExuVp9ZN/guv7TFHiFD4m3fR02nSUgD GAWZW6Z2Sx9jPrtzWHylXj1d9HbZzbEYr6C+Wts2qBrnNODBPZwd+aY+ppokhAUpLee5 +8gUQxsD2C+w1gLsbg8KEYd/g26IaKzF90miHoRcGMW1PvyvBfj6TWiiLuoHgEw+f9+f mt4ufrWoHWWuGb2+V1Rwx5n2GOgvYnfGBST+yBL6qe6oOIC8y7OqlZspKxMycf9E8Hrd +f6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=L0L8T16s+k4nWXnCCMJyvVuRqvoKDIsIAE/S89iGj7Q=; b=REbdaUqWKJix6C7xaG9ZVdkCV/ImUBDEtMJ3TtrpFgEShk5ERKlxgyUc2TTQHJRWKv MqqggB0NIhYAj0iIjqswHS9Q3BV1plM2ir9qF3oezmzfoV4WTf687mfGiMwRwXX1RBK1 uLVwd+aupGS/JzsGRKLxukPxANBSfjlWoUAuAQ+TR5TIr5ptPWI9qi6OvGNgYrWNoI/d 54BQrdWXO05VL28bCahVZx9kGtsmlhdIwQeG7lGjdIMoU1xoTwKX7lJRM9TgylkwuHAQ q+h6aCVEkD930L+W+DmkHk6En79AsWRZClyMzdKTecWHomRqt7wIjvyRKxKmIdacmW1V 41eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=NEeAm8r4; 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 b2-20020a170903228200b0016a2bfe5c7csi38269987plh.172.2022.07.01.21.48.18; Fri, 01 Jul 2022 21:48:30 -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=NEeAm8r4; 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 S232215AbiGBEpi (ORCPT + 99 others); Sat, 2 Jul 2022 00:45:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbiGBEpd (ORCPT ); Sat, 2 Jul 2022 00:45:33 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39ABE2A96D for ; Fri, 1 Jul 2022 21:45:32 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 205-20020a1c02d6000000b003a03567d5e9so4360259wmc.1 for ; Fri, 01 Jul 2022 21:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=L0L8T16s+k4nWXnCCMJyvVuRqvoKDIsIAE/S89iGj7Q=; b=NEeAm8r4YrMgWjDNhu4Cv71/viQC7bqibXl7R3xRHRvYstyTKCq7RDcNVMVZSMz75l dgwe/nzhCFiWh2Tgsgk9kNQp9O0GkkMouCG8Oe7nJ0nMcYMX9VDpFgI8/vWwRYdGoBJp ieRsa75Y+EfFZROhYga2OwCDYj2XrQ0a5grBv2AUhcwxVylC9W7xHqVIJr9Rslo3zVZJ 5sjh5yNKwKknjapOpiiiHSAuKSarxDiFpW0DhE3ua6nnkuG2gAiRLgr/Ee/HdjXSoYZE dlkwfJWlk+ZkJAtmZFXX2teeD3WyNKl4iIMJQpz7RyfzrXkv9aRHSKwM4tHjxoiSImDz eUUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=L0L8T16s+k4nWXnCCMJyvVuRqvoKDIsIAE/S89iGj7Q=; b=EaiMGHp6Kzgh2Ixlz4PWjqAh+vVHVe+80OScGqBS9vhVn4viiS1T+pV4ponI4HUosC eBk5PLN+XVMEpodxB0m41OZasxGOzLjyprV5Ang6ym3htqvc1bnu/OZ2MMM/VUXB0Uu8 pwgm9M2r5Kc/l2JPf6V7WE4OZJRywCnl39XkLBKJYy8aMRBqA5wAVchSPJ1AyY5EFe7m BZFJS+HxvmVCeLf9+deY6JQV7agLcET/xFnPc/2JOH0Bzp27t+CrtglSyFjTgwwb5qRp 8wNCEolXCAT3hB+va3Yz9aZaw8dPgl1EZUU4l0mc+AwM7kOX4FqEN/UIKKVUIgQaoo6R 9ukA== X-Gm-Message-State: AJIora/IIobv0ehDU/ipjwl0UizDxZoFY/T+o5/1GLyhm8fEwsX3aZeR t6BqTcuQ3LhSXkloxvnuVpw7J216EDUFaAkIkuvKYA== X-Received: by 2002:a05:600c:4e8e:b0:3a0:4f43:beb6 with SMTP id f14-20020a05600c4e8e00b003a04f43beb6mr21738567wmq.176.1656737130660; Fri, 01 Jul 2022 21:45:30 -0700 (PDT) MIME-Version: 1.0 References: <20220702040959.3232874-1-davidgow@google.com> <20220702040959.3232874-4-davidgow@google.com> In-Reply-To: <20220702040959.3232874-4-davidgow@google.com> From: David Gow Date: Sat, 2 Jul 2022 12:45:19 +0800 Message-ID: Subject: Re: [PATCH v5 4/4] selftest: Taint kernel when test module loaded To: Brendan Higgins , Andy Shevchenko , Jonathan Corbet , Andrew Morton , Kees Cook , Shuah Khan , Greg KH , Luis Chamberlain , Masahiro Yamada Cc: "Guilherme G . Piccoli" , Sebastian Reichel , John Ogness , Joe Fradley , Daniel Latypov , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Jani Nikula , Lucas De Marchi , Aaron Tomlin , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Michal Marek , Nick Desaulniers , Linux Kbuild mailing list Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000002c3a0905e2cb2ca8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 --0000000000002c3a0905e2cb2ca8 Content-Type: text/plain; charset="UTF-8" On Sat, Jul 2, 2022 at 12:10 PM David Gow wrote: > > Make any kselftest test module (using the kselftest_module framework) > taint the kernel with TAINT_TEST on module load. > > Also mark the module as a test module using MODULE_INFO(test, "Y") so > that other tools can tell this is a test module. We can't rely solely > on this, though, as these test modules are also often built-in. > > Finally, update the kselftest documentation to mention that the kernel > should be tainted, and how to do so manually (as below). > > Note that several selftests use kernel modules which are not based on > the kselftest_module framework, and so will not automatically taint the > kernel. > > This can be done in two ways: > - Moving the module to the tools/testing directory. All modules under > this directory will taint the kernel. > - Adding the 'test' module property with: > MODULE_INFO(test, "Y") > > Similarly, selftests which do not load modules into the kernel generally > should not taint the kernel (or possibly should only do so on failure), > as it's assumed that testing from user-space should be safe. Regardless, > they can write to /proc/sys/kernel/tainted if required. > > Reviewed-by: Luis Chamberlain > Signed-off-by: David Gow > --- Whoops: forgot the changelogs. Only patches 2 and 4 had changes. For this patch: Changes since v4: https://lore.kernel.org/lkml/20220513083212.3537869-3-davidgow@google.com/ - Actually use the new TAINT_TEST name, instead of TAINT_KUNIT (Thanks, kernel-test-robot) - Document how to use this (or MODULE_INFO()) to taint the kernel. (Thanks, Luis) - Also add MODULE_INFO(test, "Y") to embed the fact that this is a test module into the .ko - Nothing depends on it now, but it should allow us to tell this is a test module without executing it in the future. No changes since v3: https://lore.kernel.org/lkml/20220513083212.3537869-3-davidgow@google.com/ --0000000000002c3a0905e2cb2ca8 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIPnwYJKoZIhvcNAQcCoIIPkDCCD4wCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg ggz5MIIEtjCCA56gAwIBAgIQeAMYYHb81ngUVR0WyMTzqzANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbj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