From patchwork Mon Nov 21 15:44:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 23916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1670232wrr; Mon, 21 Nov 2022 07:53:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf44NmYTgY8WkPRGZGYE7wm8K2+2PW2xAfjX63WYVOW2dI5qtXoHY1V1eQhVnmAt+xZaGiV9 X-Received: by 2002:a17:907:50a2:b0:7ad:a34f:1efe with SMTP id fv34-20020a17090750a200b007ada34f1efemr16087840ejc.350.1669046016001; Mon, 21 Nov 2022 07:53:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669046015; cv=none; d=google.com; s=arc-20160816; b=ksDu4goamq/OlnzMPLefhpFJWQ8lmOc8+pzEfx49Ol78xrn6AXQpx5W/aOh30X33FH krqZtn7ZBW+fHUrhx36+WXrrSBTUdquzEzL46QroNrc+sGZNwXxWvqOjaYqLFDcr0qHs ADmPZY7XsSF/ZZg3pvIyhZKnZXY5qCmF8QNM4egQaskjwzrbYLTtCmbkOp1OAEy/49YT WsevOyL8PajqzYqb9evqzKIQcmJ4qQnFy0xZR7St2onqlpJIM1evMguw8t7qYJ7mYpG0 pMCjASV18LD/D+u6kpeDywulHjwbTBc0KeErlfHI0QlkA7OowB80H9EGBouclErwH+Fc g94Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date; bh=t/VbDmj2MOTi4wdMzZGg5B8szOYvx6l5tiyGnvKZCW8=; b=rcX7jN2bMtkV3v1/y33IEmkvPFCEpnYgUc2e0pnLCf3Xk/ZyRqaAqRtcnzTmd9w46e ZgeBFOh/IQegI8pkrCZGzmysSzSGWQRFAqA9UDt5iurt0976AkbCppG4ED2uOP4LlkhZ jwzXkPwemiq50P4nqMr+twtU94L8us04hsQziCxjxZWuFME30Xr4fkg6Lhy4KLDRju7n 2kX4+omeNP3cqTeT0ra7qkuOcOQOrmbr90By6KCMq/Hq8cOdXgBV6MXxg5gF2q9yKJfL mGTwEAZq2lYFAZLnprHMERZ7/gpE3Xb8qMVvTb5U2TyMmgQtom0QCfnJaor9JIshDj9c uIbA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w13-20020a170906130d00b007ae664aa7dbsi8429229ejb.877.2022.11.21.07.53.10; Mon, 21 Nov 2022 07:53:35 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbiKUPpD (ORCPT + 99 others); Mon, 21 Nov 2022 10:45:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232255AbiKUPo3 (ORCPT ); Mon, 21 Nov 2022 10:44:29 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D43DCD97D for ; Mon, 21 Nov 2022 07:44:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0490C612CB for ; Mon, 21 Nov 2022 15:44:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAACDC433D6; Mon, 21 Nov 2022 15:44:04 +0000 (UTC) Date: Mon, 21 Nov 2022 10:44:03 -0500 From: Steven Rostedt To: LKML Cc: Linus Torvalds , Masami Hiramatsu , Andrew Morton , Peter Zijlstra , Kees Cook , Josh Poimboeuf , KP Singh , Chris Mason , Mark Rutland , Alexei Starovoitov , Florent Revest , Greg Kroah-Hartman , Christoph Hellwig Subject: [PATCH] error-injection: Add prompt for function error injection Message-ID: <20221121104403.1545f9b5@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750121595065146984?= X-GMAIL-MSGID: =?utf-8?q?1750121595065146984?= From: "Steven Rostedt (Google)" The config to be able to inject error codes into any function annotated with ALLOW_ERROR_INJECTION() is enabled when CONFIG_FUNCTION_ERROR_INJECTION is enabled. But unfortunately, this is always enabled on x86 when KPROBES is enabled, and there's no way to turn it off. As kprobes is useful for observability of the kernel, it is useful to have it enabled in production environments. But error injection should be avoided. Add a prompt to the config to allow it to be disabled even when kprobes is enabled, and get rid of the "def_bool y". This is a kernel debug feature (it's in Kconfig.debug), and should have never been something enabled by default. Cc: stable@vger.kernel.org Fixes: 540adea3809f6 ("error-injection: Separate error-injection from kprobe") Signed-off-by: Steven Rostedt (Google) Acked-by: Borislav Petkov Acked-by: Masami Hiramatsu (Google) Signed-off-by: Benjamin Tissoires Signed-off-by: Alexei Starovoitov --- lib/Kconfig.debug | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index c3c0b077ade3..9ee72d8860c3 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1874,8 +1874,14 @@ config NETDEV_NOTIFIER_ERROR_INJECT If unsure, say N. config FUNCTION_ERROR_INJECTION - def_bool y + bool "Fault-injections of functions" depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES + help + Add fault injections into various functions that are annotated with + ALLOW_ERROR_INJECTION() in the kernel. BPF may also modify the return + value of theses functions. This is useful to test error paths of code. + + If unsure, say N config FAULT_INJECTION bool "Fault-injection framework"