From patchwork Tue Jan 24 18:50:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47820 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318784wrn; Tue, 24 Jan 2023 10:53:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXucmsY7eVuDK7LLvq9W1OKyiIny4OABya4ptgPoZS/aUUAfV5d3thC8LwvajdH8/MvfhQfE X-Received: by 2002:a05:6a21:1646:b0:b8:58ca:d8b4 with SMTP id no6-20020a056a21164600b000b858cad8b4mr30576024pzb.40.1674586393983; Tue, 24 Jan 2023 10:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586393; cv=none; d=google.com; s=arc-20160816; b=Cm8eSsurPVByBhwpqUB4wvYjAdcfUu/7xlhDvP096arCgK3PdBZiHUwEW11e7AXduI bTXpRvHQZ9vttLQrXB5jBVVV41ZnPBk/CfyY54U15pjbWqaTxDJAa0aHjnb0eLrGOanq aFDrSyscYtDcBgD0UzpphJT7s4eJd/2v5yMzI05njscS6RLKKuVvdfirK+9yCJVEml8l 6+m0iQVivE4YPhU+3AWfxtKW2CIyCq+NV3Vt7RLbW6U+13rM9ZTr4/HgyLCIHOmpDGqr V/rpNiu3HQOEAGotMRRxw/0B9IVm8WEVaGvBLL2tsXn2L5Mf3c+qh/QbsnBv4kqHzLVw IQxQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E6P4W8Gb0g8i2Jd7c8xxXJ0mEZLHEWZ0jeOhi+xl0sQ=; b=qjcr9gVbO6JPhpF0JfJMcBtbkMEh0KhxD4YvVu/hV4yvmch66mf+HHd65QoPqnvf2t fqsKqSgejYKtmeW2VaU3N7ikaF2z9Xn1V7USJ/S2dYYd8tcFhY+d9ryDDu9UbWItYFcf bDR2vU1QOOznu2C+Ywk8qKiQT57kBU6plac68dQ1cutQNCcX13cmY7z6zoDdPtQPNWka YfP6sRLqc09EDBebGbMGGJwbb8RP5meYn610G5EVaOR8TZujZkaXTWWLpz7NPQRdkBgT Kj0CLkFjnmnAH7WhsiRG0NlfeASUTfCLIrdoouWaig3Jo7B6aJJ4n7kwTdwo6OaErE9L oR1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fcLiFqsM; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a63b00e000000b00495c911341bsi2615958pgf.783.2023.01.24.10.53.01; Tue, 24 Jan 2023 10:53:13 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fcLiFqsM; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234154AbjAXSwG (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbjAXSwE (ORCPT ); Tue, 24 Jan 2023 13:52:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B9F42BF13; Tue, 24 Jan 2023 10:52:03 -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 BE47A61329; Tue, 24 Jan 2023 18:52:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA15DC4339C; Tue, 24 Jan 2023 18:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586322; bh=QBywAJ3d3lClnXOBIxl7CdDy5bmnPB2/lqb7sprkUXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fcLiFqsMg4MBgWIdFQP9QdnlhNYleqJfQ7ZBaCtxYcVQ4P1R5sQuajFZGgvjMx5vJ rwMBkCoK5CX2aD5UMk1z2i5Hog6AnZPVVjalMC66rF9n37rvdKOmoqZoF7vcqpm5X0 B1MBKynf55Z4Qh1OPdz9LZT5kYBjRgQT4YIRE/eHEdnYcvEOAv2GGBJ1/C8ArSG6vt bBkKOlQPNXym7uBciH+8SyiJj8dgSWClgAfIthvDh6KYuwbmuS5LGy8SO/1yGBuoOG VIfXLpKAGnZyXNxEVEjWKPYIeqv7/Xp9Z8Flc4Rhzvb8ddXuwBGZB+hSKDa0K/dO50 WIiwVjzOeqbwQ== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Iurii Zaikin , Peter Zijlstra , Paul Turner , Andy Shevchenko , Sebastian Reichel , Tetsuo Handa , Petr Mladek , Sergey Senozhatsky , Qing Wang , Benjamin LaHaise , Al Viro , Jan Kara , Amir Goldstein , Stephen Kitt , Antti Palosaari , Arnd Bergmann , Benjamin Herrenschmidt , Clemens Ladisch , David Airlie , Jani Nikula , Joel Becker , Joonas Lahtinen , Joseph Qi , Julia Lawall , Lukas Middendorf , Mark Fasheh , Phillip Potter , Rodrigo Vivi , Douglas Gilbert , "James E . J . Bottomley" , Jani Nikula , John Ogness , "Martin K . Petersen" , "Rafael J. Wysocki" , Steven Rostedt , Suren Baghdasaryan , "Theodore Ts'o" , Xiaoming Ni , Luis Chamberlain , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 01/20] sysctl: add a new register_sysctl_init() interface Date: Tue, 24 Jan 2023 10:50:51 -0800 Message-Id: <20230124185110.143857-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931102694868373?= X-GMAIL-MSGID: =?utf-8?q?1755931102694868373?= From: Xiaoming Ni commit 3ddd9a808cee7284931312f2f3e854c9617f44b2 upstream. Patch series "sysctl: first set of kernel/sysctl cleanups", v2. Finally had time to respin the series of the work we had started last year on cleaning up the kernel/sysct.c kitchen sink. People keeps stuffing their sysctls in that file and this creates a maintenance burden. So this effort is aimed at placing sysctls where they actually belong. I'm going to split patches up into series as there is quite a bit of work. This first set adds register_sysctl_init() for uses of registerting a sysctl on the init path, adds const where missing to a few places, generalizes common values so to be more easy to share, and starts the move of a few kernel/sysctl.c out where they belong. The majority of rework on v2 in this first patch set is 0-day fixes. Eric Biederman's feedback is later addressed in subsequent patch sets. I'll only post the first two patch sets for now. We can address the rest once the first two patch sets get completely reviewed / Acked. This patch (of 9): The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. Today though folks heavily rely on tables on kernel/sysctl.c so they can easily just extend this table with their needed sysctls. In order to help users move their sysctls out we need to provide a helper which can be used during code initialization. We special-case the initialization use of register_sysctl() since it *is* safe to fail, given all that sysctls do is provide a dynamic interface to query or modify at runtime an existing variable. So the use case of register_sysctl() on init should *not* stop if the sysctls don't end up getting registered. It would be counter productive to stop boot if a simple sysctl registration failed. Provide a helper for init then, and document the recommended init levels to use for callers of this routine. We will later use this in subsequent patches to start slimming down kernel/sysctl.c tables and moving sysctl registration to the code which actually needs these sysctls. [mcgrof@kernel.org: major commit log and documentation rephrasing also moved to fs/proc/proc_sysctl.c ] Link: https://lkml.kernel.org/r/20211123202347.818157-1-mcgrof@kernel.org Link: https://lkml.kernel.org/r/20211123202347.818157-2-mcgrof@kernel.org Signed-off-by: Xiaoming Ni Signed-off-by: Luis Chamberlain Reviewed-by: Kees Cook Cc: Iurii Zaikin Cc: "Eric W. Biederman" Cc: Peter Zijlstra Cc: Greg Kroah-Hartman Cc: Paul Turner Cc: Andy Shevchenko Cc: Sebastian Reichel Cc: Tetsuo Handa Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Qing Wang Cc: Benjamin LaHaise Cc: Al Viro Cc: Jan Kara Cc: Amir Goldstein Cc: Stephen Kitt Cc: Antti Palosaari Cc: Arnd Bergmann Cc: Benjamin Herrenschmidt Cc: Clemens Ladisch Cc: David Airlie Cc: Jani Nikula Cc: Joel Becker Cc: Joonas Lahtinen Cc: Joseph Qi Cc: Julia Lawall Cc: Lukas Middendorf Cc: Mark Fasheh Cc: Phillip Potter Cc: Rodrigo Vivi Cc: Douglas Gilbert Cc: James E.J. Bottomley Cc: Jani Nikula Cc: John Ogness Cc: Martin K. Petersen Cc: "Rafael J. Wysocki" Cc: Steven Rostedt (VMware) Cc: Suren Baghdasaryan Cc: "Theodore Ts'o" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Eric Biggers --- fs/proc/proc_sysctl.c | 33 +++++++++++++++++++++++++++++++++ include/linux/sysctl.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 013fc5931bc37..0b7a00ed6c49b 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "internal.h" static const struct dentry_operations proc_sys_dentry_operations; @@ -1384,6 +1385,38 @@ struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *tab } EXPORT_SYMBOL(register_sysctl); +/** + * __register_sysctl_init() - register sysctl table to path + * @path: path name for sysctl base + * @table: This is the sysctl table that needs to be registered to the path + * @table_name: The name of sysctl table, only used for log printing when + * registration fails + * + * The sysctl interface is used by userspace to query or modify at runtime + * a predefined value set on a variable. These variables however have default + * values pre-set. Code which depends on these variables will always work even + * if register_sysctl() fails. If register_sysctl() fails you'd just loose the + * ability to query or modify the sysctls dynamically at run time. Chances of + * register_sysctl() failing on init are extremely low, and so for both reasons + * this function does not return any error as it is used by initialization code. + * + * Context: Can only be called after your respective sysctl base path has been + * registered. So for instance, most base directories are registered early on + * init before init levels are processed through proc_sys_init() and + * sysctl_init(). + */ +void __init __register_sysctl_init(const char *path, struct ctl_table *table, + const char *table_name) +{ + struct ctl_table_header *hdr = register_sysctl(path, table); + + if (unlikely(!hdr)) { + pr_err("failed when register_sysctl %s to %s\n", table_name, path); + return; + } + kmemleak_not_leak(hdr); +} + static char *append_path(const char *path, char *pos, const char *name) { int namelen; diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index fa372b4c23132..47cf70c8eb93c 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -206,6 +206,9 @@ struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, void unregister_sysctl_table(struct ctl_table_header * table); extern int sysctl_init(void); +extern void __register_sysctl_init(const char *path, struct ctl_table *table, + const char *table_name); +#define register_sysctl_init(path, table) __register_sysctl_init(path, table, #table) void do_sysctl_args(void); extern int pwrsw_enabled; From patchwork Tue Jan 24 18:50:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318715wrn; Tue, 24 Jan 2023 10:53:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXv7ww5Fxd/jxrvIrzchLmwXffPhIWQasf07WIGj5k3l7T0mOdDrgLKrD3rSXxAdHE+4ByZ6 X-Received: by 2002:a05:6a20:b71b:b0:b8:965a:ccb5 with SMTP id fg27-20020a056a20b71b00b000b8965accb5mr27315342pzb.24.1674586386676; Tue, 24 Jan 2023 10:53:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586386; cv=none; d=google.com; s=arc-20160816; b=FtA5sjkrw9sjXgkhzVW1pVJNOZKuztLlC93L3F63Dc/STDXmH3XE5bOq62NHRjwDHu agfBQexeu+Dp/+MW1i1SEgykb9heLKghJj+ncoaIc7jGIbMhdb/V2QSnpUkF5x3CeMlG 37p6hUQmDproHYuF+kyi+Nqo82OtQ1vN3IHPPbybFOsd4cve+pboJd5jESTU7UP3H8kp Ofid74KkUK6aBByZRDPGVm4pqJq0rcZI/4Vcmw/4wndhfMdR0Wsl6bxDrsGHmL16kjMb UUpEIiS2rSaF9FRS+Rm3s9OyuqDly27b0QJxgo51zBqOU1h5NEkNmNHvmZOLmMEnqLyK 3trw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hcB5YSfHVeHcH4+8WMbhjS5/9eF57BibzGevLtkZMzY=; b=L4ZIlV5zwiErygOHH1DPUqPrn7dZ0aONiVzFjeW3a8N8aGOPJmDMzz10uOmd14aDw3 pP3bCEdUfNMYPj4VHnfaJcca/Bcgl/Nhw9u6ZibhWJ10VW57kKSAuMXUlg1p+yMNbKrg yyZP1+jCbkBz6OKGGQo4XVdpL5PSAiGXv3OcRZ6iuU6NCtgQL6hcpzAQj03g6SEWdu5J /vkMgraYmVNqWbCQykWP6vcuVIcyCVgFzd5zbU2DFBwV4JBqdj4WWtXjY3sMLicOpYKB vkTgHrkXL0RNI33G0THVnVAHn0OkZoOT9HHmlalsgxIQSVO1FBjP5Np70l8MXjb0z+Ee HoIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WQ98RMDD; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u75-20020a63794e000000b004775a57f324si3000213pgc.296.2023.01.24.10.52.52; Tue, 24 Jan 2023 10:53:06 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WQ98RMDD; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234035AbjAXSwL (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232064AbjAXSwF (ORCPT ); Tue, 24 Jan 2023 13:52:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2DBA402CC; Tue, 24 Jan 2023 10:52:03 -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 3D6626132D; Tue, 24 Jan 2023 18:52:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FDE5C433A7; Tue, 24 Jan 2023 18:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586322; bh=Ow9TgWwAub8fE+SNOb9xM+/rdmy9a1pdg2vENGYMYyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WQ98RMDDVvD+yJnDJrolDKhPC3l8CPVUZD/VuApgVu1LLllrFeIUee0AGaKtqCPSu yIeTCvINrtYlbRwoH1yotW05tySL6YCPbzKzD0MVw9ueb+/t/5lBf/bBXi+5EAhvvV HF4FkhyqCIpOIXgU4zcxPQbjOLluIrIa1pHBlZijFOUbQNoXGBt0ggFa0aU0snWQSq 6UxFNFPUuG60a+HXWrU/RZg4x9sfao0pxpM/JsTucSIdcGFNykQiX7imUnmkcgrqHO PYp6cuMCcONBQMheaLqpzWx3dT04M0Y9HFOZHoL+xxoicTgMET9AihPdHQIkQUCsOk LMtpdCyB4kxkA== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, tangmeng , Luis Chamberlain Subject: [PATCH 5.15 02/20] kernel/panic: move panic sysctls to its own file Date: Tue, 24 Jan 2023 10:50:52 -0800 Message-Id: <20230124185110.143857-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931095209590507?= X-GMAIL-MSGID: =?utf-8?q?1755931095209590507?= From: tangmeng commit 9df918698408fd914493aba0b7858fef50eba63a upstream. kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. All filesystem syctls now get reviewed by fs folks. This commit follows the commit of fs, move the oops_all_cpu_backtrace sysctl to its own file, kernel/panic.c. Signed-off-by: tangmeng Signed-off-by: Luis Chamberlain Signed-off-by: Eric Biggers --- include/linux/panic.h | 6 ------ kernel/panic.c | 26 +++++++++++++++++++++++++- kernel/sysctl.c | 11 ----------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/include/linux/panic.h b/include/linux/panic.h index f5844908a089e..e71161da69c4b 100644 --- a/include/linux/panic.h +++ b/include/linux/panic.h @@ -15,12 +15,6 @@ extern void oops_enter(void); extern void oops_exit(void); extern bool oops_may_print(void); -#ifdef CONFIG_SMP -extern unsigned int sysctl_oops_all_cpu_backtrace; -#else -#define sysctl_oops_all_cpu_backtrace 0 -#endif /* CONFIG_SMP */ - extern int panic_timeout; extern unsigned long panic_print; extern int panic_on_oops; diff --git a/kernel/panic.c b/kernel/panic.c index cefd7d82366fb..5ee281b996f9e 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -42,7 +42,9 @@ * Should we dump all CPUs backtraces in an oops event? * Defaults to 0, can be changed via sysctl. */ -unsigned int __read_mostly sysctl_oops_all_cpu_backtrace; +static unsigned int __read_mostly sysctl_oops_all_cpu_backtrace; +#else +#define sysctl_oops_all_cpu_backtrace 0 #endif /* CONFIG_SMP */ int panic_on_oops = CONFIG_PANIC_ON_OOPS_VALUE; @@ -71,6 +73,28 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list); EXPORT_SYMBOL(panic_notifier_list); +#if defined(CONFIG_SMP) && defined(CONFIG_SYSCTL) +static struct ctl_table kern_panic_table[] = { + { + .procname = "oops_all_cpu_backtrace", + .data = &sysctl_oops_all_cpu_backtrace, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, + { } +}; + +static __init int kernel_panic_sysctls_init(void) +{ + register_sysctl_init("kernel", kern_panic_table); + return 0; +} +late_initcall(kernel_panic_sysctls_init); +#endif + static long no_blink(int state) { return 0; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 34ce5953dbb09..928798f89ca1d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2220,17 +2220,6 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, }, #endif -#ifdef CONFIG_SMP - { - .procname = "oops_all_cpu_backtrace", - .data = &sysctl_oops_all_cpu_backtrace, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif /* CONFIG_SMP */ { .procname = "pid_max", .data = &pid_max, From patchwork Tue Jan 24 18:50:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47817 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318742wrn; Tue, 24 Jan 2023 10:53:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWI2VrYm4ForcREaSoJvPEzXapb8jynaHB/7iNJg82nj9WoHrEzW2h5zhvgIbCyGv0A32X X-Received: by 2002:a05:6a00:4c91:b0:580:ea08:5277 with SMTP id eb17-20020a056a004c9100b00580ea085277mr31000895pfb.16.1674586389592; Tue, 24 Jan 2023 10:53:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586389; cv=none; d=google.com; s=arc-20160816; b=gA00mKnTJABtX+INlA1fw1tRKgPbqAO2cBU6kVoOow2Cm8pAB4NZSUOKMHeAaBXOAe fEj3XOwKaDseRJIonQ+X2TVX+ivhDSrwLpUwVg3kkf9kvASVVMk3Ky5UVJVhL+4iS9ty 6xu8JoX8qt1Zbwf+PAFEPDjHdaSlrJ09/flrAc3zZfOmvfE+NWM7CYJwLYg8ZkT7z+2C gQdQzjs3H7Ef9vqBlAhPTGMymBZvKx5TZbDoiFhCfrTbLGf3Yz7WcmInMgLLQBlqIN7E FwTUcB4OAu6cbViVnd+VwAmrh2eHJMLjOSICE9nblyCAhyr8vi670o8LBAjKuCIc7qRF NeoA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YXxFrWp2XxPcAMlEt6CXmhB5psC1oJ6sDkufw4U+g2Y=; b=IV7k8TZll2haQgh8CfJdjiO75Lddp7x4Q2GTFkbZued+5ytkYIsLELgR11ecaKrrdY u6HEFpKv5e2n5qzQRdDJdBlYEKbHTLlWzs4jfirCfjpuw2IBq5TwRGzgjrwiVSrLI48D 2HDkTQzYE+9TWzJkOcqpO++G/myBvabKXQcHLmuozRm5x/7d9eHh1QY6An6yg6b+7iKq QOoSYsPiPj6Aumyn5MQwsZirNIuVljbiwBcDZISHa5GyheSh+mxr5nD9vVxLc0tRLEcQ 4eK/HrUMaYaxzYunkS0sHbPDEqurIJVqdtNpyHpMIYOEvekEecryW+X5xg8AI9sOJnQh a1pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FUF0b4HL; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y195-20020a6264cc000000b0057462551be5si2961202pfb.237.2023.01.24.10.52.55; Tue, 24 Jan 2023 10:53:09 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FUF0b4HL; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234226AbjAXSwT (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234158AbjAXSwG (ORCPT ); Tue, 24 Jan 2023 13:52:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9B18305FD; Tue, 24 Jan 2023 10:52:05 -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 ams.source.kernel.org (Postfix) with ESMTPS id 9DBC6B816A4; Tue, 24 Jan 2023 18:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA4DEC433D2; Tue, 24 Jan 2023 18:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586323; bh=ddhv5ZxDDV8fG0tIULVcl+ZErzPf+c/2H6zK1ntF56M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUF0b4HLD8/J08B1DhAe6wF+jGyV1GTa4S3Np4VZl3fBWcGhcOaiaLXAj2GJK8djO sulhGapTFWWRF1j3Rl2i/8YEmibrsz6UspWyWPSDTkue+fV3YEZjhu9JFzpaGPKY52 WcJjeNTF6uvfn4gpBSsEN1+dXBiTc2OKuaaNvm2eV+FFFzMZob5tliVYSxlPVPxoRw UNQhji7iSHB2ofY/COuzE9BcPLnaiNzk0ipjMBhS9/qWDepCz+PfPv/BgWKhnXy0ao atre0vCb/6vCEt4dx20Ote8BCWc24EQg2VAWRiQthwCk6dc1QJjKo+kSAer/3bY526 rovSOp/TCmZ3Q== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Ryabinin , Baoquan He , Jonathan Corbet , Xuefeng Li , Tiezhu Yang , Marco Elver , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 03/20] panic: unset panic_on_warn inside panic() Date: Tue, 24 Jan 2023 10:50:53 -0800 Message-Id: <20230124185110.143857-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931098375788408?= X-GMAIL-MSGID: =?utf-8?q?1755931098375788408?= From: Tiezhu Yang commit 1a2383e8b84c0451fd9b1eec3b9aab16f30b597c upstream. In the current code, the following three places need to unset panic_on_warn before calling panic() to avoid recursive panics: kernel/kcsan/report.c: print_report() kernel/sched/core.c: __schedule_bug() mm/kfence/report.c: kfence_report_error() In order to avoid copy-pasting "panic_on_warn = 0" all over the places, it is better to move it inside panic() and then remove it from the other places. Link: https://lkml.kernel.org/r/1644324666-15947-4-git-send-email-yangtiezhu@loongson.cn Signed-off-by: Tiezhu Yang Reviewed-by: Marco Elver Cc: Andrey Ryabinin Cc: Baoquan He Cc: Jonathan Corbet Cc: Xuefeng Li Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Eric Biggers --- kernel/panic.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/panic.c b/kernel/panic.c index 5ee281b996f9e..5ed1ad06f9a34 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -208,6 +208,16 @@ void panic(const char *fmt, ...) int old_cpu, this_cpu; bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers; + if (panic_on_warn) { + /* + * This thread may hit another WARN() in the panic path. + * Resetting this prevents additional WARN() from panicking the + * system on this thread. Other threads are blocked by the + * panic_mutex in panic(). + */ + panic_on_warn = 0; + } + /* * Disable local interrupts. This will prevent panic_smp_self_stop * from deadlocking the first cpu that invokes the panic, since @@ -616,16 +626,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, if (regs) show_regs(regs); - if (panic_on_warn) { - /* - * This thread may hit another WARN() in the panic path. - * Resetting this prevents additional WARN() from panicking the - * system on this thread. Other threads are blocked by the - * panic_mutex in panic(). - */ - panic_on_warn = 0; + if (panic_on_warn) panic("panic_on_warn set ...\n"); - } if (!regs) dump_stack(); From patchwork Tue Jan 24 18:50:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318717wrn; Tue, 24 Jan 2023 10:53:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXseGfnY8UOScn6HaLdWtWYe8ekXeWI3p8PLe21jV2VG/JFAp8rZ+jrzCTKnAUHgB+g76R82 X-Received: by 2002:a17:90b:902:b0:226:164d:a19a with SMTP id bo2-20020a17090b090200b00226164da19amr52933243pjb.49.1674586386923; Tue, 24 Jan 2023 10:53:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586386; cv=none; d=google.com; s=arc-20160816; b=WaMj2KY+jCrbroWlfNLkflnP995Afc/nYH1XRDLyakRUNkumegg7iV/hiMHntdQ1Ha sV8jBgInmBSxKMqxtzSmtcBKBufeZJcxnLnb3bfWTtXRtuPa9KL4YoCLQM+Xi6VpTCTZ r70PLwF0HbfEGS5Jlml2l4ojIalHTGZo3LWMRdUrrwGO/g4vxIL1/phvQ3V3wwvrJ3cU PAV/ssf4SX6xxX7ZjnRfzboGGpKN7IF+ELr7f5OBrSFe4ONFmh5gdfrLl8Lh+nyoy1co KNEkT2xIWaj96ZXNyDbD4m0AGo54aGDPKMYTXs/ULK5ZV5K3GQ9crrEM8oqscrDa+Dn2 Zp+A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qJq5bZ8moayhp2wrMNhSV8PMfa0d6Ag/xLxZN4HHdic=; b=f+i2f5F7DNCzUmpChH3/SVLH/nBueVxyHoSwW9dqVpMqHlEMnk1Ti8h54p/p1hpJ3F Z7gz6Pn0g/d0DbZ3DTwvNT8iv3OYxeTcpSJqTffJy0cYSHe30IB7XP/Heb56AhBm/shm 8zJN+RWRpHSpTKqzVfk9Q54IX80IXdZGEYdTxYH3UESIBcXSMrLLFmqO6LdVySamRuqG QI0MoVv5v5acIYMsn069pg0BTHBroLxMztyiJp64gRJG2MrOPsU1lpvtBUtfPOglD11p zzeaK/7yQAPNw1eA+21uSboNA5fiwumvu8xKQqbdmrHtO6w46prJzpRKk9+Tm6I+9mC1 rEQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vjt1XUXW; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a63340c000000b004991efb7281si3032869pga.423.2023.01.24.10.52.52; Tue, 24 Jan 2023 10:53:06 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vjt1XUXW; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233737AbjAXSwN (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233815AbjAXSwF (ORCPT ); Tue, 24 Jan 2023 13:52:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1B6742DFD; Tue, 24 Jan 2023 10:52:04 -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 8FE5861333; Tue, 24 Jan 2023 18:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79868C433A1; Tue, 24 Jan 2023 18:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586324; bh=yaiQwBn2rTDrZhwgXDYQi0ScGBCi5abPA1RpzOQ4srI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vjt1XUXWDXluHlh8RrTj9/dFkQbxY9dm0cIDoLMWmF7SENFQrleiigF2tOKM09Jw/ VZEeFsculLU9id7WocJkcfOuljqO7AsgHEYzm+GZFVsiTMplsKetB4g7pZrALuCG+P /SW6+QFS7vYl5gkb6bHUhVaMAzKaOKn/VnRZ7+IMYarn7xzAAnkohUlYXr/m5pu82a RcsTb53KAFetr51txcHdD+Zpvw9tAafssN3OiAmOShqZwQaIMPTGFjQfiIItGnec3F d2XMovkFJdqvIO0qUGV1C+LYCTIshLpy/X66caLpB1YoYi7GcWgitFsaoptL4bQHeE /2HhArVFOOEOw== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Ryabinin , Baoquan He , Jonathan Corbet , Xuefeng Li , Tiezhu Yang , Marco Elver , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 04/20] ubsan: no need to unset panic_on_warn in ubsan_epilogue() Date: Tue, 24 Jan 2023 10:50:54 -0800 Message-Id: <20230124185110.143857-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931094831874791?= X-GMAIL-MSGID: =?utf-8?q?1755931094831874791?= From: Tiezhu Yang commit d83ce027a54068fabb70d2c252e1ce2da86784a4 upstream. panic_on_warn is unset inside panic(), so no need to unset it before calling panic() in ubsan_epilogue(). Link: https://lkml.kernel.org/r/1644324666-15947-5-git-send-email-yangtiezhu@loongson.cn Signed-off-by: Tiezhu Yang Reviewed-by: Marco Elver Cc: Andrey Ryabinin Cc: Baoquan He Cc: Jonathan Corbet Cc: Xuefeng Li Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Eric Biggers --- lib/ubsan.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/ubsan.c b/lib/ubsan.c index bdc380ff5d5c7..36bd75e334263 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -154,16 +154,8 @@ static void ubsan_epilogue(void) current->in_ubsan--; - if (panic_on_warn) { - /* - * This thread may hit another WARN() in the panic path. - * Resetting this prevents additional WARN() from panicking the - * system on this thread. Other threads are blocked by the - * panic_mutex in panic(). - */ - panic_on_warn = 0; + if (panic_on_warn) panic("panic_on_warn set ...\n"); - } } void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs) From patchwork Tue Jan 24 18:50:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319090wrn; Tue, 24 Jan 2023 10:54:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXtHCf07Md4yBAX8rT4z8ys8edGe18cOvEH0w/8Yz4ueu6RtWrQQvhFqJcLTiQvsHfv19Yt2 X-Received: by 2002:a05:6a00:1d11:b0:58e:2649:5bdb with SMTP id a17-20020a056a001d1100b0058e26495bdbmr11984985pfx.20.1674586439892; Tue, 24 Jan 2023 10:53:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586439; cv=none; d=google.com; s=arc-20160816; b=NvIb2FRMVUuP4UW7khe68wc5mYnkWz/OrmwLBRYIF+ErwBUOxbmBXeF62ltZESug/B fv2p2uZhWJRxYIWJc3tzvxyiKc/dLV9xvK4R8EmElJqU08XpY5NpwwUMuQgVwzRNuQTg yxxFJX5xekwl7pwr2jNkLEFAMRp6tUk33nJd8G2buErJqpw34Ag2bGP+LqgvHrZzGFGU GuO2+VWx2HUsV62SCKobBSkKbLYS4HfxwqnMYRncvc6tmDxFF3EIQ+S6cX4srJTE/E/i qQ5G3wg8CVeUBIGjvyP99XYKlCyCm/iTBYRsZy0uq3SC/sjHpLlXyLkhAOkyro+ZSg4x o9zA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hLIvfi4r5u7OzosAZV+OYDBNGofasQ8/Lp1KvTu9jhA=; b=RyWup0RiI0qEo4J5mumeBoaL9rAFvagnLhmGe6z813taiXvSENvbMT1AldwDIbj/uA /C8f1qUIB3AKMalsuzB2dMkXYIl97y2tPxK4QBb4ip+Bl0lj7BY9g0fsFoFv5G4PUDpi QPeUOdbfI0ogKl+AaT7ttxA+zgLY+vIqQ1npTabPznKG0GiJOQMXYp85Atf0zhj+ROzb bcIkpUorCpE3oOcHWt9VR8l3tG6Hx8vtco49/tfD7yGviqTPmlUKk9hW1soacx5+XTPs 7/w25S9beGZwRQEkTRG8I2cbIsj+j7LtR2YRFKk+Lwiua6tpYBk+4O6Dp7Q96tgz0lmS OnAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hPRqhYfA; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cg19-20020a056a00291300b00589170e18cesi3052625pfb.170.2023.01.24.10.53.47; Tue, 24 Jan 2023 10:53:59 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hPRqhYfA; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234071AbjAXSwP (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233944AbjAXSwF (ORCPT ); Tue, 24 Jan 2023 13:52:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 417202BF13; Tue, 24 Jan 2023 10:52:05 -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 D458D61330; Tue, 24 Jan 2023 18:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 291BBC4339B; Tue, 24 Jan 2023 18:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586324; bh=FJr8BjrY0TIgcS5b++r8ZCSIVGNroe0iaKdta2nV8tU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPRqhYfAAwS2D4UwqLKr7br8D3sFNtDuz1WqxABvTidT6NHiPbhd4DU3Vas76Bb2F JoSSlVn+wKXv3/d1K3a+ytz8zSk465FdOgwUzsLr23Fds2HlmnO/XpmNjwUQA6tQTZ Upg2rUoDo1hoRUxQdmPyCnjoqPxG9Qanncdf5eq56x2wQ+BJDRj1Ug0IqBz+eNkkSH qyLlzrqGVfDycGG4gnqgz2+cxim2YA6l1pmlEBmK/fwUMBgB2uyCohLiyr023D43AH 3jbZCumbSXOh+ztmEe8EDZlshcYrkHM5GrqrOgJoDQgB6YvY7jERq56tut5PEXrxQ1 Beu78xbyek35g== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Ryabinin , Baoquan He , Jonathan Corbet , Xuefeng Li , Tiezhu Yang , Marco Elver , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 05/20] kasan: no need to unset panic_on_warn in end_report() Date: Tue, 24 Jan 2023 10:50:55 -0800 Message-Id: <20230124185110.143857-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931150659762892?= X-GMAIL-MSGID: =?utf-8?q?1755931150659762892?= From: Tiezhu Yang commit e7ce7500375a63348e1d3a703c8d5003cbe3fea6 upstream. panic_on_warn is unset inside panic(), so no need to unset it before calling panic() in end_report(). Link: https://lkml.kernel.org/r/1644324666-15947-6-git-send-email-yangtiezhu@loongson.cn Signed-off-by: Tiezhu Yang Reviewed-by: Marco Elver Cc: Andrey Ryabinin Cc: Baoquan He Cc: Jonathan Corbet Cc: Xuefeng Li Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Eric Biggers --- mm/kasan/report.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 884a950c70265..bf17704b302fc 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -117,16 +117,8 @@ static void end_report(unsigned long *flags, unsigned long addr) pr_err("==================================================================\n"); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); - if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) { - /* - * This thread may hit another WARN() in the panic path. - * Resetting this prevents additional WARN() from panicking the - * system on this thread. Other threads are blocked by the - * panic_mutex in panic(). - */ - panic_on_warn = 0; + if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) panic("panic_on_warn set ...\n"); - } if (kasan_arg_fault == KASAN_ARG_FAULT_PANIC) panic("kasan.fault=panic set ...\n"); kasan_enable_current(); From patchwork Tue Jan 24 18:50:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318936wrn; Tue, 24 Jan 2023 10:53:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXs0DztqlBNmSiEi7CaEaUIggPmijl1X7aVAccodBcmTy/orL0gAU5yDR9wRGgqh5unNKlc8 X-Received: by 2002:a17:90b:3c0e:b0:227:1c1e:7529 with SMTP id pb14-20020a17090b3c0e00b002271c1e7529mr30687176pjb.15.1674586414942; Tue, 24 Jan 2023 10:53:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586414; cv=none; d=google.com; s=arc-20160816; b=KqITQFx6vhWe8iRpY+XEVP03CzxqY5YKxlP+YE8OikF74wkpjKWlaLhzHMiDqy/Wg6 UXe5VtYhQlc4RUI7V15oa5tZjysvz9Isevy1NbOWPUCQGkJkf/MT9DHb5wM3HNx9cYbE GPoyDVmyVCbfi5AWwEG2GMS7ZUpWE9/u/EYRhZFZPZe6jfQhRNGqY0WwRn9sqtjAEqvY NwB28k+7p+iPu4be6/s0ZchmXJJU2ksCo8weGmAg45TVR7cAZ7TzYpfrGReSjpd1yH7b PY6Hd6VEEGB0NzzBYgI1Ii3QfK02ultHZN+MOm73N97gDDk/jpcUi2v9K7yTSi2vk7VO sDjQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zeMIHt8ym/HiTMwVX9eu0tbeAfKXj8S9TFu0yQLZRMk=; b=hcv9V8iulxVbuUlfQYqC9OA6J49YuO782YAblMzBnYPLoyjjJgwhfeNvaTJUTS4R8G wneNIeXv692LyhnAGb8evT3Xf96xAUIkpoEGnsbBkyhQST9JQrCMPfV5yWnQ621IRzqU U5chWqAeufrKwfIbcVhDvKdPjM0xI5UBPdLcXty1+o4RlMBMglJArybac8BDmms4bG5X o4/GFD8ystS4fMRm27mrzYsN3fTWpmsywWgfO5m/pZ52iydNESuXfe7IhxsWY1/yTvJk LSQw72saB9BzlvKGWMMpBQcjIN63XOaItr69Mwu/Aoz7NWI3NF6aSwprSk32bjQ4E1Z7 AqEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fan03XEw; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a17090aca9100b0022953d318ddsi3054228pjt.99.2023.01.24.10.53.22; Tue, 24 Jan 2023 10:53:34 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fan03XEw; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234429AbjAXSwu (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232320AbjAXSwa (ORCPT ); Tue, 24 Jan 2023 13:52:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB45C4617C; Tue, 24 Jan 2023 10:52: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 ams.source.kernel.org (Postfix) with ESMTPS id 7295CB81628; Tue, 24 Jan 2023 18:52:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE5A3C4339E; Tue, 24 Jan 2023 18:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586325; bh=Es45q5zg5Ss217MhrmhMbvahDYwizi5msW7nzfLAZ0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fan03XEwcyrjf1W/mj7ju3ootgme3zhyCtDoeZcKPC+SPkHwpThNXrrs9bkJmCTvt NKzyHLuRorU2N0QrhP4/v+R3hxGt9sqgXMXOo3hn/DcyhD1crux74kBTDS6Nelbz95 ax8J9y4FkCGJ9L7oEjgOqRqjeQ7M8vv1ousUNbThEL7XnzlWWUIyxioM9HNowZFXwO kKwZJIhw/WlNOUGbH850BPAp90yTT+l8Z0j7/DrkQaRlt+EL+MuVCllK8unbUXmFe6 f5z1TsNym9dorevgg37b6qzdZuE5c9J+oSDIS3zTff1yuYxJD+ek0W6whsPwo/eyVR 4815bR9URYK3A== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5.15 06/20] exit: Add and use make_task_dead. Date: Tue, 24 Jan 2023 10:50:56 -0800 Message-Id: <20230124185110.143857-7-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931124576551122?= X-GMAIL-MSGID: =?utf-8?q?1755931124576551122?= From: "Eric W. Biederman" commit 0e25498f8cd43c1b5aa327f373dd094e9a006da7 upstream. There are two big uses of do_exit. The first is it's design use to be the guts of the exit(2) system call. The second use is to terminate a task after something catastrophic has happened like a NULL pointer in kernel code. Add a function make_task_dead that is initialy exactly the same as do_exit to cover the cases where do_exit is called to handle catastrophic failure. In time this can probably be reduced to just a light wrapper around do_task_dead. For now keep it exactly the same so that there will be no behavioral differences introducing this new concept. Replace all of the uses of do_exit that use it for catastraphic task cleanup with make_task_dead to make it clear what the code is doing. As part of this rename rewind_stack_do_exit rewind_stack_and_make_dead. Signed-off-by: "Eric W. Biederman" Signed-off-by: Eric Biggers --- arch/alpha/kernel/traps.c | 6 +++--- arch/alpha/mm/fault.c | 2 +- arch/arm/kernel/traps.c | 2 +- arch/arm/mm/fault.c | 2 +- arch/arm64/kernel/traps.c | 2 +- arch/arm64/mm/fault.c | 2 +- arch/csky/abiv1/alignment.c | 2 +- arch/csky/kernel/traps.c | 2 +- arch/csky/mm/fault.c | 2 +- arch/h8300/kernel/traps.c | 2 +- arch/h8300/mm/fault.c | 2 +- arch/hexagon/kernel/traps.c | 2 +- arch/ia64/kernel/mca_drv.c | 2 +- arch/ia64/kernel/traps.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/m68k/kernel/traps.c | 2 +- arch/m68k/mm/fault.c | 2 +- arch/microblaze/kernel/exceptions.c | 4 ++-- arch/mips/kernel/traps.c | 2 +- arch/nds32/kernel/fpu.c | 2 +- arch/nds32/kernel/traps.c | 8 ++++---- arch/nios2/kernel/traps.c | 4 ++-- arch/openrisc/kernel/traps.c | 2 +- arch/parisc/kernel/traps.c | 2 +- arch/powerpc/kernel/traps.c | 8 ++++---- arch/riscv/kernel/traps.c | 2 +- arch/riscv/mm/fault.c | 2 +- arch/s390/kernel/dumpstack.c | 2 +- arch/s390/kernel/nmi.c | 2 +- arch/sh/kernel/traps.c | 2 +- arch/sparc/kernel/traps_32.c | 4 +--- arch/sparc/kernel/traps_64.c | 4 +--- arch/x86/entry/entry_32.S | 6 +++--- arch/x86/entry/entry_64.S | 6 +++--- arch/x86/kernel/dumpstack.c | 4 ++-- arch/xtensa/kernel/traps.c | 2 +- include/linux/sched/task.h | 1 + kernel/exit.c | 9 +++++++++ tools/objtool/check.c | 3 ++- 39 files changed, 63 insertions(+), 56 deletions(-) diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index e805106409f76..f5ba12adde67c 100644 --- a/arch/alpha/kernel/traps.c +++ b/arch/alpha/kernel/traps.c @@ -192,7 +192,7 @@ die_if_kernel(char * str, struct pt_regs *regs, long err, unsigned long *r9_15) local_irq_enable(); while (1); } - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } #ifndef CONFIG_MATHEMU @@ -577,7 +577,7 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg, printk("Bad unaligned kernel access at %016lx: %p %lx %lu\n", pc, va, opcode, reg); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); got_exception: /* Ok, we caught the exception, but we don't want it. Is there @@ -632,7 +632,7 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg, local_irq_enable(); while (1); } - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } /* diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c index eee5102c3d889..e9193d52222ea 100644 --- a/arch/alpha/mm/fault.c +++ b/arch/alpha/mm/fault.c @@ -204,7 +204,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr, printk(KERN_ALERT "Unable to handle kernel paging request at " "virtual address %016lx\n", address); die_if_kernel("Oops", regs, cause, (unsigned long*)regs - 16); - do_exit(SIGKILL); + make_task_dead(SIGKILL); /* We ran out of memory, or some other thing happened to us that made us unable to handle the page fault gracefully. */ diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 54abd8720ddef..91e757bb054e6 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -334,7 +334,7 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr) if (panic_on_oops) panic("Fatal exception"); if (signr) - do_exit(signr); + make_task_dead(signr); } /* diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index efa4020250315..af5177801fb10 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -125,7 +125,7 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr, show_pte(KERN_ALERT, mm, addr); die("Oops", regs, fsr); bust_spinlocks(0); - do_exit(SIGKILL); + make_task_dead(SIGKILL); } /* diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index f859cc870d5b3..21e69a991bc83 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -235,7 +235,7 @@ void die(const char *str, struct pt_regs *regs, int err) raw_spin_unlock_irqrestore(&die_lock, flags); if (ret != NOTIFY_STOP) - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } static void arm64_show_signal(int signo, const char *str) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index d09b21faa0b23..97a93ee756a2e 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -302,7 +302,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr, show_pte(addr); die("Oops", regs, esr); bust_spinlocks(0); - do_exit(SIGKILL); + make_task_dead(SIGKILL); } #ifdef CONFIG_KASAN_HW_TAGS diff --git a/arch/csky/abiv1/alignment.c b/arch/csky/abiv1/alignment.c index cb2a0d94a144d..5e2fb45d605cf 100644 --- a/arch/csky/abiv1/alignment.c +++ b/arch/csky/abiv1/alignment.c @@ -294,7 +294,7 @@ void csky_alignment(struct pt_regs *regs) __func__, opcode, rz, rx, imm, addr); show_regs(regs); bust_spinlocks(0); - do_exit(SIGKILL); + make_dead_task(SIGKILL); } force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr); diff --git a/arch/csky/kernel/traps.c b/arch/csky/kernel/traps.c index 2020af88b6361..b445c5aee220b 100644 --- a/arch/csky/kernel/traps.c +++ b/arch/csky/kernel/traps.c @@ -109,7 +109,7 @@ void die(struct pt_regs *regs, const char *str) if (panic_on_oops) panic("Fatal exception"); if (ret != NOTIFY_STOP) - do_exit(SIGSEGV); + make_dead_task(SIGSEGV); } void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr) diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c index 466ad949818a6..7215a46b6b8eb 100644 --- a/arch/csky/mm/fault.c +++ b/arch/csky/mm/fault.c @@ -67,7 +67,7 @@ static inline void no_context(struct pt_regs *regs, unsigned long addr) pr_alert("Unable to handle kernel paging request at virtual " "addr 0x%08lx, pc: 0x%08lx\n", addr, regs->pc); die(regs, "Oops"); - do_exit(SIGKILL); + make_task_dead(SIGKILL); } static inline void mm_fault_error(struct pt_regs *regs, unsigned long addr, vm_fault_t fault) diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c index bdbe988d8dbcf..3d4e0bde37ae7 100644 --- a/arch/h8300/kernel/traps.c +++ b/arch/h8300/kernel/traps.c @@ -106,7 +106,7 @@ void die(const char *str, struct pt_regs *fp, unsigned long err) dump(fp); spin_unlock_irq(&die_lock); - do_exit(SIGSEGV); + make_dead_task(SIGSEGV); } static int kstack_depth_to_print = 24; diff --git a/arch/h8300/mm/fault.c b/arch/h8300/mm/fault.c index d4bc9c16f2df9..0223528565dd3 100644 --- a/arch/h8300/mm/fault.c +++ b/arch/h8300/mm/fault.c @@ -51,7 +51,7 @@ asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address, printk(" at virtual address %08lx\n", address); if (!user_mode(regs)) die("Oops", regs, error_code); - do_exit(SIGKILL); + make_dead_task(SIGKILL); return 1; } diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c index edfc35dafeb19..6dd6cf0ab711f 100644 --- a/arch/hexagon/kernel/traps.c +++ b/arch/hexagon/kernel/traps.c @@ -214,7 +214,7 @@ int die(const char *str, struct pt_regs *regs, long err) panic("Fatal exception"); oops_exit(); - do_exit(err); + make_dead_task(err); return 0; } diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c index 5bfc79be4cefe..23c203639a968 100644 --- a/arch/ia64/kernel/mca_drv.c +++ b/arch/ia64/kernel/mca_drv.c @@ -176,7 +176,7 @@ mca_handler_bh(unsigned long paddr, void *iip, unsigned long ipsr) spin_unlock(&mca_bh_lock); /* This process is about to be killed itself */ - do_exit(SIGKILL); + make_task_dead(SIGKILL); } /** diff --git a/arch/ia64/kernel/traps.c b/arch/ia64/kernel/traps.c index e13cb905930fb..753642366e12e 100644 --- a/arch/ia64/kernel/traps.c +++ b/arch/ia64/kernel/traps.c @@ -85,7 +85,7 @@ die (const char *str, struct pt_regs *regs, long err) if (panic_on_oops) panic("Fatal exception"); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); return 0; } diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c index 02de2e70c5874..4796cccbf74f3 100644 --- a/arch/ia64/mm/fault.c +++ b/arch/ia64/mm/fault.c @@ -259,7 +259,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re regs = NULL; bust_spinlocks(0); if (regs) - do_exit(SIGKILL); + make_task_dead(SIGKILL); return; out_of_memory: diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c index 34d6458340b0f..59fc63feb0dcc 100644 --- a/arch/m68k/kernel/traps.c +++ b/arch/m68k/kernel/traps.c @@ -1131,7 +1131,7 @@ void die_if_kernel (char *str, struct pt_regs *fp, int nr) pr_crit("%s: %08x\n", str, nr); show_registers(fp); add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } asmlinkage void set_esp0(unsigned long ssp) diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c index ef46e77e97a5b..fcb3a0d8421c5 100644 --- a/arch/m68k/mm/fault.c +++ b/arch/m68k/mm/fault.c @@ -48,7 +48,7 @@ int send_fault_sig(struct pt_regs *regs) pr_alert("Unable to handle kernel access"); pr_cont(" at virtual address %p\n", addr); die_if_kernel("Oops", regs, 0 /*error_code*/); - do_exit(SIGKILL); + make_task_dead(SIGKILL); } return 1; diff --git a/arch/microblaze/kernel/exceptions.c b/arch/microblaze/kernel/exceptions.c index 908788497b287..fd153d5fab982 100644 --- a/arch/microblaze/kernel/exceptions.c +++ b/arch/microblaze/kernel/exceptions.c @@ -44,10 +44,10 @@ void die(const char *str, struct pt_regs *fp, long err) pr_warn("Oops: %s, sig: %ld\n", str, err); show_regs(fp); spin_unlock_irq(&die_lock); - /* do_exit() should take care of panic'ing from an interrupt + /* make_task_dead() should take care of panic'ing from an interrupt * context so we don't handle it here */ - do_exit(err); + make_task_dead(err); } /* for user application debugging */ diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index edd93430b954a..afb2c955d99ef 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -416,7 +416,7 @@ void __noreturn die(const char *str, struct pt_regs *regs) if (regs && kexec_should_crash(current)) crash_kexec(regs); - do_exit(sig); + make_task_dead(sig); } extern struct exception_table_entry __start___dbe_table[]; diff --git a/arch/nds32/kernel/fpu.c b/arch/nds32/kernel/fpu.c index 9edd7ed7d7bf8..701c09a668de4 100644 --- a/arch/nds32/kernel/fpu.c +++ b/arch/nds32/kernel/fpu.c @@ -223,7 +223,7 @@ inline void handle_fpu_exception(struct pt_regs *regs) } } else if (fpcsr & FPCSR_mskRIT) { if (!user_mode(regs)) - do_exit(SIGILL); + make_task_dead(SIGILL); si_signo = SIGILL; } diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c index f06421c645aff..b90030e8e546f 100644 --- a/arch/nds32/kernel/traps.c +++ b/arch/nds32/kernel/traps.c @@ -141,7 +141,7 @@ void die(const char *str, struct pt_regs *regs, int err) bust_spinlocks(0); spin_unlock_irq(&die_lock); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } EXPORT_SYMBOL(die); @@ -240,7 +240,7 @@ void unhandled_interruption(struct pt_regs *regs) pr_emerg("unhandled_interruption\n"); show_regs(regs); if (!user_mode(regs)) - do_exit(SIGKILL); + make_task_dead(SIGKILL); force_sig(SIGKILL); } @@ -251,7 +251,7 @@ void unhandled_exceptions(unsigned long entry, unsigned long addr, addr, type); show_regs(regs); if (!user_mode(regs)) - do_exit(SIGKILL); + make_task_dead(SIGKILL); force_sig(SIGKILL); } @@ -278,7 +278,7 @@ void do_revinsn(struct pt_regs *regs) pr_emerg("Reserved Instruction\n"); show_regs(regs); if (!user_mode(regs)) - do_exit(SIGILL); + make_task_dead(SIGILL); force_sig(SIGILL); } diff --git a/arch/nios2/kernel/traps.c b/arch/nios2/kernel/traps.c index 596986a74a26d..85ac49d64cf73 100644 --- a/arch/nios2/kernel/traps.c +++ b/arch/nios2/kernel/traps.c @@ -37,10 +37,10 @@ void die(const char *str, struct pt_regs *regs, long err) show_regs(regs); spin_unlock_irq(&die_lock); /* - * do_exit() should take care of panic'ing from an interrupt + * make_task_dead() should take care of panic'ing from an interrupt * context so we don't handle it here */ - do_exit(err); + make_task_dead(err); } void _exception(int signo, struct pt_regs *regs, int code, unsigned long addr) diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c index aa1e709405acd..9df1d85bfe1d1 100644 --- a/arch/openrisc/kernel/traps.c +++ b/arch/openrisc/kernel/traps.c @@ -212,7 +212,7 @@ void die(const char *str, struct pt_regs *regs, long err) __asm__ __volatile__("l.nop 1"); do {} while (1); #endif - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } /* This is normally the 'Oops' routine */ diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c index 6fe5a3e98edc2..70ace36879507 100644 --- a/arch/parisc/kernel/traps.c +++ b/arch/parisc/kernel/traps.c @@ -268,7 +268,7 @@ void die_if_kernel(char *str, struct pt_regs *regs, long err) panic("Fatal exception"); oops_exit(); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } /* gdb uses break 4,8 */ diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 11741703d26e0..a08bb7cefdc54 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -245,7 +245,7 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, if (panic_on_oops) panic("Fatal exception"); - do_exit(signr); + make_task_dead(signr); } NOKPROBE_SYMBOL(oops_end); @@ -792,9 +792,9 @@ int machine_check_generic(struct pt_regs *regs) void die_mce(const char *str, struct pt_regs *regs, long err) { /* - * The machine check wants to kill the interrupted context, but - * do_exit() checks for in_interrupt() and panics in that case, so - * exit the irq/nmi before calling die. + * The machine check wants to kill the interrupted context, + * but make_task_dead() checks for in_interrupt() and panics + * in that case, so exit the irq/nmi before calling die. */ if (in_nmi()) nmi_exit(); diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 4102c97309cc2..6084bd93d2f58 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -59,7 +59,7 @@ void die(struct pt_regs *regs, const char *str) if (panic_on_oops) panic("Fatal exception"); if (ret != NOTIFY_STOP) - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr) diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index 7cfaf366463fb..676a3f28811fa 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -31,7 +31,7 @@ static void die_kernel_fault(const char *msg, unsigned long addr, bust_spinlocks(0); die(regs, "Oops"); - do_exit(SIGKILL); + make_task_dead(SIGKILL); } static inline void no_context(struct pt_regs *regs, unsigned long addr) diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c index db1bc00229caf..272ef8597e208 100644 --- a/arch/s390/kernel/dumpstack.c +++ b/arch/s390/kernel/dumpstack.c @@ -224,5 +224,5 @@ void die(struct pt_regs *regs, const char *str) if (panic_on_oops) panic("Fatal exception: panic_on_oops"); oops_exit(); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } diff --git a/arch/s390/kernel/nmi.c b/arch/s390/kernel/nmi.c index 383b4799b6dd3..d4f071e73a0a6 100644 --- a/arch/s390/kernel/nmi.c +++ b/arch/s390/kernel/nmi.c @@ -175,7 +175,7 @@ void __s390_handle_mcck(void) "malfunction (code 0x%016lx).\n", mcck.mcck_code); printk(KERN_EMERG "mcck: task: %s, pid: %d.\n", current->comm, current->pid); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } } diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c index e76b221570999..361b764700b74 100644 --- a/arch/sh/kernel/traps.c +++ b/arch/sh/kernel/traps.c @@ -57,7 +57,7 @@ void die(const char *str, struct pt_regs *regs, long err) if (panic_on_oops) panic("Fatal exception"); - do_exit(SIGSEGV); + make_task_dead(SIGSEGV); } void die_if_kernel(const char *str, struct pt_regs *regs, long err) diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c index 5630e5a395e0d..179aabfa712ea 100644 --- a/arch/sparc/kernel/traps_32.c +++ b/arch/sparc/kernel/traps_32.c @@ -86,9 +86,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs) } printk("Instruction DUMP:"); instruction_dump ((unsigned long *) regs->pc); - if(regs->psr & PSR_PS) - do_exit(SIGKILL); - do_exit(SIGSEGV); + make_task_dead((regs->psr & PSR_PS) ? SIGKILL : SIGSEGV); } void do_hw_interrupt(struct pt_regs *regs, unsigned long type) diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 6863025ed56d2..21077821f4272 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c @@ -2559,9 +2559,7 @@ void __noreturn die_if_kernel(char *str, struct pt_regs *regs) } if (panic_on_oops) panic("Fatal exception"); - if (regs->tstate & TSTATE_PRIV) - do_exit(SIGKILL); - do_exit(SIGSEGV); + make_task_dead((regs->tstate & TSTATE_PRIV)? SIGKILL : SIGSEGV); } EXPORT_SYMBOL(die_if_kernel); diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 6b44263d7efbc..e309e71560389 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -1239,14 +1239,14 @@ SYM_CODE_START(asm_exc_nmi) SYM_CODE_END(asm_exc_nmi) .pushsection .text, "ax" -SYM_CODE_START(rewind_stack_do_exit) +SYM_CODE_START(rewind_stack_and_make_dead) /* Prevent any naive code from trying to unwind to our caller. */ xorl %ebp, %ebp movl PER_CPU_VAR(cpu_current_top_of_stack), %esi leal -TOP_OF_KERNEL_STACK_PADDING-PTREGS_SIZE(%esi), %esp - call do_exit + call make_task_dead 1: jmp 1b -SYM_CODE_END(rewind_stack_do_exit) +SYM_CODE_END(rewind_stack_and_make_dead) .popsection diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index a3af2a9159b1b..9f1333a9ee41d 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1487,7 +1487,7 @@ SYM_CODE_END(ignore_sysret) #endif .pushsection .text, "ax" -SYM_CODE_START(rewind_stack_do_exit) +SYM_CODE_START(rewind_stack_and_make_dead) UNWIND_HINT_FUNC /* Prevent any naive code from trying to unwind to our caller. */ xorl %ebp, %ebp @@ -1496,6 +1496,6 @@ SYM_CODE_START(rewind_stack_do_exit) leaq -PTREGS_SIZE(%rax), %rsp UNWIND_HINT_REGS - call do_exit -SYM_CODE_END(rewind_stack_do_exit) + call make_task_dead +SYM_CODE_END(rewind_stack_and_make_dead) .popsection diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index ea4fe192189d5..53de044e56540 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -351,7 +351,7 @@ unsigned long oops_begin(void) } NOKPROBE_SYMBOL(oops_begin); -void __noreturn rewind_stack_do_exit(int signr); +void __noreturn rewind_stack_and_make_dead(int signr); void oops_end(unsigned long flags, struct pt_regs *regs, int signr) { @@ -386,7 +386,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr) * reuse the task stack and that existing poisons are invalid. */ kasan_unpoison_task_stack(current); - rewind_stack_do_exit(signr); + rewind_stack_and_make_dead(signr); } NOKPROBE_SYMBOL(oops_end); diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c index 874b6efc6fb31..904086ad56827 100644 --- a/arch/xtensa/kernel/traps.c +++ b/arch/xtensa/kernel/traps.c @@ -552,5 +552,5 @@ void die(const char * str, struct pt_regs * regs, long err) if (panic_on_oops) panic("Fatal exception"); - do_exit(err); + make_task_dead(err); } diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index caae8e045160d..d351f1b362ef9 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -59,6 +59,7 @@ extern void sched_post_fork(struct task_struct *p); extern void sched_dead(struct task_struct *p); void __noreturn do_task_dead(void); +void __noreturn make_task_dead(int signr); extern void proc_caches_init(void); diff --git a/kernel/exit.c b/kernel/exit.c index aefe7445508db..5d1a507fd4bae 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -877,6 +877,15 @@ void __noreturn do_exit(long code) } EXPORT_SYMBOL_GPL(do_exit); +void __noreturn make_task_dead(int signr) +{ + /* + * Take the task off the cpu after something catastrophic has + * happened. + */ + do_exit(signr); +} + void complete_and_exit(struct completion *comp, long code) { if (comp) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 308c8806ad94e..82ade76dcef2f 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -169,6 +169,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func, "panic", "do_exit", "do_task_dead", + "make_task_dead", "__module_put_and_exit", "complete_and_exit", "__reiserfs_panic", @@ -176,7 +177,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func, "fortify_panic", "usercopy_abort", "machine_real_restart", - "rewind_stack_do_exit", + "rewind_stack_and_make_dead" "kunit_try_catch_throw", "xen_start_kernel", "cpu_bringup_and_idle", From patchwork Tue Jan 24 18:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47818 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318753wrn; Tue, 24 Jan 2023 10:53:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXtimm4dxI97e4ZZfWiUawLBzsliSCKFRFvU7kftU1kr9vP22qMbChG6Tfn5dm5T0HeSVjPw X-Received: by 2002:a17:902:e548:b0:194:687c:e883 with SMTP id n8-20020a170902e54800b00194687ce883mr39656428plf.37.1674586390785; Tue, 24 Jan 2023 10:53:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586390; cv=none; d=google.com; s=arc-20160816; b=tBWnSsAxlLry7PBSlZ3fU7fc44PvDe9U4i4WTkz30cww12OGRKJVlnLBS12XPybY8H KFTHBTWFnG5EIZgeuNbx7NJWWRNIV4/wJk9+ysYNvpalttzdTq6P6N9mGStYuKT1tdEZ lhxAG4yx98EtecP9hg7QnTIY8lTEHK3bCypw6qEIP3aV/pjaUh+C0aqt1MRqp7kKrstt MvwZsBBR8o6NAAIl2FfaAQgHaseLXXtyrACOBasVAuEa//fIBqGbM8KprKXy262NSbhW ON2qqo9Det5ecYmVe5EpvM1Ojq5u/kwmJVPq0IXdTZopAQsY5Z3NiDQ6g1hCbjKZknHm KkxQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9cGvNp3uSGsw1g7c4Y/xqaIWy+gsDlfGW4ZDwOwHZRM=; b=EVRjVNx0E6hTgKjR/ZxzIQtiiXVxiMrC6DiphOdkBAeadcIosEjKID05Y38ONMqpos RJZhdF8qwcjNBXbqmJRkiJWVpRpXu5Ff8RhAFMaY5H+pbc/h/YpRtQzxTzHNO0Lu5zGy UtRcTFiXdZ2C/jfSykbPL03c8dXIKiCf4MNvtHAAHCLrJuL7GYQdgMgPUWPYfrkN7E+f uO2210H/H0hqKATQK+VrCDddIHeFIi47cbBi7mnurlZYD994YMOVH/KCiuW/t73HPF4R TV2FBfEzKMdjI0xlRAA+8oOKJsjURw0xiLQg+Tie2Tbtg6HE+IUY45QZyY0c2cqnvZhh 30QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jYUxilzC; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a170902e5c300b001949d233d5csi3287047plf.65.2023.01.24.10.52.57; Tue, 24 Jan 2023 10:53:10 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jYUxilzC; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232854AbjAXSwY (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbjAXSwH (ORCPT ); Tue, 24 Jan 2023 13:52:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD7044BD1; Tue, 24 Jan 2023 10:52:06 -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 36A9A61329; Tue, 24 Jan 2023 18:52:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C1F5C433A0; Tue, 24 Jan 2023 18:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586325; bh=ETUNzGdE1q29ST7qCi2iY3q174yxefVjhGSMsUKt8+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jYUxilzCb2eUCPCGnkS8Eq9AfBcrQuVXg6iCq95NE+ExdI7jQeKsBDgSr+7nWGBKv /8z0vMxXiJwlUB7cAKTxNcEKjIDVBaDdjDVdzDR4YNIrwj356K+XynhyAfRx0Qm9Le V1s5yI4WHIHLtj7fjNfb17gpGY2zqTP0pmbKmD/Q0HVFaBdKC193uYAVxtkOCjQ8WI IgQYYDOZ6QWhlObAx2GyOoBSuqtdXbP8YPOfE7Vm/fvWNkb7quTDIvEOIa6OKnKeD7 +VZj4x/Y4JHPKSmDM8E2PZJy4BoHmlYiLim3p+NAgUppKpJPhDQgQ/vYkQ23q6kuqB LJKWFiv36mJvw== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot Subject: [PATCH 5.15 07/20] objtool: Add a missing comma to avoid string concatenation Date: Tue, 24 Jan 2023 10:50:57 -0800 Message-Id: <20230124185110.143857-8-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931099527359913?= X-GMAIL-MSGID: =?utf-8?q?1755931099527359913?= From: "Eric W. Biederman" commit 1fb466dff904e4a72282af336f2c355f011eec61 upstream. Recently the kbuild robot reported two new errors: >> lib/kunit/kunit-example-test.o: warning: objtool: .text.unlikely: unexpected end of section >> arch/x86/kernel/dumpstack.o: warning: objtool: oops_end() falls through to next function show_opcodes() I don't know why they did not occur in my test setup but after digging it I realized I had accidentally dropped a comma in tools/objtool/check.c when I renamed rewind_stack_do_exit to rewind_stack_and_make_dead. Add that comma back to fix objtool errors. Link: https://lkml.kernel.org/r/202112140949.Uq5sFKR1-lkp@intel.com Fixes: 0e25498f8cd4 ("exit: Add and use make_task_dead.") Reported-by: kernel test robot Signed-off-by: "Eric W. Biederman" Signed-off-by: Eric Biggers --- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 82ade76dcef2f..758c0ba8de350 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -177,7 +177,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func, "fortify_panic", "usercopy_abort", "machine_real_restart", - "rewind_stack_and_make_dead" + "rewind_stack_and_make_dead", "kunit_try_catch_throw", "xen_start_kernel", "cpu_bringup_and_idle", From patchwork Tue Jan 24 18:50:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319113wrn; Tue, 24 Jan 2023 10:54:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXv4s9hAjfYTcEH2bwLIHvGtKxZZJqL0Z9mMvVfYfUDdjzs4g36eYoGTTHZBQ/o04RRQ0pli X-Received: by 2002:a05:6a20:cb58:b0:af:b909:2b3f with SMTP id hd24-20020a056a20cb5800b000afb9092b3fmr25847376pzb.34.1674586443573; Tue, 24 Jan 2023 10:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586443; cv=none; d=google.com; s=arc-20160816; b=SwmV0nA/Q1vcAYGmz7Ft9S5LvSVI1ffyrea/d7u1xU3QLxR7ixD1bXkHuqBurufoVG Uqe4nNDEtxaor0fKIIK4yV9qsEgae4zCxNvTI6g/tzuMg6A41vCQ+0+gjueVC1k5k3a+ TKULyW13cPS5ktyCtOzmBclhgwlsSsF25LiBgJAonRpuAI6s6Cv+vec68G91r5laci4M 7rSHnqkQQUKHhx7OFqD0NC5Aw/T5ED6nwi3e6yKLQ+19tYLfg5pnPOMGB/v7fzjFzPDQ R6MzU5TrMZrXllYf4dF1g+oOnywFU13ePJvger73yqC5YU3GaOETrpzcY7LaVR9rzL32 Ho8w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YWPFBVSYQeEzzEWZl6wYDlq5kqT7Tp0m5kBS9A+u37A=; b=LsB9LnKjAKV6QkLMA/7RCDSKmMhBhUZ56T+mNQAjsS6ZVEyyZkS4B1hKDa/ogCkIW9 O8j4nFEMMNSsriTKjc9G2frVivRJM4rfUtwPQei5Qf491J/mDsM8PLb1sASLg1SAhATF 48plre2gz/HOMnieU/q1oGWCSq76QHEf00BKpIrtlOVAVLePOMchZbmF9LGnFzQwf0nH Rrlleza+qRNu8xwSVf7rUhR6i5W7rVZ6BO2CZNUAJlntxAcwat/awOW7rbgBUwA5A19d Lu+pnZIMABS1io2ZZbARy8pDjwmGBNKtfKQwbfMdmzKCfAaVfsCGEcjRBeN89+4/XIY/ 0NNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UQ6bxJRF; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a637703000000b0046ec3bd90bbsi3144391pgc.60.2023.01.24.10.53.51; Tue, 24 Jan 2023 10:54:03 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UQ6bxJRF; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234233AbjAXSw0 (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234180AbjAXSwH (ORCPT ); Tue, 24 Jan 2023 13:52:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B83F460B1; Tue, 24 Jan 2023 10:52: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 A9F4661326; Tue, 24 Jan 2023 18:52:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C158FC4339B; Tue, 24 Jan 2023 18:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586326; bh=KXWYAV5gggvFf9MFGmbJ26fy4m1XP/EJdO/BLbEx1cA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UQ6bxJRFIYdY0M8uCKCGrIrguAdNOZNW9jfBhOJPPuE/dbmbgv7P5d7rgPLxeVEcS Yh0MwM6/3bkVe4v0CL+1rZiXEX/J6Yj9TdXE8tUssx3k27P0ZRklFApxBXHJttAn66 JPvZch3kPeA+18i/duStN8SVwPUDv+8fgfUbmDmxZrSTjtigJfdzAleHNt9LviYIfL sA7MjRgS3m6wiCq1xqpHBkwh15sEnz+kCHgMt3XOW+YjSH0H6WMYci9RFU5ZFaxhNE dintyN4QOxHdpXzl9vLGPPGTxTsqdNkZ6YJ4tkQlWFp+ZhzHR1BCRC8bmSve/LT1Yg 3/wEEoqpaLCqg== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor Subject: [PATCH 5.15 08/20] hexagon: Fix function name in die() Date: Tue, 24 Jan 2023 10:50:58 -0800 Message-Id: <20230124185110.143857-9-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931154656395149?= X-GMAIL-MSGID: =?utf-8?q?1755931154656395149?= From: Nathan Chancellor commit 4f0712ccec09c071e221242a2db9a6779a55a949 upstream. When building ARCH=hexagon defconfig: arch/hexagon/kernel/traps.c:217:2: error: implicit declaration of function 'make_dead_task' [-Werror,-Wimplicit-function-declaration] make_dead_task(err); ^ The function's name is make_task_dead(), change it so there is no more build error. Fixes: 0e25498f8cd4 ("exit: Add and use make_task_dead.") Signed-off-by: Nathan Chancellor Link: https://lkml.kernel.org/r/20211227184851.2297759-2-nathan@kernel.org Signed-off-by: Eric W. Biederman Signed-off-by: Eric Biggers --- arch/hexagon/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c index 6dd6cf0ab711f..1240f038cce02 100644 --- a/arch/hexagon/kernel/traps.c +++ b/arch/hexagon/kernel/traps.c @@ -214,7 +214,7 @@ int die(const char *str, struct pt_regs *regs, long err) panic("Fatal exception"); oops_exit(); - make_dead_task(err); + make_task_dead(err); return 0; } From patchwork Tue Jan 24 18:50:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47831 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319120wrn; Tue, 24 Jan 2023 10:54:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXuvH5blQ958Y/cplqx1KxHUZSUtBvB7gqx8VX6E8FUQSwdu/blPOquHA0ndBXeHQrxRz9cw X-Received: by 2002:a17:90b:50e:b0:229:4dcd:ff61 with SMTP id r14-20020a17090b050e00b002294dcdff61mr30958727pjz.28.1674586444455; Tue, 24 Jan 2023 10:54:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586444; cv=none; d=google.com; s=arc-20160816; b=UlpSZEd8w5TPTfAPC+OXlq+TR767fOogyhevU3yVXJu8g+YAr/Y7oSqtOaqJAESZuY 0vwmCaFhxXZ4wqiq9a7jf1w4hCmaulTlNcBFRN9Uv4SAxmGhEG1RvbYUECh6bQCLfZH5 Tx7PUSVmVFnQzMBBgB6TjPIchOtbudlzVG9vuEALYP11pmB+kMbqtT+thqmPnqtN3XXv IUR9A8ZO6Xvo/8+IjDGyTYQ5uCO6TO1i05XXk4S0ewSRZFk7hVY1IYtOoXyCqnzapkS/ LzsDBvN4d7T189OGJKuf68qXs1S97Hr2PKtrRvjvqksvzRFdjLP4/yGomQvB+1UiUxdY chdQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QekplI4XndTlcU0QqUHTWdrdn9A4qpMHmy6uwByrU3o=; b=BwSbufUMcumfZYWkgBwdVjjUe3JDiwHxgpA/WhpvpHSV02OkG9NcXX9IG8O/rW/vz4 pQFOEDe7lpEox+MNG338znfsOiDlDqHcdHEpL1CcTEIxrwfy9DCNQR9pk+3pKy/T0byz GAO5jAwg+DSUw3vtYWPv1SSvZlROEDae8SRtIubisWuE59MGqZ0kmSpgf4C0AAHR8ezG bPojmAfvKYM2sLxCwtYJcqbg1TwT0N+hr62RtQRT8heRh6lF6rOsTH/9YToBkRAjt9iJ +swMiZfvpBwgVNwCCWnCrN5p9mw6ZLitgnsbx0FSk9N5akT3Km/1X2apgiiQ42idH/mL IP6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c4Ln8OAq; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l73-20020a633e4c000000b004a737c5d96csi3150559pga.71.2023.01.24.10.53.52; Tue, 24 Jan 2023 10:54:04 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c4Ln8OAq; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234279AbjAXSwn (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbjAXSw0 (ORCPT ); Tue, 24 Jan 2023 13:52:26 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA1A04609D; Tue, 24 Jan 2023 10:52:09 -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 sin.source.kernel.org (Postfix) with ESMTPS id 459B4CE0E11; Tue, 24 Jan 2023 18:52:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FE47C433EF; Tue, 24 Jan 2023 18:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586326; bh=pCEZoYPkgp7l8iruCPKNi4PqYvgj1pEBIkBY310sT6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c4Ln8OAqe1Ot1EbIajSILw67/X0mGUxD4NiE1u9827xvIcUDfIIdNOijnfomRcZlr Gv0NAp0X+AuWoswUDleTSFpk6NVH6R42G3SmdX9JQ1jq4fDD4bEFlxEt8vhJHikX4r J4jFNSllRt7qtYYiZZBVUlFDI3TFV9tss7wW3r5pl3W1HxMNIvFb0vJ61ynXxQ0D1D 2VbnQbk61msSW54jL/7dcEBMT5fbXMFoyCeNBlayfMxKrtC5aJiTBlJFsqvlU9Cv3u 8QbemyBRJ32HJZ/EADVzSZFAZKp/o/uZKM9Ez+Q5/Rk93yXMCtdTpJmzf94oNi/rY4 uzYNf52MIR1Tw== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor Subject: [PATCH 5.15 09/20] h8300: Fix build errors from do_exit() to make_task_dead() transition Date: Tue, 24 Jan 2023 10:50:59 -0800 Message-Id: <20230124185110.143857-10-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931155549139744?= X-GMAIL-MSGID: =?utf-8?q?1755931155549139744?= From: Nathan Chancellor commit ab4ababdf77ccc56c7301c751dff49c79709c51c upstream. When building ARCH=h8300 defconfig: arch/h8300/kernel/traps.c: In function 'die': arch/h8300/kernel/traps.c:109:2: error: implicit declaration of function 'make_dead_task' [-Werror=implicit-function-declaration] 109 | make_dead_task(SIGSEGV); | ^~~~~~~~~~~~~~ arch/h8300/mm/fault.c: In function 'do_page_fault': arch/h8300/mm/fault.c:54:2: error: implicit declaration of function 'make_dead_task' [-Werror=implicit-function-declaration] 54 | make_dead_task(SIGKILL); | ^~~~~~~~~~~~~~ The function's name is make_task_dead(), change it so there is no more build error. Additionally, include linux/sched/task.h in arch/h8300/kernel/traps.c to avoid the same error because do_exit()'s declaration is in kernel.h but make_task_dead()'s is in task.h, which is not included in traps.c. Fixes: 0e25498f8cd4 ("exit: Add and use make_task_dead.") Signed-off-by: Nathan Chancellor Link: https://lkml.kernel.org/r/20211227184851.2297759-3-nathan@kernel.org Signed-off-by: Eric W. Biederman Signed-off-by: Eric Biggers --- arch/h8300/kernel/traps.c | 3 ++- arch/h8300/mm/fault.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c index 3d4e0bde37ae7..a92c39e03802e 100644 --- a/arch/h8300/kernel/traps.c +++ b/arch/h8300/kernel/traps.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -106,7 +107,7 @@ void die(const char *str, struct pt_regs *fp, unsigned long err) dump(fp); spin_unlock_irq(&die_lock); - make_dead_task(SIGSEGV); + make_task_dead(SIGSEGV); } static int kstack_depth_to_print = 24; diff --git a/arch/h8300/mm/fault.c b/arch/h8300/mm/fault.c index 0223528565dd3..b465441f490df 100644 --- a/arch/h8300/mm/fault.c +++ b/arch/h8300/mm/fault.c @@ -51,7 +51,7 @@ asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address, printk(" at virtual address %08lx\n", address); if (!user_mode(regs)) die("Oops", regs, error_code); - make_dead_task(SIGKILL); + make_task_dead(SIGKILL); return 1; } From patchwork Tue Jan 24 18:51:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318773wrn; Tue, 24 Jan 2023 10:53:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXtr4xLT1DiKNQZFlhMwxEUkTH7nZh+9Nth3wKYoiYyKCUI9ERqHxkAakb4EOR+kj/w2QLDE X-Received: by 2002:a05:6a20:4f08:b0:b8:36a7:c5b0 with SMTP id gi8-20020a056a204f0800b000b836a7c5b0mr28874981pzb.13.1674586392498; Tue, 24 Jan 2023 10:53:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586392; cv=none; d=google.com; s=arc-20160816; b=S8yNQ3aa0/czE0hqXPqPnGvUveq/E4oIsPKo/JQFTFcOiywLkdQfk7poUexRNE1ozs Xj+NFmai04KLmGAC9Uq+rhBw/QudkaE272LX0bwKlDkx1NWJf+2tE/er9QlYqh2zS5j+ UP3ahN8hdYNaz/o9vWatchJGmX7VRthzxpclxRrbel2Gv9S+t+IA+vR3HAfTEYUxv4Pe uOC5w4ckGrHQifcfH1m/kfOtEsTXuwNpQLs7bL9vGixMjEMdFSE2SfntWm/qpsS3ffKq Z9Uvovjm0yVBKyGZFUEu/bWvi229Dv6gjppSl3/EIAmm+BM3zIM7m4Qwfbt9VrrHREzJ 1hyQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jOy+q30oAIln4kZfQpF951aWORpjJC/W8u6auksMZOw=; b=eOeIQU/WZ3g2KurrLauQC8ifgrnC34GLIHKnG0zpr+R0eBJU4UufiAXUoaxXH/JVfY FGQBV3m5voGJ1/FRF50FpR47BS5rxrWzmeINw4v1Fo5vGeCdo+LtZRCFthA4h7aQ91wI xnEsCbmY08jA0E/7+lgOP2nCoDB9K6jGOyxLrKHrQtn2msQ+Q5da0LFCRJh8YjOpRU6U R94S9hWlCzX1l8fOBijyGOoEYi/KBLoHr1t7W+Ljx9I1uG8Pna6SKD0aZBH7Mfu7nAfk R+zG4VRG+6ZBDujHBJ7XiNob5vZl5/K81kWkkCzKCoJ+2HJS5iYyeM1oYUO533R+tLhL A+yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t0XMxKfV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t4-20020a637804000000b00477b7f8a857si3009335pgc.203.2023.01.24.10.52.59; Tue, 24 Jan 2023 10:53:12 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t0XMxKfV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234243AbjAXSwb (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234197AbjAXSwJ (ORCPT ); Tue, 24 Jan 2023 13:52:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D7145883; Tue, 24 Jan 2023 10:52:08 -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 A69D46133A; Tue, 24 Jan 2023 18:52:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2C5DC4339C; Tue, 24 Jan 2023 18:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586327; bh=GU2e8jnUe6XycCi7u+fblwnZwNdQQIRY+kiK7YVxOM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t0XMxKfVmzBaHV/TUUBHail2GurVC78Scym29ZonVlxwuDzKz/Xu4yNW3khbMDXDq evPHgI2Vn4hhqhW3zjGwOQYv/HU+gin/Qn/vT9iCkTQKqZtTXVPVocBpnrYcEu2dXe 1mN5uW691ri0XSDPi+m/JWaFqge+CHINgiWQjznsHkNoZv0JMatkglE8Sg1HSVMkjQ 6HnVGhkLcJl8BYngdf2qQ4zp7v8VETyor/IZvznhLzsrxj9snDuRq/nhpyZML5Yupw 3iNjD9QFAiz5GWI5870uuNoggJBU9O9O2N0e8L0z7/HT3amqHRQ0/DZY2zlj331stt c+y38QmUSXt+A== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Guo Ren Subject: [PATCH 5.15 10/20] csky: Fix function name in csky_alignment() and die() Date: Tue, 24 Jan 2023 10:51:00 -0800 Message-Id: <20230124185110.143857-11-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931100714616925?= X-GMAIL-MSGID: =?utf-8?q?1755931100714616925?= From: Nathan Chancellor commit 751971af2e3615dc5bd12674080bc795505fefeb upstream. When building ARCH=csky defconfig: arch/csky/kernel/traps.c: In function 'die': arch/csky/kernel/traps.c:112:17: error: implicit declaration of function 'make_dead_task' [-Werror=implicit-function-declaration] 112 | make_dead_task(SIGSEGV); | ^~~~~~~~~~~~~~ The function's name is make_task_dead(), change it so there is no more build error. Fixes: 0e25498f8cd4 ("exit: Add and use make_task_dead.") Signed-off-by: Nathan Chancellor Reviewed-by: Guo Ren Link: https://lkml.kernel.org/r/20211227184851.2297759-4-nathan@kernel.org Signed-off-by: Eric W. Biederman Signed-off-by: Eric Biggers --- arch/csky/abiv1/alignment.c | 2 +- arch/csky/kernel/traps.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/csky/abiv1/alignment.c b/arch/csky/abiv1/alignment.c index 5e2fb45d605cf..2df115d0e2105 100644 --- a/arch/csky/abiv1/alignment.c +++ b/arch/csky/abiv1/alignment.c @@ -294,7 +294,7 @@ void csky_alignment(struct pt_regs *regs) __func__, opcode, rz, rx, imm, addr); show_regs(regs); bust_spinlocks(0); - make_dead_task(SIGKILL); + make_task_dead(SIGKILL); } force_sig_fault(SIGBUS, BUS_ADRALN, (void __user *)addr); diff --git a/arch/csky/kernel/traps.c b/arch/csky/kernel/traps.c index b445c5aee220b..6e426fba01193 100644 --- a/arch/csky/kernel/traps.c +++ b/arch/csky/kernel/traps.c @@ -109,7 +109,7 @@ void die(struct pt_regs *regs, const char *str) if (panic_on_oops) panic("Fatal exception"); if (ret != NOTIFY_STOP) - make_dead_task(SIGSEGV); + make_task_dead(SIGSEGV); } void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr) From patchwork Tue Jan 24 18:51:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318791wrn; Tue, 24 Jan 2023 10:53:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdKMn215EWOicVJZwDnRuhEjNLhVB/VjcK36h3vvRO5EILPTWS3OMziBWYGS+JInSzx6DI X-Received: by 2002:a17:902:7fc2:b0:194:9485:809e with SMTP id t2-20020a1709027fc200b001949485809emr25722876plb.30.1674586395107; Tue, 24 Jan 2023 10:53:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586395; cv=none; d=google.com; s=arc-20160816; b=j8WwDe0Mh9sdeceNy3UNXNrCYdlvxq7tch8OI7hOsX/KogphaaVCwPqABhiJPvIn1W DXLpbUjmRBPau0qIDgWaq2TxfLZs6+U7HWXJYahJ+xtpzqMfStUb4TXNIfNfvL4wYreO xzS/M6GHpJNayRkzipTKl/GQjXlRFrRKNID2mZsvYRXV65UvhTIKTrU0TUPv9rFLszgX w/GzwjziPruTYqdcgghBHWHQeUVetSMwpm+BNVxG9qmytUbXkPMp5VXYtRkVTtFzh0mU 4Zu+SHk9a9UJk8o9e/muJRQDx81ZIJmSYnbYX85NZtUsXeoAs1PHe/1Ord8Rr5ptMfjv wV5Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/CqYXoUxFXEPnwQoWati1C11wLQcjQJXHDmvANaMvPI=; b=ncj0eWVh3tDKIK8VLjx24PZPWRfgGaQntTIpd0LkSPCiHRYCQVP1f/mByUjWRWLqcU vxXikho4Rqf5uSamieLASXrDbwECV1ednlb10UsPCpx205THVH1uvRBBYvOF7KBLlT4Y cbmKW06s9N7T0rBzGilvfkslH+Hz80tMiPR0e0sSLnw59Ei4m5iJ55nWKNJ+CDbOAeZ0 6vOekiWV74BsEmo/zmrqKP2ikoT5hCNrbmBn3DOzykMpjlweAInwzre6Ynx5JkBFQFsl g1N0yietHGumVwXnnGltRyk7iiTN05G+azNkyMCg6kPordxbiTkojIy3O7iQrU9BzBEI H+XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GAYtRepR; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63a109000000b004c92a2e33c1si2715945pgf.476.2023.01.24.10.53.01; Tue, 24 Jan 2023 10:53:15 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GAYtRepR; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233798AbjAXSwh (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234199AbjAXSwJ (ORCPT ); Tue, 24 Jan 2023 13:52:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BBB64670B; Tue, 24 Jan 2023 10:52:08 -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 D71CE6133F; Tue, 24 Jan 2023 18:52:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B1D0C433D2; Tue, 24 Jan 2023 18:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586327; bh=jzPL6LHUXqIbpvpkZv0OXyeymsk3s+AKet/3VWgwU90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GAYtRepRYA2Q4xMgMgBErhJoFj8ZH7udk/W+roxBpvUGOWn0ZqPPkgO28T/muUMop C66tLKDXvJ2HTxjGBeqedY6avpk0qE4w9Rjggv0iDawDAoQbNC9sQoVZ7cbluXGaqQ bs8SD0LKj9NO1oK9XCj5midRsozpNujWh9mQ1/5sa30Rfv/pzJocBxARsfDvMoz2+/ FASwSf6KYublmlGPr8X8xxFtJygcZnGvJ1C4Sn/bszAkWk0DInUydkvXgXqPf5DlHM 2PhJCrCku2lIgEyxMcIF3JZfz51lkTaC4sTQZjdlDm9hUQPF4lL9ToWVjc4NxFWjFM m8zLVSXLwA2HQ== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Tony Luck , Randy Dunlap , Christoph Hellwig , Christoph Hellwig , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 11/20] ia64: make IA64_MCA_RECOVERY bool instead of tristate Date: Tue, 24 Jan 2023 10:51:01 -0800 Message-Id: <20230124185110.143857-12-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931103431511182?= X-GMAIL-MSGID: =?utf-8?q?1755931103431511182?= From: Randy Dunlap commit dbecf9b8b8ce580f4e11afed9d61e8aa294cddd2 upstream. In linux-next, IA64_MCA_RECOVERY uses the (new) function make_task_dead(), which is not exported for use by modules. Instead of exporting it for one user, convert IA64_MCA_RECOVERY to be a bool Kconfig symbol. In a config file from "kernel test robot " for a different problem, this linker error was exposed when CONFIG_IA64_MCA_RECOVERY=m. Fixes this build error: ERROR: modpost: "make_task_dead" [arch/ia64/kernel/mca_recovery.ko] undefined! Link: https://lkml.kernel.org/r/20220124213129.29306-1-rdunlap@infradead.org Fixes: 0e25498f8cd4 ("exit: Add and use make_task_dead.") Signed-off-by: Randy Dunlap Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig Reviewed-by: "Eric W. Biederman" Cc: Tony Luck Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Eric Biggers --- arch/ia64/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 1e33666fa679b..b1f2b6ac9b1d5 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -323,7 +323,7 @@ config ARCH_PROC_KCORE_TEXT depends on PROC_KCORE config IA64_MCA_RECOVERY - tristate "MCA recovery from errors other than TLB." + bool "MCA recovery from errors other than TLB." config IA64_PALINFO tristate "/proc/pal support" From patchwork Tue Jan 24 18:51:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318804wrn; Tue, 24 Jan 2023 10:53:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvbjkGD0gjVrwyQqfKb7jg/JMc2r0pqEDSlX+/zWnmbOVuzDarDaQ+9fKQImcQ39PYyCNAk X-Received: by 2002:aa7:8204:0:b0:58b:9473:7ae0 with SMTP id k4-20020aa78204000000b0058b94737ae0mr30096710pfi.32.1674586396844; Tue, 24 Jan 2023 10:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586396; cv=none; d=google.com; s=arc-20160816; b=UJGxQHej85o43+JlMUkrvXr2ud7eYYXL4ezJdYolvqlrqaOkQul/4UipjTXSKaZK+2 OWBmyLiNZ6gj2o67Vmb+l0zPoj3vn3AZJTG8QnLHJU2UK5Dhdu0b8QcMm/Q0ZeR3d6kT rgW1VuvlDPu7I6U2IkNbjI61uc3g4iz23H6mWRkPbC0vb4oVKq1BXCCGEWN1fgLFC/ef gIKsxA/eWJB8T6kpBKAgE8y8SzDOyWRWOQ4Z3gUHuqH8SQJmu8Nvfb7/2FjsVlXOxXro TfJZ/rfAMDAlNLunR5VXtIGWU2xbmwH5f1SC0YjtmaKIh9ojWCsLSOo0A+DFrDtAphDi YFsw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j7euGvUOF5JKEjl5e0oDFWpNjvltUWCDrRHm8Oma1ts=; b=zxDkgXeiJp+irICynbgSfqlc5ezy1TbW+hFCLVbrIIVh7YLPgdLjFN6JoqfapKVlKj 9wpQlZqzUUCaPXCBuoCRhQMehaK5gTfnbkmLrnPICp/j557ocLUGMzGjItPvIrYsXF9E BNp7R/1VZDYtdIIr3CKJMgaQr8WFAa7kaoFPhE2VO0M5KkbHJFh+pbE1sh4jwOII90nA XotURjia0knBqcgujOAR2M6Gi3pUd45G3KXJ0mrbBLpdaQnRJwNmL+PxtQTLOQw4fgll rq0YWJBl3IhJc5w5NkgRxyBR6O9FfIJI43I7l2xoyFj/RSXC2KxScgbkCq97QFTVIijq gMEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oMhNbTOo; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h67-20020a625346000000b00585070b8dbcsi3136185pfb.315.2023.01.24.10.53.04; Tue, 24 Jan 2023 10:53:16 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oMhNbTOo; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234234AbjAXSwk (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234158AbjAXSw0 (ORCPT ); Tue, 24 Jan 2023 13:52:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053E644BD1; Tue, 24 Jan 2023 10:52:08 -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 7EE5B61326; Tue, 24 Jan 2023 18:52:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0595C4339E; Tue, 24 Jan 2023 18:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586328; bh=elP5tUEwCrTY71huuet3T+Fo7FOpVMVZKiKxptHmsR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMhNbTOoyCDWwXiAn3txe/olFH7txY1maX+VNuyaiVCUGgq8yHK4Yh7bsc6g9nDAI CVehe8kFo7Ejy94Vcsm4aZqGa10U36KOpVzziSfsG0GSV+rB5gC0Ks2H22Zu5gWLUg 9H2MUSixcgU0w2N31sRebxKNzBxwZ4HRHnRpm21KdWOmfxiymSGabPzrkTeVbsBccv SD6gUbg4rafkFlPqYMVmdwS8SQj9HP3iISVGTxQgXNUotFVkJD41L84JiDlbzMjeZD n9g4tEomI3y7KhB809iIcWkmRbRmfi8DJfzT6ci7EGl65wGmfQHaret1HXC4cS4hh5 DOQs8N3Bum7UA== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Mladek , Andrew Morton , tangmeng , "Guilherme G. Piccoli" , Tiezhu Yang , Sebastian Andrzej Siewior , Luis Chamberlain Subject: [PATCH 5.15 12/20] panic: Separate sysctl logic from CONFIG_SMP Date: Tue, 24 Jan 2023 10:51:02 -0800 Message-Id: <20230124185110.143857-13-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931105624494082?= X-GMAIL-MSGID: =?utf-8?q?1755931105624494082?= From: Kees Cook commit 9360d035a579d95d1e76c471061b9065b18a0eb1 upstream. In preparation for adding more sysctls directly in kernel/panic.c, split CONFIG_SMP from the logic that adds sysctls. Cc: Petr Mladek Cc: Andrew Morton Cc: tangmeng Cc: "Guilherme G. Piccoli" Cc: Tiezhu Yang Cc: Sebastian Andrzej Siewior Reviewed-by: Luis Chamberlain Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20221117234328.594699-1-keescook@chromium.org Signed-off-by: Eric Biggers --- kernel/panic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/panic.c b/kernel/panic.c index 5ed1ad06f9a34..0b560312878c5 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -73,8 +73,9 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list); EXPORT_SYMBOL(panic_notifier_list); -#if defined(CONFIG_SMP) && defined(CONFIG_SYSCTL) +#ifdef CONFIG_SYSCTL static struct ctl_table kern_panic_table[] = { +#ifdef CONFIG_SMP { .procname = "oops_all_cpu_backtrace", .data = &sysctl_oops_all_cpu_backtrace, @@ -84,6 +85,7 @@ static struct ctl_table kern_panic_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, +#endif { } }; From patchwork Tue Jan 24 18:51:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318944wrn; Tue, 24 Jan 2023 10:53:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXsF7YVRXB3/aNBAFNONV95/t5VFRQX+Tq/ykMawUJFQ8voewkk9dm2cBALfe7pEvcAt19Bx X-Received: by 2002:a17:90b:8c1:b0:229:1f83:84d0 with SMTP id ds1-20020a17090b08c100b002291f8384d0mr30146717pjb.14.1674586416951; Tue, 24 Jan 2023 10:53:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586416; cv=none; d=google.com; s=arc-20160816; b=iosMzXRGBL4Gu4Lpp1tTzDychJL7iMEPMdxa+ZAeSC70PnKoa4JcTA1wUhRHQCd5WH J8hwYXXiRaMmPHLKGoUNxWKGWC9/0ycHpAEt0Z7gfwNHSWEFdyE23menlHRpfnDXrNC9 F9iUrc8uAoSTMkYRMEWAZdSlqqlPxM0lUo7R41vYXtYrBNRgS+egaVYnRICSwGR9waFt 6YRvw+7kdP9he2Fj73txo4rB/zzxo1lSeJNyOZ2qKo10utvUlP8F5l4YNkrK20XdeeZW y6sxCDv7F5Zu44RAIzKTOvMKobeQ0P3KHt/QV5bOVkehQCsAnaLgiDEKVtVvlt7WlsWZ qSgg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g4QjEzTS/osr0PKRCWiITf0QcXOhGd1ocEFY19NorLQ=; b=JxjeGOGzfYMOC3DV4RIHQeAulVG7J6Q/Tlkb5PznXRdYcF2hu4AfNQL4btgYlXCYRa ElwSZBzpDVsuI1I6KJhNB+qlsxot9/YQhYQE0XqaauUOYW2jWbNN2VqZii9kBSkWAoqk yH1LTJg+TXiFM/2xveC20rp1iNF426Pji4lm0MxlcesZkI1KSqsFYido5ZD1TgHoPNBD ES523FSHdBHMfmn0TmGrdu/Jmag3ySsywPav6EG19p0VO1qr81D2eoyVd6wlKWtG4G/x gzu++N3kf12Vxpzl+PbACgIN+G4dSWq0ZjoGFx8NGooeTzWP1vbDbvgqswoNlg2kZDm/ Ejjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjFKUvpf; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o20-20020a17090ad25400b0022949f5ca1esi14452003pjw.86.2023.01.24.10.53.24; Tue, 24 Jan 2023 10:53:36 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjFKUvpf; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234269AbjAXSwx (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233809AbjAXSwg (ORCPT ); Tue, 24 Jan 2023 13:52:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 600644ABDB; Tue, 24 Jan 2023 10:52:11 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0F95AB816A9; Tue, 24 Jan 2023 18:52:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78575C433A0; Tue, 24 Jan 2023 18:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586328; bh=JPVb5eRLwkSeq1J7Wd4S+qskMfD70BTRh8Tm7ANTEH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjFKUvpfYB1A24NUDrMYpG6IbcuEuWTgzbwThbbBBSwGmxZyh8aURWsvyVwZVgxJN O+c+B3wJoXZIaBpKFNMGDPo6Zl4F50U2lt8okogX+GzbfdEFP3ABflIbZUC2qUGV9Z LMQW83uDYRgCXXGchdfGunCVesY4DjXQMtcwrVVDCItkTYbE8IO4z26UmClTCe3NGt IuiFkoPRdJp10flCPG4eexiOwHzMliCYJokVz4haRrxksbUQQRP0js0u5EScCoaqZY +ihlcsAwU4DE/nYghvAvZbh9p5hfX7oFEjTtSCBAJ6TRNJO6GBvq7dxBjSNTjLa+7t smrkD90nhyerw== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 5.15 13/20] exit: Put an upper limit on how often we can oops Date: Tue, 24 Jan 2023 10:51:03 -0800 Message-Id: <20230124185110.143857-14-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931126791963472?= X-GMAIL-MSGID: =?utf-8?q?1755931126791963472?= From: Jann Horn commit d4ccd54d28d3c8598e2354acc13e28c060961dbb upstream. Many Linux systems are configured to not panic on oops; but allowing an attacker to oops the system **really** often can make even bugs that look completely unexploitable exploitable (like NULL dereferences and such) if each crash elevates a refcount by one or a lock is taken in read mode, and this causes a counter to eventually overflow. The most interesting counters for this are 32 bits wide (like open-coded refcounts that don't use refcount_t). (The ldsem reader count on 32-bit platforms is just 16 bits, but probably nobody cares about 32-bit platforms that much nowadays.) So let's panic the system if the kernel is constantly oopsing. The speed of oopsing 2^32 times probably depends on several factors, like how long the stack trace is and which unwinder you're using; an empirically important one is whether your console is showing a graphical environment or a text console that oopses will be printed to. In a quick single-threaded benchmark, it looks like oopsing in a vfork() child with a very short stack trace only takes ~510 microseconds per run when a graphical console is active; but switching to a text console that oopses are printed to slows it down around 87x, to ~45 milliseconds per run. (Adding more threads makes this faster, but the actual oops printing happens under &die_lock on x86, so you can maybe speed this up by a factor of around 2 and then any further improvement gets eaten up by lock contention.) It looks like it would take around 8-12 days to overflow a 32-bit counter with repeated oopsing on a multi-core X86 system running a graphical environment; both me (in an X86 VM) and Seth (with a distro kernel on normal hardware in a standard configuration) got numbers in that ballpark. 12 days aren't *that* short on a desktop system, and you'd likely need much longer on a typical server system (assuming that people don't run graphical desktop environments on their servers), and this is a *very* noisy and violent approach to exploiting the kernel; and it also seems to take orders of magnitude longer on some machines, probably because stuff like EFI pstore will slow it down a ton if that's active. Signed-off-by: Jann Horn Link: https://lore.kernel.org/r/20221107201317.324457-1-jannh@google.com Reviewed-by: Luis Chamberlain Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20221117234328.594699-2-keescook@chromium.org Signed-off-by: Eric Biggers --- Documentation/admin-guide/sysctl/kernel.rst | 8 ++++ kernel/exit.c | 43 +++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index 609b891754081..b6e68d6f297e5 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -671,6 +671,14 @@ This is the default behavior. an oops event is detected. +oops_limit +========== + +Number of kernel oopses after which the kernel should panic when +``panic_on_oops`` is not set. Setting this to 0 or 1 has the same effect +as setting ``panic_on_oops=1``. + + osrelease, ostype & version =========================== diff --git a/kernel/exit.c b/kernel/exit.c index 5d1a507fd4bae..172d7f835f801 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -69,6 +69,33 @@ #include #include +/* + * The default value should be high enough to not crash a system that randomly + * crashes its kernel from time to time, but low enough to at least not permit + * overflowing 32-bit refcounts or the ldsem writer count. + */ +static unsigned int oops_limit = 10000; + +#ifdef CONFIG_SYSCTL +static struct ctl_table kern_exit_table[] = { + { + .procname = "oops_limit", + .data = &oops_limit, + .maxlen = sizeof(oops_limit), + .mode = 0644, + .proc_handler = proc_douintvec, + }, + { } +}; + +static __init int kernel_exit_sysctls_init(void) +{ + register_sysctl_init("kernel", kern_exit_table); + return 0; +} +late_initcall(kernel_exit_sysctls_init); +#endif + static void __unhash_process(struct task_struct *p, bool group_dead) { nr_threads--; @@ -879,10 +906,26 @@ EXPORT_SYMBOL_GPL(do_exit); void __noreturn make_task_dead(int signr) { + static atomic_t oops_count = ATOMIC_INIT(0); + /* * Take the task off the cpu after something catastrophic has * happened. */ + + /* + * Every time the system oopses, if the oops happens while a reference + * to an object was held, the reference leaks. + * If the oops doesn't also leak memory, repeated oopsing can cause + * reference counters to wrap around (if they're not using refcount_t). + * This means that repeated oopsing can make unexploitable-looking bugs + * exploitable through repeated oopsing. + * To make sure this can't happen, place an upper bound on how often the + * kernel may oops without panic(). + */ + if (atomic_inc_return(&oops_count) >= READ_ONCE(oops_limit)) + panic("Oopsed too often (kernel.oops_limit is %d)", oops_limit); + do_exit(signr); } From patchwork Tue Jan 24 18:51:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2318908wrn; Tue, 24 Jan 2023 10:53:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6nTvw9zPVgBou0Q7bQavaB8IdgqB91w39c/KcJtjSf9GGcjITy794zHk91l95CfiAhjD5 X-Received: by 2002:a05:6a21:99a7:b0:b2:5cf9:817b with SMTP id ve39-20020a056a2199a700b000b25cf9817bmr40358795pzb.5.1674586411812; Tue, 24 Jan 2023 10:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586411; cv=none; d=google.com; s=arc-20160816; b=hICIBxHui3DSxstR8WHR4y66crIIXNvb+sq1klA/qLNcX8juI9KbQYjyOuvC5zDfUt q9nSX1xYgFdjorAPRky2yUmHFoailt9RSvZ0EtmKXEEujeXVKz8xy4QoRVb3nstw6P6q iQKHXdRIrGwQMj5r6pZCgVzI3QVpKRPHJGrRmPMrK9SGjn3omxoG1D5LuQl2EPmULTDY BpE1F7dTGpTaZssC6ECxW0PET80wroYeDxx6mmAFLKTBkj4FoSS2F+UFPvOu8z3JMnB2 KrYRLWwOVSpeoRPUybtGQIytWmaqXpdUqrMhaUZ8+MtFB99YnhchCCCYr9Qo0cSokmDF MWqQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=auGgKjyMpDvez1faFRIwBh5uW0k8WXb83q14xOiT0WM=; b=vKYj5IT9UM9SUa8s/DfFrskOQJqn7UgdOCCNM7AHCsk2HvQ22maQ3eZm6byR4Ntnzc PsO130PvloWOIqhebHhQI13v7imLSozdmueXgmjYO+T/6yRkJcQSERb8KOcTZA4GsbrE Mw9FwKEysnNTy0lXrFqkf0c40QwkMC6UxCQz5KyU6T/9w3sYDhp99tYz5wYcSSy30s7N N/jCi6KvuIF22RHa1OVyWumgfouIsgml5uLyc6Xj2na4c4PXWe1JCzqPKJw7dshFMlyq dtcXBg7TCQ8w+vqVvjrUtgFFGrbW9Ui3XVo2k9Ml+lfpHr1EsXF4H9il8vMVCniduf7s 9MtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kj91HuNi; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d62-20020a633641000000b004891755d4besi2730492pga.78.2023.01.24.10.53.19; Tue, 24 Jan 2023 10:53:31 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kj91HuNi; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233564AbjAXSwq (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234119AbjAXSwa (ORCPT ); Tue, 24 Jan 2023 13:52:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55488460A9; Tue, 24 Jan 2023 10:52:10 -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 DC11761326; Tue, 24 Jan 2023 18:52:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAD8CC43445; Tue, 24 Jan 2023 18:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586329; bh=NVfEjkKHCDh3Q/HRqIiZkG55CLB6j3MC4GyUMgpia2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kj91HuNibxhwrowanpgNHSeOb1Q3eahhhQ/c3F+HUmUIhFDxRSm/3LpVuk+YfDFlD sw9eGUEOrN5zI6efL1YULprwaFJp2hNEvDbAo4ThJPc5sC3IhVwSwpeP+0Bt9Fjy4v s7LuXb7YSUFdlyYW/rLLwD8aDxBMaNt65QxWsHqN19kiP2F8pxNtStpLJfsqOsCESN VeSsUEGIYLHfIZRthfHPslifP5I0jQFlLaBEgwWJVJEWGseSSslC/xIyh1A+Xp8O9k DRHBCQPHlRqFucE/3yvdtPQqLEkKqnefit11cLYpwQIwl+oej5hyAmxG1qblPSOEEq bZpe2Jfm66HRw== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Luis Chamberlain Subject: [PATCH 5.15 14/20] exit: Expose "oops_count" to sysfs Date: Tue, 24 Jan 2023 10:51:04 -0800 Message-Id: <20230124185110.143857-15-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931121525991548?= X-GMAIL-MSGID: =?utf-8?q?1755931121525991548?= From: Kees Cook commit 9db89b41117024f80b38b15954017fb293133364 upstream. Since Oops count is now tracked and is a fairly interesting signal, add the entry /sys/kernel/oops_count to expose it to userspace. Cc: "Eric W. Biederman" Cc: Jann Horn Cc: Arnd Bergmann Reviewed-by: Luis Chamberlain Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20221117234328.594699-3-keescook@chromium.org Signed-off-by: Eric Biggers --- .../ABI/testing/sysfs-kernel-oops_count | 6 +++++ kernel/exit.c | 22 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-kernel-oops_count diff --git a/Documentation/ABI/testing/sysfs-kernel-oops_count b/Documentation/ABI/testing/sysfs-kernel-oops_count new file mode 100644 index 0000000000000..156cca9dbc960 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-kernel-oops_count @@ -0,0 +1,6 @@ +What: /sys/kernel/oops_count +Date: November 2022 +KernelVersion: 6.2.0 +Contact: Linux Kernel Hardening List +Description: + Shows how many times the system has Oopsed since last boot. diff --git a/kernel/exit.c b/kernel/exit.c index 172d7f835f801..f68a9c6adfc9c 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -96,6 +97,25 @@ static __init int kernel_exit_sysctls_init(void) late_initcall(kernel_exit_sysctls_init); #endif +static atomic_t oops_count = ATOMIC_INIT(0); + +#ifdef CONFIG_SYSFS +static ssize_t oops_count_show(struct kobject *kobj, struct kobj_attribute *attr, + char *page) +{ + return sysfs_emit(page, "%d\n", atomic_read(&oops_count)); +} + +static struct kobj_attribute oops_count_attr = __ATTR_RO(oops_count); + +static __init int kernel_exit_sysfs_init(void) +{ + sysfs_add_file_to_group(kernel_kobj, &oops_count_attr.attr, NULL); + return 0; +} +late_initcall(kernel_exit_sysfs_init); +#endif + static void __unhash_process(struct task_struct *p, bool group_dead) { nr_threads--; @@ -906,8 +926,6 @@ EXPORT_SYMBOL_GPL(do_exit); void __noreturn make_task_dead(int signr) { - static atomic_t oops_count = ATOMIC_INIT(0); - /* * Take the task off the cpu after something catastrophic has * happened. From patchwork Tue Jan 24 18:51:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319038wrn; Tue, 24 Jan 2023 10:53:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXvXcNiS05q4w4NMIi82QJPWagS4uY0FLgR7ebowq43SDn0V3vm50Ez4YOqxXSOknaXmTFkx X-Received: by 2002:a17:902:e9cd:b0:194:5de4:52d0 with SMTP id 13-20020a170902e9cd00b001945de452d0mr30645155plk.41.1674586431501; Tue, 24 Jan 2023 10:53:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586431; cv=none; d=google.com; s=arc-20160816; b=LNc3tmUPoGlJfVLUwxUTAZopfMFfgqOj0z3764WnuvBb9Ju/yYT9T5GmIncFnq9Ckt qEm9sbuOT9cfrlCXJqbe3wDKWi1TXGgbAZi6CXv5it1UUmvegl5bMVqv5T9Yxo6oH1mI JnqvD0x86kieQXKH7MOEBX/F5jnXK4t9i5gLq//gAAGny6Jpuuyxe0rqiRqDOTNx5ztf utGLNFo13JFy9SoGfCefC3qUttY8EMNi37SySo2Rg5Uak1Yby6zXqBin7GrxRhIXM/b5 nrO+JoKu8hCJbZ69jfxFB8HM7zEy/P+pqb5xthn8kv8/7jxfSAopScA03Wu7NQibNHjU yorg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4/FCEX8pK2ZuTQMIHTfcbZL0cpj4+jiCgIxt8GoZs10=; b=0tTcREShAyodSK5YodilZZiDt2zzD/28l+RDwxPjNEPtiSHh8Q+nmqKOeJuhA506FC 0Pnakyf88VRP9sssOm6K3olUMUipH7gCiD6gxbKsZJC8vxSD3269X5hjt+zHe1P6byWd dbfxG7TlHAZfryLemxgtTejFpclzFQeN49Xg4dEDrtAb6P2xrbRegOO9rHtMbe5Inssy SCxafX7M7ZO45MXARhconS0oNi2nTryMNaQN6dcKyM860HLTR7VF3T7A0BSkrZ+lvq7o 9y1IKXh2OmkqGfgYGHE2RPo6+bUpBx2HkZzV22l8TLYqj9F5UFElBGuX/UjkyBDdXpZz 7frA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fEuDjKUV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170903244700b00186b3cb49basi3392415pls.202.2023.01.24.10.53.38; Tue, 24 Jan 2023 10:53:51 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fEuDjKUV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233205AbjAXSw7 (ORCPT + 99 others); Tue, 24 Jan 2023 13:52:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233877AbjAXSwg (ORCPT ); Tue, 24 Jan 2023 13:52:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB64846156; Tue, 24 Jan 2023 10:52:10 -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 87AD761338; Tue, 24 Jan 2023 18:52:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70F7EC43326; Tue, 24 Jan 2023 18:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586330; bh=leveuMYdLJGLyfBl3ZKl32ZBXIzkUK2G8DzKRi5KAsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fEuDjKUVsKyG2ujjjMpLuz7JDPK6cDyP1JGGINeZi/eB3K8ecTvvyxN3AmE7stXVG X8lU7dS1fo2oNB/zQqgk0fgeKAmeVMNK2ZAV5SgkwQXdbA1DM7u8p+kV4F9TGb915T fIhNYNhjNjRpj+LE9SDLwsrvBZAhfqSi8rxOPYQ7HL6LmFBa5+Ez0tK//chbrzYI3m 7xu68omeUadtBH+5xzBNTZVNXUH+9ocnGs/bYv6Ofqy7W/U7GQBqlsg4SBwOzhUrqv 9oz5RGQNygWnAsA+TfeuRUU4rvQcxi+5fyNVT2IxXSjJGz+TgtV6OUAJ0pj6TsIgCY qPaL+JuhyRNGg== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Andrew Morton , Baolin Wang , "Jason A. Donenfeld" , Eric Biggers , Huang Ying , Arnd Bergmann , linux-doc@vger.kernel.org Subject: [PATCH 5.15 15/20] exit: Allow oops_limit to be disabled Date: Tue, 24 Jan 2023 10:51:05 -0800 Message-Id: <20230124185110.143857-16-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931141591894511?= X-GMAIL-MSGID: =?utf-8?q?1755931141591894511?= From: Kees Cook commit de92f65719cd672f4b48397540b9f9eff67eca40 upstream. In preparation for keeping oops_limit logic in sync with warn_limit, have oops_limit == 0 disable checking the Oops counter. Cc: Jann Horn Cc: Jonathan Corbet Cc: Andrew Morton Cc: Baolin Wang Cc: "Jason A. Donenfeld" Cc: Eric Biggers Cc: Huang Ying Cc: "Eric W. Biederman" Cc: Arnd Bergmann Cc: linux-doc@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Eric Biggers --- Documentation/admin-guide/sysctl/kernel.rst | 5 +++-- kernel/exit.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index b6e68d6f297e5..d6f1d3892e71e 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -675,8 +675,9 @@ oops_limit ========== Number of kernel oopses after which the kernel should panic when -``panic_on_oops`` is not set. Setting this to 0 or 1 has the same effect -as setting ``panic_on_oops=1``. +``panic_on_oops`` is not set. Setting this to 0 disables checking +the count. Setting this to 1 has the same effect as setting +``panic_on_oops=1``. The default value is 10000. osrelease, ostype & version diff --git a/kernel/exit.c b/kernel/exit.c index f68a9c6adfc9c..f6c85101dba0f 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -941,7 +941,7 @@ void __noreturn make_task_dead(int signr) * To make sure this can't happen, place an upper bound on how often the * kernel may oops without panic(). */ - if (atomic_inc_return(&oops_count) >= READ_ONCE(oops_limit)) + if (atomic_inc_return(&oops_count) >= READ_ONCE(oops_limit) && oops_limit) panic("Oopsed too often (kernel.oops_limit is %d)", oops_limit); do_exit(signr); From patchwork Tue Jan 24 18:51:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319111wrn; Tue, 24 Jan 2023 10:54:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXuOyzwxKnukL8cXz7rdblH8l6ftEwESgVSgVaqCqMai2gUvoNJaQr9Uqzf3udpET8bCbW3d X-Received: by 2002:a05:6a21:3290:b0:af:76da:1462 with SMTP id yt16-20020a056a21329000b000af76da1462mr40663081pzb.40.1674586443204; Tue, 24 Jan 2023 10:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586443; cv=none; d=google.com; s=arc-20160816; b=QrAaggPDc0yoDpirKAFehDt227fDa5LV1K8lh+bJ/NztXC89lbH3GtfmaTGRGi8CXn NaX2VXeUNimcXhcgRtjNy8hW0Q78aOBpKmE/4gO6qSV5gV58yvpsCgnVpJAw81rrHJE9 210NweAoGDJC1hf5TQq1FzRSziexynyubFHBnp2RNWvEfHIP7xWI4DVpt3k9MCVLOGGL qYen2KmGkkVAVaOf/mxeDKMLbTO4a10lR6M8SEoDdufW/BjirRrw6Vts165P/SpgZN6u wPzUUSCkrTnBVlKoWA+10e4lyQ+oJPIK/l0Dw1as0MPYmXlv5NKkulKevt2qSu/VtyPH 1cFA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xJNGcJv2h2UR3BQ3maAHJ6jpbT35hLIku6WgjRekH1Q=; b=Fv54IeHPsU7Sj2Qd1TKN+fRoNsi4HbJJq/Eu+WughXOS2xzniI43BLawbzD1zlIDOJ vXCYrUGq9x6TQOR8v9bFIFmhHVA6oFZKhfb82k8IDev4xqGKDKM/utX57vnLHi8CKxxW wXgVj4ADqcu/qvm0Lz//hc3rPbF2+sYGxxOzMlMs/y1g4lJUDxsEe4N58t6qjliASAGa VRB2tea6krxBqSrgIuSkdiSZLqEASl0E8EBZWEyjc+32Nrs+dpzUSenpnTT8vNHIOFbs muLEeYNNtK8ewzq6MLXNgtIZW+ae5u78LwdS6aCPKB/bX+9NQ5mrMn3EF/Ms95AMYCUy mLVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GqXJ7TZ4; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a636903000000b004cd418b1f06si2744654pgc.206.2023.01.24.10.53.51; Tue, 24 Jan 2023 10:54:03 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GqXJ7TZ4; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234499AbjAXSxG (ORCPT + 99 others); Tue, 24 Jan 2023 13:53:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234307AbjAXSwi (ORCPT ); Tue, 24 Jan 2023 13:52:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E62847EC2; Tue, 24 Jan 2023 10:52:13 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8025CB816AF; Tue, 24 Jan 2023 18:52:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21498C433A4; Tue, 24 Jan 2023 18:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586331; bh=F3BXfb8h26phWS3v8sVDECw7So0I3t1gmfnIPT90UKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqXJ7TZ4oLwJ+iuu5aHSEswFErDMvlZjUegG6yu33wFwC1RNnTpAT+SrNaKQZp4XZ 4RmVf5IXtOVHl36IT88+c27SkTPM0ta6OJyM+HRD5qdioSUKTkon0wFn6o+v9K937M qUQ2kND2qmtlfwC4Nx/i3w1sLEzbfkYuX2yOHgh8c8nj5ABnlM39ZJrOWl1Jv1p2PD 27dBm7bABESpIp5N4K1TnoCej+0ghWrA6eEfBflzHWiZSJCVFO9Qvfa7N9lCaxU8Pf jVMK3peEhwadTGj3N0ikYChbNuuGqyUMx5rGlCfW4r2Sqh4HG/U3En8zr3hrG6IQPM R8xhEwfZf4H5g== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Marco Elver , Dmitry Vyukov , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Vincenzo Frascino , Andrew Morton , David Gow , tangmeng , Shuah Khan , Petr Mladek , "Paul E. McKenney" , Sebastian Andrzej Siewior , "Guilherme G. Piccoli" , Tiezhu Yang , kasan-dev@googlegroups.com, linux-mm@kvack.org, Luis Chamberlain Subject: [PATCH 5.15 16/20] panic: Consolidate open-coded panic_on_warn checks Date: Tue, 24 Jan 2023 10:51:06 -0800 Message-Id: <20230124185110.143857-17-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931154045304748?= X-GMAIL-MSGID: =?utf-8?q?1755931154045304748?= From: Kees Cook commit 79cc1ba7badf9e7a12af99695a557e9ce27ee967 upstream. Several run-time checkers (KASAN, UBSAN, KFENCE, KCSAN, sched) roll their own warnings, and each check "panic_on_warn". Consolidate this into a single function so that future instrumentation can be added in a single location. Cc: Marco Elver Cc: Dmitry Vyukov Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Vincenzo Frascino Cc: Andrew Morton Cc: David Gow Cc: tangmeng Cc: Jann Horn Cc: Shuah Khan Cc: Petr Mladek Cc: "Paul E. McKenney" Cc: Sebastian Andrzej Siewior Cc: "Guilherme G. Piccoli" Cc: Tiezhu Yang Cc: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org Reviewed-by: Luis Chamberlain Signed-off-by: Kees Cook Reviewed-by: Marco Elver Reviewed-by: Andrey Konovalov Link: https://lore.kernel.org/r/20221117234328.594699-4-keescook@chromium.org Signed-off-by: Eric Biggers --- include/linux/panic.h | 1 + kernel/kcsan/report.c | 3 +-- kernel/panic.c | 9 +++++++-- kernel/sched/core.c | 3 +-- lib/ubsan.c | 3 +-- mm/kasan/report.c | 4 ++-- mm/kfence/report.c | 3 +-- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/linux/panic.h b/include/linux/panic.h index e71161da69c4b..8eb5897c164fc 100644 --- a/include/linux/panic.h +++ b/include/linux/panic.h @@ -11,6 +11,7 @@ extern long (*panic_blink)(int state); __printf(1, 2) void panic(const char *fmt, ...) __noreturn __cold; void nmi_panic(struct pt_regs *regs, const char *msg); +void check_panic_on_warn(const char *origin); extern void oops_enter(void); extern void oops_exit(void); extern bool oops_may_print(void); diff --git a/kernel/kcsan/report.c b/kernel/kcsan/report.c index 21137929d4283..b88d5d5f29e48 100644 --- a/kernel/kcsan/report.c +++ b/kernel/kcsan/report.c @@ -432,8 +432,7 @@ static void print_report(enum kcsan_value_change value_change, dump_stack_print_info(KERN_DEFAULT); pr_err("==================================================================\n"); - if (panic_on_warn) - panic("panic_on_warn set ...\n"); + check_panic_on_warn("KCSAN"); } static void release_report(unsigned long *flags, struct other_info *other_info) diff --git a/kernel/panic.c b/kernel/panic.c index 0b560312878c5..bf0324941e433 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -193,6 +193,12 @@ static void panic_print_sys_info(void) ftrace_dump(DUMP_ALL); } +void check_panic_on_warn(const char *origin) +{ + if (panic_on_warn) + panic("%s: panic_on_warn set ...\n", origin); +} + /** * panic - halt the system * @fmt: The text string to print @@ -628,8 +634,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint, if (regs) show_regs(regs); - if (panic_on_warn) - panic("panic_on_warn set ...\n"); + check_panic_on_warn("kernel"); if (!regs) dump_stack(); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2bd5e235d0781..c1458fa8beb3e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5560,8 +5560,7 @@ static noinline void __schedule_bug(struct task_struct *prev) pr_err("Preemption disabled at:"); print_ip_sym(KERN_ERR, preempt_disable_ip); } - if (panic_on_warn) - panic("scheduling while atomic\n"); + check_panic_on_warn("scheduling while atomic"); dump_stack(); add_taint(TAINT_WARN, LOCKDEP_STILL_OK); diff --git a/lib/ubsan.c b/lib/ubsan.c index 36bd75e334263..60c7099857a05 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -154,8 +154,7 @@ static void ubsan_epilogue(void) current->in_ubsan--; - if (panic_on_warn) - panic("panic_on_warn set ...\n"); + check_panic_on_warn("UBSAN"); } void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index bf17704b302fc..887af873733bc 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -117,8 +117,8 @@ static void end_report(unsigned long *flags, unsigned long addr) pr_err("==================================================================\n"); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); - if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) - panic("panic_on_warn set ...\n"); + if (!test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) + check_panic_on_warn("KASAN"); if (kasan_arg_fault == KASAN_ARG_FAULT_PANIC) panic("kasan.fault=panic set ...\n"); kasan_enable_current(); diff --git a/mm/kfence/report.c b/mm/kfence/report.c index 37e140e7f201e..cbd9456359b96 100644 --- a/mm/kfence/report.c +++ b/mm/kfence/report.c @@ -267,8 +267,7 @@ void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *r lockdep_on(); - if (panic_on_warn) - panic("panic_on_warn set ...\n"); + check_panic_on_warn("KFENCE"); /* We encountered a memory safety error, taint the kernel! */ add_taint(TAINT_BAD_PAGE, LOCKDEP_STILL_OK); From patchwork Tue Jan 24 18:51:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319012wrn; Tue, 24 Jan 2023 10:53:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXuzD1Ro7HllTizdEt7RxJcUGFghZ+lPevOVDAevK1xWhBuAPCCmm5FJxp1BSrcFKGiboyUP X-Received: by 2002:a05:6a20:d80e:b0:b8:8098:7ee5 with SMTP id iv14-20020a056a20d80e00b000b880987ee5mr31332700pzb.60.1674586428021; Tue, 24 Jan 2023 10:53:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586428; cv=none; d=google.com; s=arc-20160816; b=WNOCHE/hAuy2/vbWmsXPYRgM08uiTPCRvOM8m7huPJk7vCNv/grED4MDnJh3MQxy6o cOSEO2js+qEDaYFy8jnj/zi7qPXN0NzBW0F0nR6RitA8YOd1RgBJ8HjVi6hhvgfRaosE bkN9KFR9DHkqNVaprYFHeBtPFjLmNp6FwM6zxWKtCtO+QxL0IMMwKzuSMAPMwYg2TOYD NFCBzxzhrHDETBBu7bwn5h+3qIPjqcwDTb0jjugWpJ6YiOSWY/U2l64xAr6jYvT18/Yh GOzgmDjm8nPaNBVu7M8na1pstbIsrABO1DDm+SQ/0KYUv4Br/VnAhlPdojnTwgABD92A Fhug== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=goArHFs2HmkCgBK+2Oh0RuGGigGsbeIgZ3VDtbp1LgI=; b=QjtFbMvaQdEa/LhGsTO8qLLC60jQ1i0Mf71rxKc+nwuLGhnPUb2YwoOKC+LduQaTtK Uo1YZZCCJ/MLeXKwPRl6P2gjJ9FgCYOLBOx8cntKvzyTMAk08qD3hRZeh4d4mUJmCeBZ F/yuypaf/RYUiuBe4UE49+WbeIz181Lq+H/kGE0YD9JCXWoDOzIvPWJ8YaWpR8hiFHfw nM2zxQPa4WJ/ADps4heYpE29zGIDcKFJ3LefbHw5jHp414NpBcn7bmbjSS6+K6igTgli pb6Qt4vpBjNyBb4mX9Bf/dLAXmEoA9QMqxUtqoF2UqQ4TNogzDI0PrdvOwNb7H3vAs06 IdMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jEo/hJUa"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g30-20020a63375e000000b0049b262ac916si3126571pgn.566.2023.01.24.10.53.33; Tue, 24 Jan 2023 10:53:48 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jEo/hJUa"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234488AbjAXSxC (ORCPT + 99 others); Tue, 24 Jan 2023 13:53:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234295AbjAXSwh (ORCPT ); Tue, 24 Jan 2023 13:52:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45327485B3; Tue, 24 Jan 2023 10:52:13 -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 A174E61336; Tue, 24 Jan 2023 18:52:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60217C4339E; Tue, 24 Jan 2023 18:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586332; bh=oM/na0j6KDMeNxgMkCt7OnT1CUcFT9V+mDvHYbo5v4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jEo/hJUabqEsYEfWYqvuU37DZczDnvT7Tl71Gv1+qOevulSwjqqwBW+t2EuNiOSVp Grft20xPVgVdqjmMuKrn3CnvZMNzmD9c1ErpeVvd3ZIBBQBIWxqeCh81npymd9onz7 4HNgGVElba0Lbu+t1LVroZn+N4+dm9NWFSIZsf55bJxKSWMuM7dgEkfjhNsIY3GRE6 M0+XvQiWSpvFtim5VCXnBmc2szm1TzAsQQ8+WcFGAprA5NsPG2VbZpMRvUTyKZvYt1 LU8Afue6V6Kt19dOLDVhKzeaUcUOaDI+H79SEOz/udNTX5wQNeAR5GW7ovkaKBcrid 6q0IE3zyKjnJA== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Andrew Morton , Baolin Wang , "Jason A. Donenfeld" , Eric Biggers , Huang Ying , Petr Mladek , tangmeng , "Guilherme G. Piccoli" , Tiezhu Yang , Sebastian Andrzej Siewior , linux-doc@vger.kernel.org, Luis Chamberlain Subject: [PATCH 5.15 17/20] panic: Introduce warn_limit Date: Tue, 24 Jan 2023 10:51:07 -0800 Message-Id: <20230124185110.143857-18-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931138614199061?= X-GMAIL-MSGID: =?utf-8?q?1755931138614199061?= From: Kees Cook commit 9fc9e278a5c0b708eeffaf47d6eb0c82aa74ed78 upstream. Like oops_limit, add warn_limit for limiting the number of warnings when panic_on_warn is not set. Cc: Jonathan Corbet Cc: Andrew Morton Cc: Baolin Wang Cc: "Jason A. Donenfeld" Cc: Eric Biggers Cc: Huang Ying Cc: Petr Mladek Cc: tangmeng Cc: "Guilherme G. Piccoli" Cc: Tiezhu Yang Cc: Sebastian Andrzej Siewior Cc: linux-doc@vger.kernel.org Reviewed-by: Luis Chamberlain Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20221117234328.594699-5-keescook@chromium.org Signed-off-by: Eric Biggers --- Documentation/admin-guide/sysctl/kernel.rst | 10 ++++++++++ kernel/panic.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index d6f1d3892e71e..48b91c485c993 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -1494,6 +1494,16 @@ entry will default to 2 instead of 0. 2 Unprivileged calls to ``bpf()`` are disabled = ============================================================= + +warn_limit +========== + +Number of kernel warnings after which the kernel should panic when +``panic_on_warn`` is not set. Setting this to 0 disables checking +the warning count. Setting this to 1 has the same effect as setting +``panic_on_warn=1``. The default value is 0. + + watchdog ======== diff --git a/kernel/panic.c b/kernel/panic.c index bf0324941e433..604d7ad77042e 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -57,6 +57,7 @@ bool crash_kexec_post_notifiers; int panic_on_warn __read_mostly; unsigned long panic_on_taint; bool panic_on_taint_nousertaint = false; +static unsigned int warn_limit __read_mostly; int panic_timeout = CONFIG_PANIC_TIMEOUT; EXPORT_SYMBOL_GPL(panic_timeout); @@ -86,6 +87,13 @@ static struct ctl_table kern_panic_table[] = { .extra2 = SYSCTL_ONE, }, #endif + { + .procname = "warn_limit", + .data = &warn_limit, + .maxlen = sizeof(warn_limit), + .mode = 0644, + .proc_handler = proc_douintvec, + }, { } }; @@ -195,8 +203,14 @@ static void panic_print_sys_info(void) void check_panic_on_warn(const char *origin) { + static atomic_t warn_count = ATOMIC_INIT(0); + if (panic_on_warn) panic("%s: panic_on_warn set ...\n", origin); + + if (atomic_inc_return(&warn_count) >= READ_ONCE(warn_limit) && warn_limit) + panic("%s: system warned too often (kernel.warn_limit is %d)", + origin, warn_limit); } /** From patchwork Tue Jan 24 18:51:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319138wrn; Tue, 24 Jan 2023 10:54:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXsTDQQ5eqBtyl4GJPKTezvQFUrlHzoZIYLy0HLYHnWHyFCirJGHtvfZnlwjba6IUkNUZ5T8 X-Received: by 2002:a05:6a20:4407:b0:b8:5835:2573 with SMTP id ce7-20020a056a20440700b000b858352573mr42150084pzb.60.1674586446854; Tue, 24 Jan 2023 10:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586446; cv=none; d=google.com; s=arc-20160816; b=pCZibZgUhwtP16F3XT+ePv19eUt+mnCcuRNPmESITWDzix4dA1yvm5gIEzO4RRIGdj i5uLPbfPgih7QH7FRkVXHTVswtyMvQQsN0DMOgBid251ErzCCc8dozSG18XP0S8EaWch ENayKt5zz/AF+RlUSUTW2wTboq+atbWUBC8oy6VQaI5+QIkxgoeJQArXv3x//qudz0TC Fc/Ry08sfQXOpmjhhIKlUpizXhTgJAeNrvZM7EEHnXLTPzn6XnKIob6g2st8QRYHWnjR JVToYjtBdAJYNmibNLO67s1MFE/z2cCWz11n4p6kAs5IDV3jDl9j9k64yXHuQaXDvS2O E9IA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fi2E6IlnA1c72bh39cdK8DiYGFCrCRAn3lHGH1gAzRU=; b=vELyoC1gw0QvMpw4SwNlUpFV1qw9IMEjIzlcRFmUZ0L+NS8ugPelt+R75A/3qvdyyf kVPpuSrtPydnggCGJd1PO/5lY3XgwrmdXmYqPQvE79sTA0v2aiysUvVvb6vNWvWlFNJJ JTHg4eYGlLvRU/1HqreCycgbgXgpj08rRc9EsxjFgUCqhFhQld1I5sPNh1XBvLuknXMt 5emO1AnjyQiH3yo7My8G9eBho2sGo0LvKt56olMNa3SkIXZ3m4LJG75RdB8yG5SqTMht +yUBljbWD7xy6Q43b6RcwbKTFJU06n+BtQ3jx77fQrpT5HikESreEtwTyYSVXqbvYJFH JJVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="vOoh/QbQ"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l69-20020a638848000000b004d0066c7156si2860785pgd.588.2023.01.24.10.53.55; Tue, 24 Jan 2023 10:54:06 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="vOoh/QbQ"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234512AbjAXSxJ (ORCPT + 99 others); Tue, 24 Jan 2023 13:53:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbjAXSwi (ORCPT ); Tue, 24 Jan 2023 13:52:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAE5C4DE29; Tue, 24 Jan 2023 10:52:13 -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 4CCFE6132D; Tue, 24 Jan 2023 18:52:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37298C433A8; Tue, 24 Jan 2023 18:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586332; bh=uJNdiP3sP+wXY0anj6obLD3qCdsvZCuU0Y8rZXFqjFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vOoh/QbQ5/sWEoKnIz+uzZa+qLghMayxPEZ6LQmVhLHnRAf4EJmpjlgFbp5tmtyf0 J0Y4dormEKBD7cp1avPPTPHjJOUcv2h278iN+62ZifiqNY7Q7Ac/2xB/8UnDG7BDzK 6Jn/a1SPL9tZMLuqDpOtZGhu6xbTFyjfqN2D8la98mOL/rM7QAl1S0mqcq6p8GxrnY FFczikOiuDIR6CofUTXsQ7Uj0WUvz/oyUyPPPSMd1eVVWB6zlYBloOBnwdcc7t6apL hXBry27DT/axW9fcG/HKfeMU/IFiXsKjsNJ4aqfKA63yaQIxCPWEBj11l1Dqp789D1 p2FOqyWzKZq4g== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Mladek , Andrew Morton , tangmeng , "Guilherme G. Piccoli" , Sebastian Andrzej Siewior , Tiezhu Yang , Luis Chamberlain Subject: [PATCH 5.15 18/20] panic: Expose "warn_count" to sysfs Date: Tue, 24 Jan 2023 10:51:08 -0800 Message-Id: <20230124185110.143857-19-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931157857343212?= X-GMAIL-MSGID: =?utf-8?q?1755931157857343212?= From: Kees Cook commit 8b05aa26336113c4cea25f1c333ee8cd4fc212a6 upstream. Since Warn count is now tracked and is a fairly interesting signal, add the entry /sys/kernel/warn_count to expose it to userspace. Cc: Petr Mladek Cc: Andrew Morton Cc: tangmeng Cc: "Guilherme G. Piccoli" Cc: Sebastian Andrzej Siewior Cc: Tiezhu Yang Reviewed-by: Luis Chamberlain Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20221117234328.594699-6-keescook@chromium.org Signed-off-by: Eric Biggers --- .../ABI/testing/sysfs-kernel-warn_count | 6 +++++ kernel/panic.c | 22 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-kernel-warn_count diff --git a/Documentation/ABI/testing/sysfs-kernel-warn_count b/Documentation/ABI/testing/sysfs-kernel-warn_count new file mode 100644 index 0000000000000..08f083d2fd51b --- /dev/null +++ b/Documentation/ABI/testing/sysfs-kernel-warn_count @@ -0,0 +1,6 @@ +What: /sys/kernel/oops_count +Date: November 2022 +KernelVersion: 6.2.0 +Contact: Linux Kernel Hardening List +Description: + Shows how many times the system has Warned since last boot. diff --git a/kernel/panic.c b/kernel/panic.c index 604d7ad77042e..4aef355e9a5d1 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #define PANIC_TIMER_STEP 100 @@ -105,6 +106,25 @@ static __init int kernel_panic_sysctls_init(void) late_initcall(kernel_panic_sysctls_init); #endif +static atomic_t warn_count = ATOMIC_INIT(0); + +#ifdef CONFIG_SYSFS +static ssize_t warn_count_show(struct kobject *kobj, struct kobj_attribute *attr, + char *page) +{ + return sysfs_emit(page, "%d\n", atomic_read(&warn_count)); +} + +static struct kobj_attribute warn_count_attr = __ATTR_RO(warn_count); + +static __init int kernel_panic_sysfs_init(void) +{ + sysfs_add_file_to_group(kernel_kobj, &warn_count_attr.attr, NULL); + return 0; +} +late_initcall(kernel_panic_sysfs_init); +#endif + static long no_blink(int state) { return 0; @@ -203,8 +223,6 @@ static void panic_print_sys_info(void) void check_panic_on_warn(const char *origin) { - static atomic_t warn_count = ATOMIC_INIT(0); - if (panic_on_warn) panic("%s: panic_on_warn set ...\n", origin); From patchwork Tue Jan 24 18:51:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319973wrn; Tue, 24 Jan 2023 10:56:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXusSUo6X+zqrq0u97WGeaco3yV9WZ3FGOTYpf2YZSOvjTC/XvjvB3Kxx5aBk90M7up2UcCH X-Received: by 2002:a62:6302:0:b0:582:848c:6281 with SMTP id x2-20020a626302000000b00582848c6281mr27144099pfb.2.1674586577708; Tue, 24 Jan 2023 10:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586577; cv=none; d=google.com; s=arc-20160816; b=rvYWeENtAUNcLFXnlnsiqhRf5rBu8EWWbZT058xu9eFEMAdj7QiTAuxf4I+6Pp3AEU zPx27Msu/tMkSKSCDMQF+X401vSprMrNlqJtPh54z7yxSeDzp1+mVV3tTo4wEPAHVPwJ RoHSF57qi9tUHNNmWZQ6ujF/rqWAhjpsRtyrLj8X5e2VxD+FFwG1uHXyFI9Q2mzodq5K pnR6GuyFiAyanM8iko5OuJtuv6/cEcT2GZ3tS4qLM1JKuwChRNNAb7QjwbQtbCF4ECNL cD8p74dQ57Hs1AOgEYSkHGxicO+nGBvzQMmtaiZ6NuIgSXDLKnSQO/iN40vS1yjkn2z6 /NsA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dPFanE1lIcKEepsAUbmGII6ZIu97CogO7PEHfoCPYow=; b=cn1dEAFPoHgDlsBLgPdjK5+HxlH1GOlfFuYG06dNhfQq6PsbL7Nmi/LrI9EgAfl/PU pP1aPaznLb2VYiWL+kt5pRfncQZy+9rKREJ20Mf30kFtFNNoF/Qy8r03WFA97KgxYreF k4F6h/z7v/VvbdK5XLaLALP5tUh9OrwC7Mf51rwIdhnXlmQUOD+BcLIB7iCJjdh3i0P1 BqYxmFsKojWMIhcfJ0HbCt50wpV6Zo/kIXIfTfb5adBnBLBjxZpV0q08wns4uEX9INf8 KCF5ix8qqdoippPn8dKw1FGxJ8F+BAPvT62ZeOiNAwGzUvdmrF5i7psVTaSbR7OHZS+l 2HzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iBXbf9Mb; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y63-20020a623242000000b0058a71b56a06si2896258pfy.130.2023.01.24.10.56.04; Tue, 24 Jan 2023 10:56:17 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iBXbf9Mb; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234384AbjAXSx2 (ORCPT + 99 others); Tue, 24 Jan 2023 13:53:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234377AbjAXSwo (ORCPT ); Tue, 24 Jan 2023 13:52:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7CE84F860; Tue, 24 Jan 2023 10:52:15 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7EB9EB816A9; Tue, 24 Jan 2023 18:52:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B5DC433D2; Tue, 24 Jan 2023 18:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586333; bh=jO10o07RAKyXXgWsy3XBxX0WTtST48LzT0RY2uOU2ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iBXbf9MbqH9tK8NOgoe1sVzbOdV0d3hZqVyka7hvfhBzTZhP11a9R1rA5Qozm5Y0Y 0HzJ9iHUg3eU5ZOATzW54bex1ebvW6UoijwsE+FPriVqrOgUKdbGX59t8a757vho7Z tWyQHqQrRfdINqBYZXgQgbBwJKmrJwZceSrOLgetlZXW1vov0sxYRhBgfhMtIGeNkJ 9b8rH0dLOI1BFig7OtQxIaB0oVRBK4lG0IRu2V3QQ0Isgl6eHVsekkjjcF3D+yJtli lnsOxvAdn+ZZ9WmbevSUThYXj/CuT1dgMKveTeWu+2de+PN4MZWuzedBKtVSoUvtX4 xaJhnbnQmfc3w== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot Subject: [PATCH 5.15 19/20] docs: Fix path paste-o for /sys/kernel/warn_count Date: Tue, 24 Jan 2023 10:51:09 -0800 Message-Id: <20230124185110.143857-20-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931295466388851?= X-GMAIL-MSGID: =?utf-8?q?1755931295466388851?= From: Kees Cook commit 00dd027f721e0458418f7750d8a5a664ed3e5994 upstream. Running "make htmldocs" shows that "/sys/kernel/oops_count" was duplicated. This should have been "warn_count": Warning: /sys/kernel/oops_count is defined 2 times: ./Documentation/ABI/testing/sysfs-kernel-warn_count:0 ./Documentation/ABI/testing/sysfs-kernel-oops_count:0 Fix the typo. Reported-by: kernel test robot Link: https://lore.kernel.org/linux-doc/202212110529.A3Qav8aR-lkp@intel.com Fixes: 8b05aa263361 ("panic: Expose "warn_count" to sysfs") Cc: linux-hardening@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Eric Biggers --- Documentation/ABI/testing/sysfs-kernel-warn_count | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-warn_count b/Documentation/ABI/testing/sysfs-kernel-warn_count index 08f083d2fd51b..90a029813717d 100644 --- a/Documentation/ABI/testing/sysfs-kernel-warn_count +++ b/Documentation/ABI/testing/sysfs-kernel-warn_count @@ -1,4 +1,4 @@ -What: /sys/kernel/oops_count +What: /sys/kernel/warn_count Date: November 2022 KernelVersion: 6.2.0 Contact: Linux Kernel Hardening List From patchwork Tue Jan 24 18:51:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 47833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2319411wrn; Tue, 24 Jan 2023 10:54:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXt/XXUSB1CioaUcwkLnb89c2LpfMZcIhs85ESzTAFoUrCAxd4C7p8uPIIoe1oaM4acG4wUx X-Received: by 2002:a17:90a:6391:b0:228:f576:b016 with SMTP id f17-20020a17090a639100b00228f576b016mr31650569pjj.25.1674586485468; Tue, 24 Jan 2023 10:54:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586485; cv=none; d=google.com; s=arc-20160816; b=IMxvEiVIyTMngeWWGcRwvprAyGM5kT5gzwx0CvdZello+TS3PD5SHTWPexpc7Hp9R2 PZWackLpAg+mv5LUdJ7nMJm9eDqggfNws+yxK//gfzQCDAATZVk1g0m9AFyMIuDlLa/R rDqoeN1C8VtIud4Lvih1/Sw1wWWcOjKEqROPVgE2JJicU6LwkKDFClB5z4mHwgE8Hr9O n1/pjDNOOgxLQ1sfq76UrOQsIkv9uaXmvvYsM6nVSJa+3Xz+CIwMzwYVHPJLiEdzujs1 uRIyfMcPg+e6zXbzq0CNIQrNqySYwsqpZllAi+vWW1ipVdOQPUC4PvcBOJmzrpbAyFlU AVXA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=73x0qz1MUQddlqrDlG/BbpP+uHy/ahYjZaVxgmFis4c=; b=RsZYJSt4cCkX7v/LbIQo0NPUgyQxaXOPELXBmUWWdhIK8lTh9EKmIEdUdv4s9SGbde Xqa+TOWSGMBdz3KwmSHsIHWV67HbZ8JnbnPjGjfUKAW3i17v4DLMZbc1Iu4MrZ9lXRcM KZkW5GnHI9iikZejztiV+5ixrDuP+3YBXqcXJmpLQIK8kkmBcqjYRokeTCRQfQSBKgJH g4MXY5J/C6lBedw1rtBxNy6bHNSDvfueILpJfAKcDUfQRf9OiCaxpLFXKNxlVNIx9sRU kA39D/yMblvBSTAxnCnujB50JFQ/+w9q+o35zeiwg556u4rV0NMLDraoN2FecL3b9HPr l3cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tUUF4HO0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i65-20020a636d44000000b004a0dd5c1e54si2814919pgc.108.2023.01.24.10.54.33; Tue, 24 Jan 2023 10:54:45 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tUUF4HO0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234343AbjAXSxN (ORCPT + 99 others); Tue, 24 Jan 2023 13:53:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233981AbjAXSwj (ORCPT ); Tue, 24 Jan 2023 13:52:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B52146710; Tue, 24 Jan 2023 10:52:14 -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 0F95E60FAC; Tue, 24 Jan 2023 18:52:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52190C433A7; Tue, 24 Jan 2023 18:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674586333; bh=7ngLw52uUuani2uGj/8r6J5RH0dFgQRDLQLIbTIDHD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tUUF4HO0FNK4sz9CZ3F4mBiXTNgy1UdkI6zgY8CbI3wY+2gwR5fJ85AumMBiMUKgV ZIQ3T9R1iLa5I9K2FCd84av0NvzxK85XhgDocEAphce7ErWMHLsvjj+7k6Xt4wG2kY SCSL5p22EEeor6T1zMYJJbENdsTDQvtIqByihx3vPKzChoLT/c6qLSDWz8gaeoNX17 X2/FJqR0iwt1FggsdIh6lJmlUp0AL2vaMtsAXbI0BM7KmzcLhMbcdFW9Un6aW/m9iv JZGrnf9Y6CtMMnEQjbw9N+ZHHJlgXR7RXFXqshmJiOu8evdzKKHaac/Vo2i1aiwrP3 OopGxQoFazbaQ== From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Petr Mladek , Andrew Morton , Luis Chamberlain , Marco Elver , tangmeng , Sebastian Andrzej Siewior , Tiezhu Yang , Peter Zijlstra Subject: [PATCH 5.15 20/20] exit: Use READ_ONCE() for all oops/warn limit reads Date: Tue, 24 Jan 2023 10:51:10 -0800 Message-Id: <20230124185110.143857-21-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230124185110.143857-1-ebiggers@kernel.org> References: <20230124185110.143857-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1755931198443750698?= X-GMAIL-MSGID: =?utf-8?q?1755931198443750698?= From: Kees Cook commit 7535b832c6399b5ebfc5b53af5c51dd915ee2538 upstream. Use a temporary variable to take full advantage of READ_ONCE() behavior. Without this, the report (and even the test) might be out of sync with the initial test. Reported-by: Peter Zijlstra Link: https://lore.kernel.org/lkml/Y5x7GXeluFmZ8E0E@hirez.programming.kicks-ass.net Fixes: 9fc9e278a5c0 ("panic: Introduce warn_limit") Fixes: d4ccd54d28d3 ("exit: Put an upper limit on how often we can oops") Cc: "Eric W. Biederman" Cc: Jann Horn Cc: Arnd Bergmann Cc: Petr Mladek Cc: Andrew Morton Cc: Luis Chamberlain Cc: Marco Elver Cc: tangmeng Cc: Sebastian Andrzej Siewior Cc: Tiezhu Yang Signed-off-by: Kees Cook Signed-off-by: Eric Biggers --- kernel/exit.c | 6 ++++-- kernel/panic.c | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index f6c85101dba0f..80efdfda6662b 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -930,6 +930,7 @@ void __noreturn make_task_dead(int signr) * Take the task off the cpu after something catastrophic has * happened. */ + unsigned int limit; /* * Every time the system oopses, if the oops happens while a reference @@ -941,8 +942,9 @@ void __noreturn make_task_dead(int signr) * To make sure this can't happen, place an upper bound on how often the * kernel may oops without panic(). */ - if (atomic_inc_return(&oops_count) >= READ_ONCE(oops_limit) && oops_limit) - panic("Oopsed too often (kernel.oops_limit is %d)", oops_limit); + limit = READ_ONCE(oops_limit); + if (atomic_inc_return(&oops_count) >= limit && limit) + panic("Oopsed too often (kernel.oops_limit is %d)", limit); do_exit(signr); } diff --git a/kernel/panic.c b/kernel/panic.c index 4aef355e9a5d1..47933d4c769b6 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -223,12 +223,15 @@ static void panic_print_sys_info(void) void check_panic_on_warn(const char *origin) { + unsigned int limit; + if (panic_on_warn) panic("%s: panic_on_warn set ...\n", origin); - if (atomic_inc_return(&warn_count) >= READ_ONCE(warn_limit) && warn_limit) + limit = READ_ONCE(warn_limit); + if (atomic_inc_return(&warn_count) >= limit && limit) panic("%s: system warned too often (kernel.warn_limit is %d)", - origin, warn_limit); + origin, limit); } /**