Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp961278iob; Fri, 13 May 2022 17:49:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHeX96UmAKAYpPwseCGV5peboDjz1piD1ftHyUt2xx1wlFw/zBE4Lr8tUt9Q0iKaHyl5VX X-Received: by 2002:a05:600c:214c:b0:394:2dfe:2754 with SMTP id v12-20020a05600c214c00b003942dfe2754mr6687499wml.135.1652489361738; Fri, 13 May 2022 17:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652489361; cv=none; d=google.com; s=arc-20160816; b=qROaEe7c9gE4nHU7D+p8+EFIJE4xq38ZFSJ+XfD2pKtLfpvUpxt5vVvysOa6aAKYyP z8gt+6U+biNvj3ZuXbgDLXCjizrIAfuS4QmHQ74qgSRFxxHfSQs/eXA0JROtew4dWXGS lqjX0CCJmBx/Qhqh39lLHkd4BmGdFonglN95vUP0O8uH+ibSPmM5SROF7WzncgdVkHaM F0dO48Oye8TZ6z7uNwP4Imden07VBLiSqC5RYT6jEQ3DdkEMcT3JtohRAEjKickp6N+8 i7LQuAwZIarXfVhFtWmIuU+63dHuf8MdwfhFUZznzg8dJl82/DWq+MchJKLQK+4HVumJ 8MXg== 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=rbJzGXtyUp4FkqReU6sYBiDMNKWwFopa4KLMlmGZbuA=; b=umdcmhW+ufGqVEiJ3zLuSmosQlS2FTNS9xjjXstKDfbkEbrfCEL6u8aqD+xBxi5aC5 OxqapaNhM45jD2VwDLwFAtF5pEZNFPKzDaYeRS+Zelm1cJTkP42+Hfd3LIZPE/ZvHj1e IGbXCgkg9GpdnJAN+kSu5MCX3PtWWSAZpWMbmbozBQN9pMM6vz6ac4wB2w9MxgOlhyGb SXyVo5erDyvRuQlDeP7LxJfg8EVeR3Y5tfuWDAK7omazr1bhbOFngEksX24s8Sk0VRzo CEBybxCOQy9bn3zh4Yug5CaUB8pKUdYUrYojMS881ijJUvFE9+IImwiGHlJPOZGBkaEN xuSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GJx1FC6P; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y5-20020adff145000000b0020c999dbe00si3313872wro.970.2022.05.13.17.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:49:21 -0700 (PDT) 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=@google.com header.s=20210112 header.b=GJx1FC6P; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4138E33D010; Fri, 13 May 2022 16:27:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344149AbiEMTJ3 (ORCPT + 99 others); Fri, 13 May 2022 15:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379900AbiEMTJ2 (ORCPT ); Fri, 13 May 2022 15:09:28 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB2053BBD8 for ; Fri, 13 May 2022 12:09:25 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id c24so6593908lfv.11 for ; Fri, 13 May 2022 12:09:25 -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=rbJzGXtyUp4FkqReU6sYBiDMNKWwFopa4KLMlmGZbuA=; b=GJx1FC6PGj6rP204JhO+MVJD1p9S4B+WG3Wu3TnyVIi0CzstjPqeEwc9SpcYJe1l2R TXfW9mAAliWx/XxYsTGa4JGZi1ldNXUsBVx/1fAKAjk52jHYQR53XvuCTMBvBpn6MgRR nvpW/IRmtZIRvLyMS+gjblxH1h5ebwHsII+gRQJhlnTz2JmCdju6VXzbxiZrzjAU0G8S qEZAkEjFjZm5uCyVG1A9FYdpEJXEIggJw4e8FDvUWWObJAj2ttke1r3VSENsFthwAaHE UD/Jt3UM0xd083pDPRmEB5Y8Wcl8Crk4Yp0PFs+XzKdG15jB7LAq0MZO7OESoHhu2wHG Klkw== 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=rbJzGXtyUp4FkqReU6sYBiDMNKWwFopa4KLMlmGZbuA=; b=xOvnr5Ld8Fot0yzhORXSuxMAbFkAMQug4Bv2j+tDlu5NFUGg7cgunbAK9zTmHHdC5h 8WyU9p0fciA6kcE6sOwaEoVnnuaA/ksrKJnNEb/iAiP1yW61OinxNESNAv3886+vpN7j JeaDrx5C/72ccMLrVqVN3AL3DgVcHsaQQdovoMcNUxy3f2nxj2nmnAZOMgXT0cJ8sNfk O/LqTe6LodMzZCGOggD4AKCGmCW/DNZQcXok76+J7lldRkmu8tntN6pmb+tucrikWWt9 /eCfwt+Aqx3+6pa9Re3dfqEiEFm2GX0PqhBAKv1n5thcL5PEtSamaxXDTTt6H6zEzRv8 49Ag== X-Gm-Message-State: AOAM5332h1ZUp4BmLYUUHESs2eWaC71b/ZFFi3QGHPEjRmRpYG6MSSSD qvF9+cY1inRMIb60CKHqBJKg22b9alon48TSTBlbdw== X-Received: by 2002:a05:6512:104a:b0:473:d38b:cdf with SMTP id c10-20020a056512104a00b00473d38b0cdfmr4633370lfb.554.1652468963837; Fri, 13 May 2022 12:09:23 -0700 (PDT) MIME-Version: 1.0 References: <20220429043913.626647-1-davidgow@google.com> <20220513083212.3537869-2-davidgow@google.com> In-Reply-To: <20220513083212.3537869-2-davidgow@google.com> From: Daniel Latypov Date: Fri, 13 May 2022 12:08:46 -0700 Message-ID: Subject: Re: [PATCH v3 2/3] kunit: Taint the kernel when KUnit tests are run To: David Gow Cc: Brendan Higgins , Andy Shevchenko , Jonathan Corbet , Andrew Morton , Kees Cook , Shuah Khan , Greg KH , Luis Chamberlain , "Guilherme G . Piccoli" , Sebastian Reichel , John Ogness , Joe Fradley , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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, May 13, 2022 at 1:32 AM David Gow wrote: > > Make KUnit trigger the new TAINT_TEST taint when any KUnit test is run. > Due to KUnit tests not being intended to run on production systems, and > potentially causing problems (or security issues like leaking kernel > addresses), the kernel's state should not be considered safe for > production use after KUnit tests are run. > > Signed-off-by: David Gow Tested-by: Daniel Latypov Looks good to me. There's an edge case where we might have 0 suites or 0 tests and we still taint the kernel, but I don't think we need to deal with that. At the start of kunit_run_tests() is the cleanest place to do this. I wasn't quite sure where this applied, but I manually applied the changes here. Without this patch, this command exits fine: $ ./tools/testing/kunit/kunit.py run --kernel_args=panic_on_taint=0x40000 With it, I get [12:03:31] Kernel panic - not syncing: panic_on_taint set ... [12:03:31] CPU: 0 PID: 1 Comm: swapper Tainted: G N 5.17.0-00001-gea9ee5e7aed8-dirty #60 I'm a bit surprised that it prints 'G' and not 'N', but this does seem to be the right mask $ python3 -c 'print(hex(1<<18))' 0x40000 and it only takes effect when this patch is applied. I'll chalk that up to my ignorance of how taint works.