From patchwork Thu Feb 2 04:42:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37446wrn; Wed, 1 Feb 2023 20:45:17 -0800 (PST) X-Google-Smtp-Source: AK7set/WbYAxppP0YXU4mJbF1Vo27/XaAx0RudnTW7XkqU7qE7qGxIo7jQaltA8yuOcSSr+ZplaF X-Received: by 2002:a17:90a:199e:b0:22c:978e:8a6d with SMTP id 30-20020a17090a199e00b0022c978e8a6dmr5109250pji.33.1675313117187; Wed, 01 Feb 2023 20:45:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313117; cv=none; d=google.com; s=arc-20160816; b=VSRsaW88RFT3RFA7Mjv+vG6P0Xj61UNVASpt3GWComA4R7cChXiuZb0/WSQzF4C2G1 PJ4FIh52dJBgq/AyzYg7lFXJ2uxNbeWfgfYiHdMO7XmV6Cl9Wwlzq6RGxj2oyz9Awq2q FK8eaAcdfO5onewrW39elRkNlzOpgVTuJSpdwR8XT6V430yaIt+foYFv/h80rcbLFBdw nGZhPiuSsH4h8ZZXU+3x2GrP9vkc4jiFQV200iN7yI4nCdA0w2VQpvZEO2uLi7ZQDCLN h643UxFzEY5Wki1JEIdp4xpHAy/QiCnm7HRHYKA8AfvN2YzlzQsO0SPXYtpdG17BI/Hq 00kw== 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=mbJ4s3fXwXr+i50aaRM4rr2x+6tSA649zeRDBU+hr7Y=; b=YqGpW+KX/ccJ6tW5GZFkrc8QmJVFUWoclIqdwERMeVRENTriv2X7hTJ8O1eG/9GYOj X6UuMQE/OvXIxHwTBbvUgk/n/5QBIjYWIlcf7jZVCP3x47olxntGZRHk5/fmfs6ZPWjP SR9nMdvndF6SCj26AzHLv2srBf9YxXPmsSo7/sADJxL7ByEx2xUGhQPC5YdmzSdJ7CgA GhAcgZHgKTwQGhc7eawDffxk+3fBXAES3RkCDQxnq6giHCAccuEU1BkQubkUNjp3uUZV XilnbwWLO3lBywsxzpmWa/iL9qPI2mA4gYcL2+nomUSVibOkiqVpwX00QLnE2U8uW4O7 it5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AhS5ZJEf; 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 v5-20020a17090a898500b00229c28277c6si3668725pjn.41.2023.02.01.20.44.59; Wed, 01 Feb 2023 20:45: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=AhS5ZJEf; 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 S229916AbjBBEoJ (ORCPT + 99 others); Wed, 1 Feb 2023 23:44:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231479AbjBBEoD (ORCPT ); Wed, 1 Feb 2023 23:44:03 -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 7BA867A485; Wed, 1 Feb 2023 20:43:49 -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 92706B82413; Thu, 2 Feb 2023 04:43:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4068C4339C; Thu, 2 Feb 2023 04:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313027; bh=0pPNl/M2Y5WbPOCwmAQ+q6dUpUoy+qyo/FH1zUoQKPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AhS5ZJEfx/CNlhqA5lSVqlrJL9oW8hE5i6yKqV+//t8NxW5PPQyEjasP4vbEsSEP4 SCKGiweuJ9Gn4kiqFGkmYXZVxM5YuBWuaznD6IhHLGXQVfsR1SLnqWxwPaKycKh/E4 QxCoCkB4mg1rA9PtYfQGaulIuFsvYN/UoyS3Jvb/yWFVXyTwlxD1D6+kOTE6ej0B54 Wb3qCFan6AiNMn4mQCFGXbjqFvXcn9KYAhEww71Np02pPcOjuRpSPJRfoEoUp+V3jt f97zb4S6U5tSDgNZxe4ueedU6Gkxj9iNVUIWiQNRP3zN898eM0C0gf3kzX55T+XKtU 8/4CV6bSN3m+A== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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 , Greg Kroah-Hartman , 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.4 01/17] sysctl: add a new register_sysctl_init() interface Date: Wed, 1 Feb 2023 20:42:39 -0800 Message-Id: <20230202044255.128815-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693126747501742?= X-GMAIL-MSGID: =?utf-8?q?1756693126747501742?= 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 d80989b6c3448..f4264dd4ea31b 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "internal.h" static const struct dentry_operations proc_sys_dentry_operations; @@ -1397,6 +1398,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 6df477329b76e..aa615a0863f5c 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -208,6 +208,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) extern struct ctl_table sysctl_mount_point[]; From patchwork Thu Feb 2 04:42:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37486wrn; Wed, 1 Feb 2023 20:45:24 -0800 (PST) X-Google-Smtp-Source: AK7set9K9xCmytKHNKfz99+3i8XtuCADgJeqTY8ck2rC7XWypL1Oh/rUst6D5VX/TB2V4Ktkv3t/ X-Received: by 2002:a05:6a00:1c96:b0:593:893f:81d7 with SMTP id y22-20020a056a001c9600b00593893f81d7mr4029703pfw.16.1675313123923; Wed, 01 Feb 2023 20:45:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313123; cv=none; d=google.com; s=arc-20160816; b=zZGrLx7kA3sqJqweNxBpYcY4yNetEEC/wIb+hhSJ9VPGBCbJZZCXYWnkUAew6xY3BJ 0L3o6knnSw6+tTGHt8IAAN2ukryBFxV1UJjYkjYnWVriRuBzu6XWwGZHx30OqjFS5jA1 WVGhzwXbDRdz8bw5NOXMHanBZeeTzcNpEFXq3Kcm70wKuMutQg0/0JMZa/A0HjvJU7M4 2yKR3dmFuLyqCc/7qVuwkDGHBnfrzuKy3sF6YNC5vjOWjgbhUuMUZh2H8sMqP0plJpQT SE1DIg8QW+JZB7s1n2neCtXcZFz4dbntzpETBOZGHqQT5mtkvxvIcNMHiD+R38xuJrtA i8aw== 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=eHNbL3QGejSDk0ZVsjo3MAQ17xDn3FHJFW2tEWABkTk=; b=zPo8M2TNwLWbYluhegSi0ssvpXhuOFn/dPUYIiYaCNBq1QUSm+CHX52x7YICJNl2qi B5hIuHjRZwnly3sRcCX3qyquG09O6Wly+zMU/gxuCrKLAt+Sun9wb/izDRmLxI+kMVtB HC3cjv8xOS/Gv5l+rNiiWrmxCn1JkNgacCoABIVNhOvYIARxpBth9Oskkkq98rGCD8z1 zE/4W0D4Ft4ikwGKiEvdCMldc01h/TdlUYNO1lyEjqyG51VhkGMYGgywbmnCO/OJEB+Q zusDIqq1RqKWXbJnXCPM4tVDLnqbV2cCJFUqHFReJopzq7HBz/57QFxc0/fFVOD4iDxd Ldmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YV6ouvdV; 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 201-20020a6215d2000000b005615ef4cfccsi21125789pfv.185.2023.02.01.20.45.08; Wed, 01 Feb 2023 20:45:23 -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=YV6ouvdV; 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 S231540AbjBBEoO (ORCPT + 99 others); Wed, 1 Feb 2023 23:44:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231485AbjBBEoF (ORCPT ); Wed, 1 Feb 2023 23:44:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BDB87C725; Wed, 1 Feb 2023 20:43:50 -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 3F5D4B8241A; Thu, 2 Feb 2023 04:43:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63371C433A1; Thu, 2 Feb 2023 04:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313027; bh=FwUnERZE15TbKqhpyOVhsiv4XwkhT87iVqe38AaX1Pk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YV6ouvdV6PTKZoxGg1HEC9mBAcsuctU3hivQDWY9PWI3fP5qNSFvOaWTasl5nnb4n D84ATPVB9UOch3jvfEDYD9GbRqTP17aGOJy5u3aC0xZnsvp9WYDjzhEtK+QjMy8gSY rkJ9Gx0Bk9RG2kBX3jv/ejqIxdtLfsDaXe9kCjq3EHBiMAW0achIhlLZKPY2dqZvg7 UfXHXINVMbla+HPtP6ghY/MTghkAZ4CV7IorjFkp4vuak8VgU7HGWC799JEsOVvrH1 KMxocASJaw6zX2p9j3YLhJQSGZiLmCEx9ulRHiApojl26xXCBQgKhRdbOe6REEYRNd qENz8Z4aTvEJQ== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 02/17] panic: unset panic_on_warn inside panic() Date: Wed, 1 Feb 2023 20:42:40 -0800 Message-Id: <20230202044255.128815-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693134262713312?= X-GMAIL-MSGID: =?utf-8?q?1756693134262713312?= 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 f470a038b05bd..5e2b764ff5d54 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -173,6 +173,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 @@ -571,16 +581,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, if (args) vprintk(args->fmt, args->args); - 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"); - } print_modules(); From patchwork Thu Feb 2 04:42:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37500wrn; Wed, 1 Feb 2023 20:45:27 -0800 (PST) X-Google-Smtp-Source: AK7set9lHOB9cdScdKlvSMdksFZIbbR3yR2zobZ2UOUoYCCVi/eC5r9oqK0Y4CB5F3I2sJhccU1J X-Received: by 2002:a05:6a21:3405:b0:b6:d25:9a8b with SMTP id yn5-20020a056a21340500b000b60d259a8bmr4951744pzb.28.1675313126874; Wed, 01 Feb 2023 20:45:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313126; cv=none; d=google.com; s=arc-20160816; b=umQtn+LtQYG80k/z794yoTQ9sCPkQ1LFNbmU8PwdmUx7SAm7dPdWOjm+Fdqvo5nozz YUvMSXGTvh4NIyLs0dYIsCYAtGpeDfcHyVt9aanAd0DEK6rEBPaJsB6rng8GFoRQM7sq bK0gL6u8RE3hkp+k4uSxJ/zFcnv8JtPVCbUy1UI0nUbMtxm5owpQuxKyWveyqjIFPk4f geXclhPFrut6aiDQyT9tgxd/68kyWGKhW7Nwl+yOlbkxD4rs6d7Yu3pKJTiJUUctG8jv +6Zw7xsSaX2dNM8MnRb8dquufOaCKjUxVYCq4k6S8jwxrv4voSYQ2oV5jsxJ/1ZPtwBW d5Rg== 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=9wQXK2kXI5VmOR+Loj/bIsNMp+eWqMjlHgfHUNYtYCg=; b=o/nwnuIRMrSWTS1EDYWwGHgsZnudnJ+pqFqaJK80bB1j6iza+3puixrilFvJzJv27V 22UrycirSsIQtGLvmlltVHi7LHTvllVNcU9EaKDltvwXkHP3MKK5y8ndi4yKAvlh+60s Q/UlGebEfSoAPXNbvd36LKwjIZzFnzP8H+U8rD9EsBaUZy02rIXoDJ/xDBiud+08WUT5 xtpgmpMw4zfGH/UBtVKpkZ9fwQyvLuGDmMDotkST+sFeEzHLnaIwTb87HxdolKDa+QjU uPff+6Uwtha/W+cdP/uCiJ5V/JHDLMi9bHrmPGA5TImqZwTGucZvYVD44tcwSbIlkZ8K kobQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FIqlkGAj; 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 bt20-20020a632914000000b004f1ee7825fesi908924pgb.469.2023.02.01.20.45.09; Wed, 01 Feb 2023 20:45:26 -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=FIqlkGAj; 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 S231544AbjBBEoV (ORCPT + 99 others); Wed, 1 Feb 2023 23:44:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjBBEoF (ORCPT ); Wed, 1 Feb 2023 23:44:05 -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 7D91E7C73F; Wed, 1 Feb 2023 20:43:51 -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 04B1AB8241B; Thu, 2 Feb 2023 04:43:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E379C4339E; Thu, 2 Feb 2023 04:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313028; bh=3jGoUYb5ZXXZkAA7E72JChHDGyEWYUsA360wTbKvQOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FIqlkGAjxOmAJ97Zovh+TPaze9M0KI4n65AH/v7tUvMHAYqucSztv9HtRFnLwcBrU 3WqsXIsi/KPRVzGBNa6ZFHiFbiU6W31p2Fg1/G9ZHszwR2F5nmTwwPTmnvtjl5UME8 aR+umkpiBFHZPrINcn33lds233qs08T2QoKpgN8VfDwS2CC2bNuOgqoFvPQerf23qW sCnp0aYHz0bIBDyNK2LzqD1EbOXZa1JksNWGTqxpXvbTZWA45QJB8q8DQQpEoIWAnM 8mGcqfjNNNogf7BbhshMK4etUtq7mAxBxfptwNFVZLxb1iUurzzxKsKklFpZ+KCDD0 3yd4+seZdW77w== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Ryabinin , Dmitry Vyukov , Ingo Molnar , Juri Lelli , Patricia Alfonso , Peter Zijlstra , Shuah Khan , Vincent Guittot , David Gow , Andrew Morton , Andrey Konovalov , Brendan Higgins , Linus Torvalds Subject: [PATCH 5.4 03/17] mm: kasan: do not panic if both panic_on_warn and kasan_multishot set Date: Wed, 1 Feb 2023 20:42:41 -0800 Message-Id: <20230202044255.128815-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693137098164421?= X-GMAIL-MSGID: =?utf-8?q?1756693137098164421?= From: David Gow commit be4f1ae978ffe98cc95ec49ceb95386fb4474974 upstream. KASAN errors will currently trigger a panic when panic_on_warn is set. This renders kasan_multishot useless, as further KASAN errors won't be reported if the kernel has already paniced. By making kasan_multishot disable this behaviour for KASAN errors, we can still have the benefits of panic_on_warn for non-KASAN warnings, yet be able to use kasan_multishot. This is particularly important when running KASAN tests, which need to trigger multiple KASAN errors: previously these would panic the system if panic_on_warn was set, now they can run (and will panic the system should non-KASAN warnings show up). Signed-off-by: David Gow Signed-off-by: Andrew Morton Tested-by: Andrey Konovalov Reviewed-by: Andrey Konovalov Reviewed-by: Brendan Higgins Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Ingo Molnar Cc: Juri Lelli Cc: Patricia Alfonso Cc: Peter Zijlstra Cc: Shuah Khan Cc: Vincent Guittot Link: https://lkml.kernel.org/r/20200915035828.570483-6-davidgow@google.com Link: https://lkml.kernel.org/r/20200910070331.3358048-6-davidgow@google.com Signed-off-by: Linus Torvalds Signed-off-by: Eric Biggers --- mm/kasan/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 621782100eaa0..a05ff1922d499 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -92,7 +92,7 @@ static void end_report(unsigned long *flags) pr_err("==================================================================\n"); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); - if (panic_on_warn) + if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) panic("panic_on_warn set ...\n"); kasan_enable_current(); } From patchwork Thu Feb 2 04:42:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37668wrn; Wed, 1 Feb 2023 20:45:59 -0800 (PST) X-Google-Smtp-Source: AK7set98oJwTZDGfrECLGk31U58xY/uRzP8hDmr5Ofd83ls7Al+mvbT4HBCNq+6en5pC0eNkPsmw X-Received: by 2002:a17:90b:3907:b0:22c:7471:eca5 with SMTP id ob7-20020a17090b390700b0022c7471eca5mr5026108pjb.42.1675313159141; Wed, 01 Feb 2023 20:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313159; cv=none; d=google.com; s=arc-20160816; b=Kqb51hpvN4O36joyYl3xflC1lJLdu+AhdhJPJlP9P+zQ6Xy+Y6jamNQW9lu86HE7Ek eVlsjkGjyPBkQtHEssaghNN2Yqwq+JaUJmcfVElaF/X+znaXk0P6Iqv3b1rsFasaIFTa Akwl9v0Ii8UlNxReNL5R2jYqz6rNgf+4mK5ZDqKgTMdcBaUz0qX2OQ3JjmliI1OMVm86 L3CLC3JL2qGNuG9f585rxxVL5iWcQt9GMifUzD3C3Kggo3skuEyipsJDuSLJnoxZmQ4h wDJtMlHZldPAQpBRu1CjApX8Zk9bITxGQXw+tO349VNqzGGik8biZTGHratCSkB1PJGE Csng== 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=tQsWndkKB7GHx0IehG8EwFtjDLAateZl9EFXELNYO7c=; b=a1S2mnAK2XhKyQxBGvWpHrSCG2iFAeDIx43mDdKbw5I9mhZVW7NJbR0SxsrvcKUHRB iFIJD9SpuZIJHdbsHucQyyl6Uy2aCMxYdkvR+Ys0p7BeGYMw/dhg1A1khXqXEYdC3d2w YFo10gVRP3mJEcDS/vDJEFvOPJ1TUcifd4PDe5aA0zsNUAwu5tc00BAYkLSuqX4Fuugs +C+xLWWYqRgA0ew4vSoSLuoVaI1bukW1wguBUyw2TqU2nPoPu6gAiLkDGHEhVTVgIW2J ZkMP8xefeApeixFbz4vTl2rgFMXgSrhxfGkXeSXEKuVQnfYHMWWMg45MrIr+yM+UVP3A PeFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eWQcJezl; 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 pg1-20020a17090b1e0100b00229008bcf6bsi4034456pjb.16.2023.02.01.20.45.45; Wed, 01 Feb 2023 20:45: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=eWQcJezl; 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 S231551AbjBBEpD (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231542AbjBBEoO (ORCPT ); Wed, 1 Feb 2023 23:44:14 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A0379F22; Wed, 1 Feb 2023 20:43:52 -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 CE5A6CE2773; Thu, 2 Feb 2023 04:43:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0084C433A0; Thu, 2 Feb 2023 04:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313029; bh=15/R4vHRcJ4+mVME8lXm1dPwIUwCjOjTWOMBudOQmvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eWQcJezlubbRS2Ni1NZgg3F9BLTuNYLbPzaSvY5XZuPLh/G7pqQQYoqnF1yX3DSvl fL5hc6s2X2BBg5NiyuAaKODDEFOzsLjPNNjFjmP7L9Znj3wEAeNHBbPLF4Wra7NDFf 3GgteNgfdnlBIpuoS/ctnEK3eQ/jBA5SPKX5NmmHIv1zs2zSW4MGWU7TsfPG+dAOOc lyUhUhPbC8lA0afqIT8HVv3a7lztkVncKQHAi5rPT3/6U8EOPE7tkKrLVnLra3cKfP i/CtTxq4WZufrB4kkV2vC00NbduaA+YOw86XQBbZtAki99BesiGdKxR96OxCeXOufu STgkpWYXlwEtQ== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , Kees Cook , SeongJae Park , Seth Jenkins , Jann Horn , "Eric W . Biederman" , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5.4 04/17] exit: Add and use make_task_dead. Date: Wed, 1 Feb 2023 20:42:42 -0800 Message-Id: <20230202044255.128815-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693170935585640?= X-GMAIL-MSGID: =?utf-8?q?1756693170935585640?= 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/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 | 2 +- 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 ++- 38 files changed, 59 insertions(+), 52 deletions(-) diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index f6b9664ac5042..f87d8e1fcfe42 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 741e61ef9d3fe..a86286d2d3f3f 100644 --- a/arch/alpha/mm/fault.c +++ b/arch/alpha/mm/fault.c @@ -206,7 +206,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 207ef9a797bd4..03dfeb1208431 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -341,7 +341,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 bd0f4821f7e11..d623932437208 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -124,7 +124,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 4e3e9d9c81517..a436a6972ced7 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -202,7 +202,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 2a7339aeb1ad4..a8e9c98147a19 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -296,7 +296,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); } static void __do_kernel_fault(unsigned long addr, unsigned int esr, 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 63715cb90ee99..af7562907f7fa 100644 --- a/arch/csky/kernel/traps.c +++ b/arch/csky/kernel/traps.c @@ -85,7 +85,7 @@ void die_if_kernel(char *str, struct pt_regs *regs, int nr) pr_err("%s: %08x\n", str, nr); show_regs(regs); add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); - do_exit(SIGSEGV); + make_dead_task(SIGSEGV); } void buserr(struct pt_regs *regs) diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c index e47a9e0dc278f..a284c126f07a6 100644 --- a/arch/h8300/kernel/traps.c +++ b/arch/h8300/kernel/traps.c @@ -110,7 +110,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 fabffb83930af..a8d8fc63780e4 100644 --- a/arch/h8300/mm/fault.c +++ b/arch/h8300/mm/fault.c @@ -52,7 +52,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 69c623b14ddd2..bfd04a388bcac 100644 --- a/arch/hexagon/kernel/traps.c +++ b/arch/hexagon/kernel/traps.c @@ -221,7 +221,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 2a40268c3d494..d9ee3b186249d 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 c2f299fe9e04a..7f8c49579a2c2 100644 --- a/arch/ia64/mm/fault.c +++ b/arch/ia64/mm/fault.c @@ -272,7 +272,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 344f93d36a9a0..a245c1933d418 100644 --- a/arch/m68k/kernel/traps.c +++ b/arch/m68k/kernel/traps.c @@ -1139,7 +1139,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 e9b1d7585b43b..03ebb67b413ef 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 cf99c411503e3..6d3a6a6442205 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 749089c25d5e6..5a491eca456fc 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -415,7 +415,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 62bdafbc53f4c..26c62d5a55c15 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 f4d386b526227..f6648845aae76 100644 --- a/arch/nds32/kernel/traps.c +++ b/arch/nds32/kernel/traps.c @@ -184,7 +184,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); @@ -288,7 +288,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); } @@ -299,7 +299,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); } @@ -326,7 +326,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 486db793923c0..8e192d6564261 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 932a8ec2b520e..2804852a55924 100644 --- a/arch/openrisc/kernel/traps.c +++ b/arch/openrisc/kernel/traps.c @@ -218,7 +218,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 2a1060d747a5d..37988f7f3abcb 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 ecfa460f66d17..70b99246dec46 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -246,7 +246,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); diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index ae462037910be..c28d4debf5926 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -57,7 +57,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 247b8c859c448..1cfce62caa119 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -189,7 +189,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs) (addr < PAGE_SIZE) ? "NULL pointer dereference" : "paging request", addr); die(regs, "Oops"); - do_exit(SIGKILL); + make_task_dead(SIGKILL); /* * We ran out of memory, call the OOM killer, and return the userspace diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c index 34bdc60c0b11d..2100833adfb69 100644 --- a/arch/s390/kernel/dumpstack.c +++ b/arch/s390/kernel/dumpstack.c @@ -210,5 +210,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 0a487fae763ee..d8951274658bd 100644 --- a/arch/s390/kernel/nmi.c +++ b/arch/s390/kernel/nmi.c @@ -179,7 +179,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); } } EXPORT_SYMBOL_GPL(s390_handle_mcck); diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c index 63cf17bc760da..6a228c00b73f4 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 4ceecad556a9f..dbf068ac54ff3 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 f2b22c496fb97..17768680cbaeb 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c @@ -2564,9 +2564,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 2d837fb54c31b..740df9cc21963 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -1659,13 +1659,13 @@ ENTRY(async_page_fault) END(async_page_fault) #endif -ENTRY(rewind_stack_do_exit) +ENTRY(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 -END(rewind_stack_do_exit) +END(rewind_stack_and_make_dead) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index c82136030d58f..bd7a4ad0937c4 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1757,7 +1757,7 @@ ENTRY(ignore_sysret) END(ignore_sysret) #endif -ENTRY(rewind_stack_do_exit) +ENTRY(rewind_stack_and_make_dead) UNWIND_HINT_FUNC /* Prevent any naive code from trying to unwind to our caller. */ xorl %ebp, %ebp @@ -1766,5 +1766,5 @@ ENTRY(rewind_stack_do_exit) leaq -PTREGS_SIZE(%rax), %rsp UNWIND_HINT_REGS - call do_exit -END(rewind_stack_do_exit) + call make_task_dead +END(rewind_stack_and_make_dead) diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index e07424e19274b..e72042dc9487c 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -326,7 +326,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) { @@ -361,7 +361,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 4a6c495ce9b6d..16af8e514cb3b 100644 --- a/arch/xtensa/kernel/traps.c +++ b/arch/xtensa/kernel/traps.c @@ -543,5 +543,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 36f3011ab6013..6f33a07858cf6 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -51,6 +51,7 @@ extern int sched_fork(unsigned long clone_flags, 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 ece64771a31f5..6512d82b4d9b0 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -864,6 +864,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 ccf5580442d29..14be7d261ae7a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -136,6 +136,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", @@ -143,7 +144,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" "cpu_bringup_and_idle", }; From patchwork Thu Feb 2 04:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37630wrn; Wed, 1 Feb 2023 20:45:51 -0800 (PST) X-Google-Smtp-Source: AK7set+vzH1TDYkojlXUHdjVEYjyYEtwKyS5aSsCPBkSDN/9UTG4iKITN3SiBGLmKy56oZmMr+p5 X-Received: by 2002:a05:6a20:e18c:b0:bd:8b67:4e6b with SMTP id ks12-20020a056a20e18c00b000bd8b674e6bmr4817744pzb.19.1675313151054; Wed, 01 Feb 2023 20:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313151; cv=none; d=google.com; s=arc-20160816; b=UC7l2HVCP4HytvYaovABxVOTMubNyRugVnO/9QQveNC1Wnt73VzHjc+kKLJDWOttVQ 0ObbsYpPpZOl+3IXigAjfAtf/OheewayOfio1CH/xLPo0YVawZ6PnEC00iUQUCxlZhIK 2ltfirb6e+YZPWRDGGVpXU0B0baDEKHZWFEcFX16Wa35BDEFjQv8u2I/RgxL+qVri5HD Y0JGCdKbllK+55FdPHIb/BOTZeg16ziYYV4z4JfO4d5sFLQc9hfAOPhStFlF5Mny/XF2 BmM7RSsgkM4oWHrZ3oXu6LdjMwfbCh/wh7uFOz+tVzcUZd1stNHbvQstFSl2PML07Gkm wwdQ== 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=Xs84+DfhgpQjfEkxU9R++JEG0n26U3UK3FjvXz+xo2c=; b=k4IipyCImNhK2n2QdA50Y9Ww4m9qoQVRDd51+z9D5yNvezRCW9JSC+2h/xmjvRYUsq ANA7CdAib2xE9f5wMKvyzWQyIq3LNpFCQzY61SF4+N9Mqg1RU1e7hdKVtafZPrDhh8mP RVsY5Vp0cCM2CXCEdLxneGeuJk+BxGgBufPQFmumy+7WY/sVnWJcWTWalTMmVotQyVhn 5cg7tBS0NaxT66zgU5i+4xcSArZp0Uh26JngweVANqli13CJZG5BCMJTwqCeU7TLK5zr 7XRrsG+Dq7X0uA7D4N5nLzkkQ1z1aRFzotpkRxp6xje+095vUe672aWvuutF98z8dgD/ /YOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kz1lKWvL; 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 y24-20020a637d18000000b004ce0ead7aabsi20815947pgc.302.2023.02.01.20.45.36; Wed, 01 Feb 2023 20:45: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=kz1lKWvL; 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 S231743AbjBBEok (ORCPT + 99 others); Wed, 1 Feb 2023 23:44:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbjBBEoN (ORCPT ); Wed, 1 Feb 2023 23:44:13 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F29647A488; Wed, 1 Feb 2023 20:43:52 -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 44C26CE2774; Thu, 2 Feb 2023 04:43:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AF37C4339C; Thu, 2 Feb 2023 04:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313029; bh=RlJYO0lbBiRRVAS7XhsN7Zwl+KQ8V40jkMt3z+fFE5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kz1lKWvLC+IAwkHWiuA7r63D1dz/g0mDOUSL8A2p64cyWM/eX76tWeM3KN58NNsb5 6qjlXEswftJqGG6glbdQ0ilFIQ//9e+6KwS4q4kLBaMNQ3ff4LSU69RVS6S92/X0kk w0xdkhn16qvJd9/RJARoPscoFE1dwCNUAAzcPN7Dsr0Uv2iTwHL/UhdFPVfknI+df8 wHxz+fB0WL7gKJw7tXZ1O+vPMA6hf/86aTJEFL3pK+PCmaUiqsY/VIlXT57OL6vqa4 3rUzVtcl1LYC8+K/nULYpKDjgYKOpXjEmLOHsql1RdQIEYBNcNmN+FREKgBmTk3EPE rWjxjTbtnbTUg== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 05/17] objtool: Add a missing comma to avoid string concatenation Date: Wed, 1 Feb 2023 20:42:43 -0800 Message-Id: <20230202044255.128815-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693162648680403?= X-GMAIL-MSGID: =?utf-8?q?1756693162648680403?= 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 14be7d261ae7a..dfd67243faac0 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -144,7 +144,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", "cpu_bringup_and_idle", }; From patchwork Thu Feb 2 04:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37515wrn; Wed, 1 Feb 2023 20:45:30 -0800 (PST) X-Google-Smtp-Source: AK7set/B68AXqDVPMFRkdyj/Rpzx6tLDp2nFScvXZKp9uYdr8X5h3TkU1y9xgDwnwwj75Rqk1BHx X-Received: by 2002:a05:6a20:3952:b0:bc:d288:a67b with SMTP id r18-20020a056a20395200b000bcd288a67bmr6799109pzg.43.1675313130025; Wed, 01 Feb 2023 20:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313130; cv=none; d=google.com; s=arc-20160816; b=RbY7EO+0LQDBCk+ZIy52SGGf7kSa8QIHa0OgU09a92tYuBsgwjzXiRxGmDFBzyHno2 mb1QHNGqGWxUSQQqzX5HqnbvoyQEvNetJu2CNSSeeItTraQ0+1QPBI/XuR16lNfW6hag r28Bq0i8tKUimfQM1qC8KSQG+PRh6P5ibje0tJbsO5kfWm5drGIHx+GoG8epwl1CIK8x WVz6JOz3UuwCE7T4bzoIodOmOCP8eGIqCNSsFQxCWMrOO0LfUq9/RYOt4Xz/CKsz8Hi8 WYoU+YASaVQTnz3wI+4bVW3e1mW8uclqe9Ai8MzDmZexGohliVWkoKPu7YsApMVzgC5h 2lBg== 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=rnQVq+M/EgzjtETsTzIpOijQzUdQF2ZoNgjCd0VQoRA=; b=stEjH9gFHRthBBlUzBdAdEk9Rqrfs/eNxwbUxyiob4J0nnRw+ZEYsPRfnk6APTOLDb yfFalLC2BwAYsokdP6TrnXr3EjIOcAApMOpSrvbz1OSnrcdB1YksDBvp7jfcXhP0jips c2BSIfBExnTuHD4CPk+z9aiB2VLGIVb5MOCrG8latUIMUquQK/G7VPjjACkDKT3bq98X 1YHdgWs1BEwRRIibPQji77yY4vlj3XXmhcd9bgYQ9+qdtJv+Nq5X/0H9aLtLRocRcCy1 KHqY2tfkiQwvyAfIJTY3Ezdwa7tGmXedLctVHDnaX9t5JHzEoJ1JiPybjmUvomXMDLky DJBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RY+m7BOt; 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 k74-20020a636f4d000000b00479337c8eabsi19647919pgc.581.2023.02.01.20.45.16; Wed, 01 Feb 2023 20:45:30 -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=RY+m7BOt; 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 S231611AbjBBEoa (ORCPT + 99 others); Wed, 1 Feb 2023 23:44:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbjBBEoM (ORCPT ); Wed, 1 Feb 2023 23:44:12 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4B277A483; Wed, 1 Feb 2023 20:43:52 -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 686D7B8241E; Thu, 2 Feb 2023 04:43:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA2FCC433EF; Thu, 2 Feb 2023 04:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313030; bh=PuhSXXH7ABpQ0zNff3KqR9dMDr71RXa2680XZD99Eus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RY+m7BOtLdJCIQuPIS5UJRKNr7upaEVDxVRIJjOJwcDhsftkCWO24n1rpzjv/CYf/ CsOcX9wTv1ppYk3aCsRqnVXIW7x9FaCsVYxLhmsV0Jt9RInFx3aMWngbw9BGtBti8R TLlFDCyKO4QgUfKGjgOEEcCvOtXBL8EKQVpUknz7GNnfhhiRFg3hNqhQdiNttXr/KZ hdqXSFEraVvS1fAXnQaovWuF/aHNkUJ3zXcd2ARlAguZF8ts1yMeU+F+6xh+a2ZSlQ 0qCJSw2jvhAfhsqO6O+RO5Vvi2KIvNacNBOsk7v39wOSAOLserOBVgQrrwKKXG9k6g CVe6Cz9uPqa9w== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 06/17] hexagon: Fix function name in die() Date: Wed, 1 Feb 2023 20:42:44 -0800 Message-Id: <20230202044255.128815-7-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693140832165478?= X-GMAIL-MSGID: =?utf-8?q?1756693140832165478?= 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 bfd04a388bcac..f69eae3f32bd2 100644 --- a/arch/hexagon/kernel/traps.c +++ b/arch/hexagon/kernel/traps.c @@ -221,7 +221,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 Thu Feb 2 04:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37663wrn; Wed, 1 Feb 2023 20:45:56 -0800 (PST) X-Google-Smtp-Source: AK7set83miniCGTnmPhG49EuHWpph4IYzmk+MAysb08izyoyD8kBRJEdTDft9CsEcWUJdC7R3wdy X-Received: by 2002:a17:90a:30d:b0:22b:b824:827c with SMTP id 13-20020a17090a030d00b0022bb824827cmr5014434pje.48.1675313156425; Wed, 01 Feb 2023 20:45:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313156; cv=none; d=google.com; s=arc-20160816; b=TxisUsU9oQIfBt3Yy6dIiuFALgCRSgo/8d80ahRtMf3RPMkNWJT6pFgn07HtHcLN1i amVDdlHPElA59naAEDeAlO/CWOdW1bu3LyeIJbYQnJEtgVJY6n1D1WBhk9InzlXk5epw oaWfHZpiShvLU8twHfaVDVfYlxzK8vcoJCLw5JEmBJai0iOCEyGaD6Z87cqXxH8lnnLe jzVIOpEneAfS1gsLlG3k1G127g4lU9lkwnEu9gSiSh7Y9JCbBSPNDVMiKvofIDwkNFSi g6ZCdboPvKjUCdV/pabC5Zjn5g9a1apXjN9YnsLRPaIfpaTOenTeQlk18TZAy1kgHHRY 4UHw== 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=0+ip4U/OqP5VNuiYiDuTDXWGm7K8l7d7AlcU1RpRoOI=; b=EHW5XZxVuOvlDzo2vqT18TsZBcDd25o8ux1lE7+Pd8hRd47/0ThOQl2VrHXwHTZpy9 QOGvf/XYLUpnCYd1n4jNnyhGDePzkf7NG1BvAOw4EU/RKIWxHue/Oe557S9k0uJnz7MS QhM8WdbDwbX+gfxliFW3J3Rz2AXs6Q3LkU2USBAaiHonPawK1I/frDKuKnkw3yXrVVCl z/bf5YItSLb/cKt6m4jYRXtn4p03sp9rgmqeB1gxQHiVTt9qZAl+b16a73la3zwMY0TY CLkBlftbSIvcAtqP5xX77s8eQU6CX5WWcek5jjmSPoDskQeqZuVYTnLR36ac8oJiMGLT PgEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GSlRYvtk; 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 s7-20020a63af47000000b004e853906f2dsi302879pgo.480.2023.02.01.20.45.42; Wed, 01 Feb 2023 20:45:56 -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=GSlRYvtk; 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 S230323AbjBBEox (ORCPT + 99 others); Wed, 1 Feb 2023 23:44:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231537AbjBBEoN (ORCPT ); Wed, 1 Feb 2023 23:44:13 -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 5F56679F35; Wed, 1 Feb 2023 20:43:53 -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 C86C8B82419; Thu, 2 Feb 2023 04:43:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35618C433A8; Thu, 2 Feb 2023 04:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313030; bh=w2+gKam0hgvqls1hiqaw8OhtqAs87LqFnf26zQZbz5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GSlRYvtkuUFWe4vbS/HNXihmDyie8RQeqw+ns+JXTbzbI2stS5ZtZmI5tW88p7p9P 3zOUOHQhOab0uZA11IDkNDz4ni3/KlpN58Sj/bTx1yCxg/kwC2ciUBD745WJBkZ8d4 3K67pxTWaYRYojL5FJBo+7yP92zbVNlOnPwEVxy+fQPiNjEk8XfzfgDawCTWIUEzLh nkr8sBUaa/gumUuJLGVa4+EQjjnTJYGkgTDK1r0+RsB3upNATXzjgUHwfocpcQ20zD YVBH086RxKANA2ETy6Zv9M0EBamaTFOxMPdEL9jRbCzhw8Pg6mJ6S9YdF65mnwYPri 8Z9nNa359BmsA== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 07/17] h8300: Fix build errors from do_exit() to make_task_dead() transition Date: Wed, 1 Feb 2023 20:42:45 -0800 Message-Id: <20230202044255.128815-8-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693167974598822?= X-GMAIL-MSGID: =?utf-8?q?1756693167974598822?= 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 a284c126f07a6..090adaee4b84c 100644 --- a/arch/h8300/kernel/traps.c +++ b/arch/h8300/kernel/traps.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -110,7 +111,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 a8d8fc63780e4..573825c3cb708 100644 --- a/arch/h8300/mm/fault.c +++ b/arch/h8300/mm/fault.c @@ -52,7 +52,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 Thu Feb 2 04:42:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37691wrn; Wed, 1 Feb 2023 20:46:04 -0800 (PST) X-Google-Smtp-Source: AK7set9Z0M1KgJ3JsN2D2WTx5+0z1tu4+taYIRJrOyE8vTqZnakKaknoidmO5lAYUyKFv++AlD7N X-Received: by 2002:a05:6a20:3b1c:b0:bf:8e87:eb67 with SMTP id c28-20020a056a203b1c00b000bf8e87eb67mr999653pzh.18.1675313164314; Wed, 01 Feb 2023 20:46:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313164; cv=none; d=google.com; s=arc-20160816; b=Y4oVcG1UH/YGGvh7wNq5b2ZUu+p/H/54l+piaPl6QX569SnhDE37mEwgkSMfgXimpa yP6ai7x8s3FSAKdJ5+Dw2PKNc86XK/kTx2lUNcluoM5IEwQgILrgT3jlbBpgTDUTHdga rR0dOI2aAreo50xVkbmswr4oPQXWumU0Rybrply/ziC1ZmSaToAo/cybdT6w02/VpQtv Tj0dmjirvJDNbkLGdDeXa4YsbAgOKJ6SSb6UP95QElniRCBFRzQf5938VjNQ1T18NLcP 8/nDQ5PsP/go8+voltA6JlJ5jtbmBYYOm3vfhEcvJRhPRaw3PEDaJrwZ9i/QXr2sGGPd vo4Q== 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=CTofzj+DOUjtyjN3s7G9ymVGaa7wdgIgx9I/MLcIhmI=; b=Uil4Qjm1xBg27Y93RxFQZQ5y3Kz57JB7nXdG0rvQ4SuHBDn+nQ/reJIvFq0pI8UDhW hC5AtE68MPZa2Sy2sWnhmvNwOdzNnJhkLrrGIwLlFsZdaraTqmE3Cgb+nTV9FmoIO3GI r0qAfLVXn8ifldC3NgRnHjRZU6BwP36B+0RIp3mlh1YTNVhgr5Dys35EQxg0D5VxYcWu wfW35Q6CFYd/fS4xNbCqixaTb4fTs4/gIKMZZz96ZZT6CLx69D8Bvtkq15tLwD9s6OOW 5EXfDzvc/ZKTkAwAClFEtExhcUJ6v4dNDomofcb93Q1vWEmtOBrXy+EyScjPtZ+Yhl49 V2OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GAL6uaZi; 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 h190-20020a636cc7000000b004f1ab50b6fcsi1546495pgc.109.2023.02.01.20.45.48; Wed, 01 Feb 2023 20:46: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=GAL6uaZi; 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 S231751AbjBBEpQ (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjBBEo1 (ORCPT ); Wed, 1 Feb 2023 23:44:27 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0507B428; Wed, 1 Feb 2023 20:43:54 -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 AE2D0CE2776; Thu, 2 Feb 2023 04:43:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A48C5C4339E; Thu, 2 Feb 2023 04:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313031; bh=XY8YPabANMgGP9lCwC3nPujZmuktFJoup7VESPIQyWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GAL6uaZisjV10y2TJ+F4UyPLXR3ccmBea7qqRfYfYLjb+5tDTzgIMcht9juKhY315 5HlIgt0CsPyyF7CeOW184WN5KpHJae+Xrr3QiU9GG/3z1Uvwom1O2YCkKTJUWcnbeL hhivg3rYXVrRVAIcGd+gu+MX0o/LkclsGCUkR638obM101+aGTQD54w4IN2ys9ZVoG pzt+5crpb2AIcRB9Qkhonc+YNyXw1xjUUQ5K7Hqii588KYcynX+n29aCpMNU98y46l dAfkOZZXZNkAHQMk1Bb0uBCOIy+7F9TEGXLhHDgfXT4Qek55wg22n1RCGgMOj39oxO ntSx8HQEjo3Uw== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 08/17] csky: Fix function name in csky_alignment() and die() Date: Wed, 1 Feb 2023 20:42:46 -0800 Message-Id: <20230202044255.128815-9-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693176958086565?= X-GMAIL-MSGID: =?utf-8?q?1756693176958086565?= 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 af7562907f7fa..8cdbbcb5ed875 100644 --- a/arch/csky/kernel/traps.c +++ b/arch/csky/kernel/traps.c @@ -85,7 +85,7 @@ void die_if_kernel(char *str, struct pt_regs *regs, int nr) pr_err("%s: %08x\n", str, nr); show_regs(regs); add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); - make_dead_task(SIGSEGV); + make_task_dead(SIGSEGV); } void buserr(struct pt_regs *regs) From patchwork Thu Feb 2 04:42:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37832wrn; Wed, 1 Feb 2023 20:46:25 -0800 (PST) X-Google-Smtp-Source: AK7set+pqhGm8vgMNXpy0aIv6dwMVPS/I36PIgrB4aD5VEJ8wixdWlORIfXF1UrSRbWZb/9LzpNf X-Received: by 2002:a17:90b:33ca:b0:22c:aaaf:8de7 with SMTP id lk10-20020a17090b33ca00b0022caaaf8de7mr5198003pjb.5.1675313185257; Wed, 01 Feb 2023 20:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313185; cv=none; d=google.com; s=arc-20160816; b=VienU+ACqml/V4ihDSRL8mGDbp5+fuusYQAp5jwVeyOSsparNgAAXtOjpawdDKcsv7 31Ockl/aZGXO43kBcp4+v6LLgEumEkH6McYwRXQiAE7EfSEXZqBqy31IUkXGhlRcNq6G WJWo7HgkkjpaC4LQlLvBd12E5g8bV1wPIdhRylPVABwYO1YzBZzeEOm9VMOBYtjSW7yB vrGrGZI1pAOp8MgFQEa2hejYy0l0Poh63DOjI3rizNwkAU9l048H/CZMbY3tjTp3xBbu Ks+WR+yuGZN9N1zg3tFtvXz/QkTb9WuO28QWfbfqcRh+uf38PgXRgIMf3YqryVwMiT+8 lcDQ== 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=dni9tKchHmyX/o1aXsJdUAkZNzgL5FgBO3ptMOjtx0E=; b=eNLGB1Q73SEUTGXnD6tnt0Z1Lo93hFlBWa5uji7gizqFqMgNlNuaRw72pFYW++Tss5 4dWPiu9d/KgMNXOTER/RMvFIAo+hUf1aSjpycV0DBdBK7neo09cVa+ZKrHeuGsk0SUVZ 4YS11JRUybnY5VvRket14CWVFCWNDu4tEkcydUWwLIuhc4lm/9sQfH/tqE4iwr3n1sOy Y/2iO757zvEKRDpmUwSHesmytJougjGViBRUQ+iu+Mm0XAp6Prj1+OA7XfHb5AoeuTsX 91ARkH0OFm5E9WdXRazg438O+DB3YxNZzS2wm3yxQf5+nUuAuHE1fcDDdOr71pbzwpSy X+0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JdqskDXI; 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 130-20020a630188000000b004e22265da03si15754665pgb.652.2023.02.01.20.46.12; Wed, 01 Feb 2023 20:46:25 -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=JdqskDXI; 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 S231905AbjBBEpg (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbjBBEo0 (ORCPT ); Wed, 1 Feb 2023 23:44:26 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49E257AE6D; Wed, 1 Feb 2023 20:43:53 -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 F3931CE2778; Thu, 2 Feb 2023 04:43:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2746EC433AE; Thu, 2 Feb 2023 04:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313031; bh=tQ95HDESaxTuqQzyi1nO4i6CEilM7c7Fe4WNSNWi4kU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JdqskDXIomYSiwz3Z4U2sxQUvmzdaUm1/g9FqeL9OJsA7fRP94ps0hhnABrZ99FaJ p2rFFyeP6TLBIDeB+6KGL8FE60QfgpCTOVXibiz2zwIv8p2eNRK/r7YS8qDOCQPHP1 iPMlor9cjWMoJHaK2wFMZxgf8wZVjV9CpaKjlP6yGIphQp1nh2gGXMw0NrfCPW5Ymo prHIw4OO+uTw0ffAXFtgEMb/JNKiUvbe/F5NYYt8or8Knqhalkqnn7yest5JsHLpTY Q8nZkWxcAUHORHMkpeAWQ0xx7F0FMBT6PBNMrnGWu4yJoli7JyhagYp+oJ+uv0U+i4 /lIZ9kRFMNf8Q== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 09/17] ia64: make IA64_MCA_RECOVERY bool instead of tristate Date: Wed, 1 Feb 2023 20:42:47 -0800 Message-Id: <20230202044255.128815-10-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693198522968317?= X-GMAIL-MSGID: =?utf-8?q?1756693198522968317?= 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 16714477eef42..6a6036f16abe6 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -360,7 +360,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 PERFMON bool "Performance monitor support" From patchwork Thu Feb 2 04:42:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37737wrn; Wed, 1 Feb 2023 20:46:10 -0800 (PST) X-Google-Smtp-Source: AK7set9l+MlxnsAdvBvwDgrnV+slzHLkjxsR6uKHIdku/BLCOQVx4BZolicALAekbKm3PPx2cHLQ X-Received: by 2002:a05:6a20:a71f:b0:bc:acd8:fd4 with SMTP id by31-20020a056a20a71f00b000bcacd80fd4mr4276568pzb.35.1675313170520; Wed, 01 Feb 2023 20:46:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313170; cv=none; d=google.com; s=arc-20160816; b=yNjEwOxvHXL1KmkdEGyg4Zd6wLxN903bvpZQbzGengrg2wuPVVY31lbF3FTytVAudZ qPXJnxi8/CS2qYRcMbTs8lZA6MTFSNXF/lxRcvZVs1RHtYfLl1wMqttdxNAgyZIUex24 By02RqHXA0nEIyqV1UC1WVuBVyh4S8AmKTLzc6OQnk+JUcBgscDuk02DmTraSwYody6/ D+JyYQTuauANB53XI7D6dIHnZ7kCKecCaGLg5o5Qn/VMyE3vk3mhU10FLzW6ugIHafJ0 QAxCMTJJXALkg2VdP5DkmuT1Kq2dEkHpmps+V3C1R9LSuMjSw8e0eZaXKqH1BKfsoZUq 2Sow== 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=OMfnv5/JX6vF8pHSl5qdX2DsahnqdSu8xthMfGMBhXQ=; b=lpTkFPruu0n/BvIujiWwKj25Zu7eOdlOGlPk3xq/sOcfll6iL7n4RtmCkK1jewtrRU XlB3NKflBiudAb2TSycd4ZIqyXNaKyaHYSS5/zEhAdSxK7TDe/eegFVhsDSxz3L0mFVl g5C2MeTO70CK69xL/qmRvdKMY3my3NOwWNdD1lkG3BHjwnF93809N5cdRqu9UJ5yZoxh 7MRSrfxp75oWEHrYdLEWZQskyW9V9Am7gIZO5FENDEnxyTN5g1DpwfzkrU6FbtGv/rF+ Q0eF2iRY3TBQ22tdbBKYT+eUk6d15QqzcTvFOw+QfgjfjMymeJVRK/BCrmriz0L80nwT lyug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hLQoWIJ6; 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 m136-20020a633f8e000000b004e407a446acsi15325235pga.644.2023.02.01.20.45.56; Wed, 01 Feb 2023 20:46: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=hLQoWIJ6; 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 S231868AbjBBEpZ (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjBBEo3 (ORCPT ); Wed, 1 Feb 2023 23:44:29 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFBE67AE7B; Wed, 1 Feb 2023 20:43:54 -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 72ADECE2772; Thu, 2 Feb 2023 04:43:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9819C433EF; Thu, 2 Feb 2023 04:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313032; bh=HNQpHj2Cf/HumAeaEwkB8GDbdPDoX8BPhMGpIKhobPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hLQoWIJ6LP1yHpx90XEBC6myUYiMRg0HCuCMAd9F3lCCsgJ8jXN9YO1lSJXrfi4ym PSvfs2Ld3hTWm7dZZSoWEavKo++s5DesipEAxKE5A+sCYJBYkuKuxS4z9i3ZwQgBXW 6vURfKKXpyLAOMS6NDYJaxAAr4betX5OGAysSxf7R0xaiAyy/wcjb9Mrsq7+VaRJhi ZIRXVvHCA8Dw34aV/xbtmbpnZchaoCQRvqyt7wnbWoD3U7zk07kJIL2yyUuOJ0J6G3 ixGCspt9B8s6rkcozHhkr8RzVm1CnxZl2jh/EEQ0VIsixlf1ZVY+ZoMXJpkHHWhndX SNqrewgzJN2RA== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 10/17] exit: Put an upper limit on how often we can oops Date: Wed, 1 Feb 2023 20:42:48 -0800 Message-Id: <20230202044255.128815-11-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693183523835251?= X-GMAIL-MSGID: =?utf-8?q?1756693183523835251?= 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 9715685be6e3b..4bdf845c79aa3 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -557,6 +557,14 @@ numa_balancing_scan_size_mb is how many megabytes worth of pages are scanned for a given scan. +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 6512d82b4d9b0..4236970aa4384 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--; @@ -866,10 +893,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 Thu Feb 2 04:42:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp38442wrn; Wed, 1 Feb 2023 20:48:28 -0800 (PST) X-Google-Smtp-Source: AK7set9huys3MPSXKNFAULBN0Mpq4d7rDeXYr5z/m1VwBXgLEE+9ohrlx6K2Jv+9Goj1Q9TH7Vc+ X-Received: by 2002:a17:90b:1c08:b0:22c:10e2:9e3f with SMTP id oc8-20020a17090b1c0800b0022c10e29e3fmr5187867pjb.0.1675313308128; Wed, 01 Feb 2023 20:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313308; cv=none; d=google.com; s=arc-20160816; b=Ly5pB6UDYlsWUtuGt5nxKkZ66gFbiwBjAnRwIuLktII1TNmRqGsEgNGOd2UYOvMStT YCqOh77v6fCWcR6T6f1lFdAObKNBzcktwu/jgk62cgd77HDdnQrze9hrH7NkOoEyPCyG tI7yIZhv2xtbzJkdRvuMUwuaMucNlnooghYReO6ryWj3aR4Q2q9x1R9jtlxZzFbYjO/S qi8pcSLTo7mocz78N5dM0M7I1tcxyW2gXmREYEugbG5N6eNR2Q5LhIW3vSK0mODNVh0K vVsX/WYjRSPykRRqoV5IX5flnbW6ye4OmghyNx7jkoi/qDAI3CHST+sKVlmCxx8x5xGf abdg== 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=UvguEkpNRav7tA5LzETt2jX0cQidp0HG9DmDJRKY5p4=; b=ZuquM3erBTjrou/2DqTDhO969GMIyzrKiIE8MBFt8uJk3Pyt6NoRxkc309ufPeEFjT /T6o+xVkeASsG5p2UHH1ccZ2nDZp67O3U9/ImS2gzwO2k/m81OIgc+BSrNdvslhrsvl7 duAqeg88n4pgHd5690fuIJ8RUno7JrE2eq6SGJZHwWavW7b3s6xDIxprno1LkadS+EiX RYQvr1e/IMTj5UueUGwWAwzblT/g4T/zxHdsukyQ6Ux1UdvdBi7f1BBYEmxSc4Y4iW6L THyrHqXDFjSwAg83TvrFlvT2Rxy842hj0MHCgJT2v4ic9HnhZKknppsXNe+dZTghDL0U 5qyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dlSzTgDW; 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 i75-20020a639d4e000000b00476990d057asi21220227pgd.472.2023.02.01.20.48.16; Wed, 01 Feb 2023 20:48:28 -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=dlSzTgDW; 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 S231923AbjBBEqM (ORCPT + 99 others); Wed, 1 Feb 2023 23:46:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbjBBEpe (ORCPT ); Wed, 1 Feb 2023 23:45:34 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E74397E065; Wed, 1 Feb 2023 20:44: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 sin.source.kernel.org (Postfix) with ESMTPS id E5EE8CE277A; Thu, 2 Feb 2023 04:43:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36506C433A0; Thu, 2 Feb 2023 04:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313032; bh=5pmjNgpnYqex7VQnVsTlAui4MzRzKxLrogzRqHiHtqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlSzTgDWcfQVHbIxOWU30QRZsa6UC0nR/HAKxTPBKGRCVPB4BHoMb8ekSFZRMO+B7 ENitPO148BAtIpRxK+4Kmdto3uBT/qRDhAMUDvpoAKVdbbFvB1Z3//J1IsMpkMNG2E odrpaPNBuKqqPGzUHMtCrB0a4I1e5BAXQ39pWQr8C62al00wVOzL6n4LfK04hCCGwg AsnchuGGHE23Yo1Tg5S8Y1UR+b4q0Jd7wbvzNEkTEQD06hWfOvmbSooxMeJjBdzNaO ymc+yPjxaof3UmWMVtByyLmB2TpbN8L+LML2HFf3BATg/Xjis3bKHajPxRSmhns6i0 FmbPmZRgIfoig== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 11/17] exit: Expose "oops_count" to sysfs Date: Wed, 1 Feb 2023 20:42:49 -0800 Message-Id: <20230202044255.128815-12-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693326963554391?= X-GMAIL-MSGID: =?utf-8?q?1756693326963554391?= 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 4236970aa4384..48ac68ebab728 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -63,6 +63,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--; @@ -893,8 +913,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 Thu Feb 2 04:42:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 51683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37932wrn; Wed, 1 Feb 2023 20:46:48 -0800 (PST) X-Google-Smtp-Source: AK7set+nZvksHb9oBR588xxTtS9dUEHu6sjXjPX77oJQvON0Mghb05j5Xm3R7ZkdbfkhfuYR3f/9 X-Received: by 2002:a17:902:f20c:b0:198:c6d1:cc03 with SMTP id m12-20020a170902f20c00b00198c6d1cc03mr148281plc.24.1675313208380; Wed, 01 Feb 2023 20:46:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313208; cv=none; d=google.com; s=arc-20160816; b=X98OunSFSsCbh/LY2ghN0MndKJxtmLMhHXDKvFTk1+m1EER9bHZ3BHnCbBEjEJeqTF 7CeBydjLBw36llqbyaAwK/aOBxoB9HkANPKM4zHX22nlRODv780R/ExpTuGECoc6OHZO AydMLWBzDj1BiNYZ157JRydc13lvEP1npIMYLk1vK7xQkZL+3Jpk6BVDOveg6J4TN/l7 2jZ0ZrpMI3Hj3Se9Aje4OAiwUmSgxlpKCIU3sbiJl1mh39OzjgJzYRgIz1nvg94nTD+K KfPere2PPYB3SCe65H7KVFpkPnVFmCPFQeWfYGLGoyM10dMLsSnUKCKJSpjlunhpHyee 9D7w== 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=SFJ30Afl23HfBjxDwjUp8WpVg2tzuFuaKE0u0PrRs1Y=; b=C01+1CTwsysm3nwvecZdoJLqNIvmD6UYPRsDdDQHNAC9rj3MwCkZetEb/QnV9ve6uN 2SWTJITMnW/AwZnXIEeJ6VN+4/p4zh5heC7h4AcjnbsfGjEsufNeZS2jNe7E+V05VLO3 a3yZkXsI38iUPoZhcoP3ClgHMn26hwJfU55kmQQSHSfnwrCZgB5YeBAUHqIsaN33z2qn qdKIf7v0pOJGOGA0op/utUOC5Un/dYNLTQ8yRmvUbm+fxpW1ab3/Uc3rd6AHPlYXt5WW P/QiOts/BmJb+2hRfpEjf7xHn/I5mMR2UP+6n5Kzfhdfc/7X52MungNGyyQB3Uq0VdAA B5fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SRKetWvc; 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 x11-20020a170902ec8b00b001968cbc67e2si10271264plg.583.2023.02.01.20.46.36; Wed, 01 Feb 2023 20:46: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=SRKetWvc; 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 S231970AbjBBEpq (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231679AbjBBEof (ORCPT ); Wed, 1 Feb 2023 23:44:35 -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 E51B47A491; Wed, 1 Feb 2023 20:44: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 ams.source.kernel.org (Postfix) with ESMTPS id 803B0B8241D; Thu, 2 Feb 2023 04:43:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACEDBC4339B; Thu, 2 Feb 2023 04:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313033; bh=H528wNNxm5Oo0hjUOWSVmZTKVIN9JjXoFt12rdqUAXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SRKetWvcTG8xZO55clQQVma8DAfR6WxTmSIO3yNoIAIHU4Wy4wmEiLoyXMI0Lh1C0 2k7E2v75DJ1pR19FhbL0kkFrqW5f3UBCtaveVYGOGJsAiXrZVCvqHzCOOz0DjjHwzG YUKTLkRTSml4kJNPMzCU41quLTFUmQj0AGkQgpx/gM0El59PO3OUhnM9MQDeqqJeMo 33n0zw2n4rsdfz+sE/VHlNYNYCHWSmSNRcBqWuGTvb5GEqrB9Ef7ph6OFsXdAxpYvC lkJBJ8WAebzlw5OW8oHiAOKcz+r8PcnoY/oOR9qGGjm3zdhVAslz+gieJzpymURMGq dYzB1KR3qo/dw== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 12/17] exit: Allow oops_limit to be disabled Date: Wed, 1 Feb 2023 20:42:50 -0800 Message-Id: <20230202044255.128815-13-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693223093929576?= X-GMAIL-MSGID: =?utf-8?q?1756693223093929576?= 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 4bdf845c79aa3..bc31c4a88f20f 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -561,8 +561,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 48ac68ebab728..381282fb756c3 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -928,7 +928,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 Thu Feb 2 04:42: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: 51682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37913wrn; Wed, 1 Feb 2023 20:46:45 -0800 (PST) X-Google-Smtp-Source: AK7set93OEsK8kfnUENbYVdZBSgHrslArnvKrlg1MRSY5rfM9ObrvYaxBqtCcF7NIAT4PoUmY5eR X-Received: by 2002:a05:6a21:918b:b0:b2:6191:fdef with SMTP id tp11-20020a056a21918b00b000b26191fdefmr5115608pzb.43.1675313204931; Wed, 01 Feb 2023 20:46:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313204; cv=none; d=google.com; s=arc-20160816; b=KoET6/m0115GOgBvDVxNlTTCrzQGiQgNNIFQM0Ese9S0/vEaeGE79+xktx93lZturp x4v+qdFUcBO8zEDCxo8/oTDQdXFiu6b0/1aU+stXf0SJV6jYF+bM3fP52wTXuVhinhMy IgwD4R1gr1DWeLCMA1rXrnPFgme+mI4mQSFAS1KXIhCaAwriU30tm+o5dH4dkcT0PeNb zinAcbRCdCeO5o75PXTXOkHmMI7NbNb8GUJChqygTe9hz8bzgUonA+44SkGnnTIaKqjD dGj+9i2Iv0+sLmKUV1uh2UhvgoLV16coAGr2+bHJhhuWv/61txnZrxhc/vkpl2TbWENf RlXQ== 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=1d6U6SvfkV1Q4VXNQw/YmTFmTyuRguphtqdsa72EubU=; b=tTr9ouzoZ2GznElT2+TeDcGrS7kB/rl1OyW4afsAiAuSlSlg0rEptCqTSUTu9FK0yv BT0Bl4YYcuE3LNMjfBx8HMs1pH7LiY6iRuhPxV/5eQoSfsPYDdHfnqwAj3K13iE+Gv+R tG2aVUNMzRMcreumWMiGlXzQuPVyY10P2BCBWMhqp8jwd+3rEJy6g3VrTZjjR5rHuEIE j+1KsbvP8apmNzpxqe/Rhou15iMc2NGyclIsOKIX9lN3fVBY25yonMMGswa7OkmtiPRQ CK9ty3G7i/CYhbAhuxK71aOXGwDAgEPF1S2NPJQvkIybY6Yvzhb8eayfbqODegtOAQGL lipA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sf+IENLZ; 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 v2-20020a637a02000000b004786f5e24f9si21200412pgc.94.2023.02.01.20.46.31; Wed, 01 Feb 2023 20:46:44 -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=Sf+IENLZ; 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 S231716AbjBBEpl (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231676AbjBBEof (ORCPT ); Wed, 1 Feb 2023 23:44:35 -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 E54247D995; Wed, 1 Feb 2023 20:44: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 ams.source.kernel.org (Postfix) with ESMTPS id B99ADB82422; Thu, 2 Feb 2023 04:43:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59556C433A1; Thu, 2 Feb 2023 04:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313034; bh=jOyM8do6FoMsZTh5VR6sMe/vJTgtvIwc5MLZQPrW/p0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sf+IENLZWlu+ktyVwbHxv6G6WPgYHWFc6RRcQ5ZtM/XF/5bHcwbVbUwm3Lw0y2yj0 rKqANe5mqg3TcIzHncMizi+L1DYM1MhSxoagQ7c/APsqpMNAfLjvlXB2xhHNAYbZfy XHljdWt63gJbeX5N6Sr3GWrjthRwyQm0yOcKomU7T48m3SbW/mc9SuATRYlgjn2vRn NfAK7U52JCS/nPToqXAfxRozUYuXwSweJzAvq41fgNO2CHegyoVe8VTuCU8EEiUPcV NixH7tz2mB7KHXUxFEb9CAl65jKt7wTGjWG2LrSsvkVqLPqbSFT5V531IOppOOKqnW /dGporr7i8Y3Q== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 13/17] panic: Consolidate open-coded panic_on_warn checks Date: Wed, 1 Feb 2023 20:42:51 -0800 Message-Id: <20230202044255.128815-14-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693219456125314?= X-GMAIL-MSGID: =?utf-8?q?1756693219456125314?= 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/kernel.h | 1 + kernel/panic.c | 9 +++++++-- kernel/sched/core.c | 3 +-- mm/kasan/report.c | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 77c86a2236daf..1fdb251947ed4 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -321,6 +321,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); void print_oops_end_marker(void); diff --git a/kernel/panic.c b/kernel/panic.c index 5e2b764ff5d54..7e4900eb25ac1 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -156,6 +156,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 @@ -581,8 +587,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint, if (args) vprintk(args->fmt, args->args); - if (panic_on_warn) - panic("panic_on_warn set ...\n"); + check_panic_on_warn("kernel"); print_modules(); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 06b686ef36e68..8ab239fd1c8d3 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3964,8 +3964,7 @@ static noinline void __schedule_bug(struct task_struct *prev) print_ip_sym(preempt_disable_ip); pr_cont("\n"); } - 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/mm/kasan/report.c b/mm/kasan/report.c index a05ff1922d499..4d87df96acc1e 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -92,8 +92,8 @@ static void end_report(unsigned long *flags) 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"); kasan_enable_current(); } From patchwork Thu Feb 2 04:42: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: 51679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37749wrn; Wed, 1 Feb 2023 20:46:12 -0800 (PST) X-Google-Smtp-Source: AK7set+tDmBNiPahvRki1aVzEnmnzHVLqiuKL7/a9Jy8dgXXDu/+qAP1cLAhQsdzgTehu4ESizgH X-Received: by 2002:a05:6a20:4906:b0:b9:92c2:7ecd with SMTP id ft6-20020a056a20490600b000b992c27ecdmr4920602pzb.3.1675313171785; Wed, 01 Feb 2023 20:46:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313171; cv=none; d=google.com; s=arc-20160816; b=V6RO/61+B0/CC/3xAVdlHPeFJ+hnm5pK6k727x5DMqJHoFCQV+kQGMdhBdCB0q4xxR hV8aFuCnYeXxNRua1uhcZhWBL46r9k0mGPMSl2bfHCP+GqKMoYpzLs3+QIFi39bx208I Zf68QwvxaWqF3upGRcXoAAl4iQEwtNnEPAoIrc6EG2qH58iGpyuWR49lmz6xRCoi5yKl QbWDvA0Y8Va9m7XFhiN7uYVAbgoSt7a9q1iXxE48HaVyxdvvsrL+ZK/9PNZtZym36/Ft bWQ7rUnza8usffzoDWALXzL1Ea6CLlpfHJYuQIiLSNkMX5dP80RvZWsvP7SFW4InWTNa 7bGw== 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=EqFhzaEvmxMDTtrcVLK87Pu9BK+togBhVb/ndudyqdg=; b=I4IjBOvLbhcYio4n3rt+tzB6mpM8eqv533JFBSSdfarwxPFzyRyvXCR4zwTgijNQEC 3OOffXCg9cwwV7l/23I08FSd2WiJ1PsMpvKvxHF64yRJ6frfz1r5oNH3KI7zGu9Ehanp zs6XgNJM+P/jcgvqPDEYONhy+dzd8zyGJ227ZIjoaTgRm1rRzT7w4PGSlI5hEEyU5gib bcjWtXhKmDlz4kUJml4g6z2a5fA3VksWg/1NUWWko+PsQM5lchxk9aEB9ybZfzQ/AC6F oO4PnIW4Fk4Ae8UI4rk1I1/hvN7kZueFkKyTAY30QXVXTjrTdeSoe1xG8M9d6FCTZL/4 iL4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hh7LNfQt; 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 h20-20020a633854000000b00478831d07f9si6904633pgn.312.2023.02.01.20.45.57; Wed, 01 Feb 2023 20:46:11 -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=Hh7LNfQt; 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 S231886AbjBBEp2 (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbjBBEo3 (ORCPT ); Wed, 1 Feb 2023 23:44:29 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37EF07A4AD; Wed, 1 Feb 2023 20:43:56 -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 BD001619FD; Thu, 2 Feb 2023 04:43:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DAF4C433EF; Thu, 2 Feb 2023 04:43:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313035; bh=1WDmjjuyVga+D7P6svQyR42n1613E6yY3wGob4buoKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hh7LNfQtS1v6rtHYRpYUC3qn6UimYhh6+J8v3ehqsyrV6jTp1zLe1CZRA4KTlBwMm vNasGp+CpZtQVrxLwYlI6oc8ex/2J8VAGr5mLLsz8xkNYnRdn9NMJaAxB7lS0uKljL O1fDFhzrMPcIEq+zdZxNCNDrK6rFzJWmqpAuOgHJ0I/IX4MSgjoEPA6aU4rB/5men6 pneeqjdFPRAn7cu5heE4qO6eBlanpeKRnhV9mGW6WBfl04hblz8JfDHvya4nQKXbM2 ML2QuMzHJK2oA3xQQodBUHhDigB5YSfu34Rx2t1UJ6WoDKIa8vUmyiQMXY3Bkg3tYL 58qlHwyccV/IA== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 14/17] panic: Introduce warn_limit Date: Wed, 1 Feb 2023 20:42:52 -0800 Message-Id: <20230202044255.128815-15-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693184542405469?= X-GMAIL-MSGID: =?utf-8?q?1756693184542405469?= 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 | 27 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index bc31c4a88f20f..568c24ff00a72 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -1186,6 +1186,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 7e4900eb25ac1..8f72305dd501d 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -44,6 +44,7 @@ static int pause_on_oops_flag; static DEFINE_SPINLOCK(pause_on_oops_lock); bool crash_kexec_post_notifiers; int panic_on_warn __read_mostly; +static unsigned int warn_limit __read_mostly; int panic_timeout = CONFIG_PANIC_TIMEOUT; EXPORT_SYMBOL_GPL(panic_timeout); @@ -60,6 +61,26 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list); EXPORT_SYMBOL(panic_notifier_list); +#ifdef CONFIG_SYSCTL +static struct ctl_table kern_panic_table[] = { + { + .procname = "warn_limit", + .data = &warn_limit, + .maxlen = sizeof(warn_limit), + .mode = 0644, + .proc_handler = proc_douintvec, + }, + { } +}; + +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; @@ -158,8 +179,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 Thu Feb 2 04:42: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: 51680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp37778wrn; Wed, 1 Feb 2023 20:46:15 -0800 (PST) X-Google-Smtp-Source: AK7set8CGhoh6Gv4GYrlPZF+zFsSFCbddnGR/4+DkskVx4hf0r42UstsDeN8/LtVxyiMYvnQKrf8 X-Received: by 2002:a05:6a20:2a0f:b0:bf:4563:e647 with SMTP id e15-20020a056a202a0f00b000bf4563e647mr4216221pzh.40.1675313175627; Wed, 01 Feb 2023 20:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313175; cv=none; d=google.com; s=arc-20160816; b=IQ/I5BedLUMxGTfOVF3sswcQeB5Z51fBc0vBZbGeXdPaNPpNY7/YgyTi3zr2P9S9ad 7psxUXZ4crLXdk6g8aJ47zy+xyekcCF4CLGvqEjwknkq+blmTXtEna1MPnbWNc26R2kk x1Z5/v13IU16LRms5+aINnhG+bddkjcNZmJO1XuV0a9bbk1YQJV2wXrD+ZJyiIffQE0r X8/2qturxOmZQMQ2ia19leGct91y8ZK/b+ruMStwfMi9N+ixG4ScXY1xiittv3ezKyGB 5eRFcPDMTJ4vb7M5h/QfiiiiMMgxF0FGaZGfVyeAzqeUePatftLJRTb6q7Ykzkd1nkgz mQJQ== 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=o0lx7EbwtycnKw9wBcQaAg1UuCEdMv8tTJYAD1BRee8=; b=wI7GOF3tmv0hmwTu/IuzcW7ibmZlyZCI7GSKTEV9k1I2+cXD81uTXxtaFiKWNAhjjc Cz3X7zYPCxSxFroiRUxeKGfafdlb9F+3xZLe+8KfCrRi48FvRYJVf7qfvN8YoZXwElI+ Z/oLSjemPnaosGIZUc5YdU/51pZekNmol9fcub8MacpRKXg+beVFG9sFBVBDmFLLZ/IS zEuFaS2bu/kD3OELiDIyhZ50eIq3RanYBHyUVtq2KR44uOMwL3nATZN0Wxv6qCafGEKT h8YiADs5JicfrA7PnLSdMxnK8r1E18nM+gZuNnlDHuORUCIoTcO7aODpEn1vqmYVorc1 IXhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GQtBzWYu; 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 bu21-20020a632955000000b004df6beb6e39si19616244pgb.683.2023.02.01.20.46.03; Wed, 01 Feb 2023 20:46: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=GQtBzWYu; 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 S231895AbjBBEpb (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjBBEoa (ORCPT ); Wed, 1 Feb 2023 23:44:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B2887AE50; Wed, 1 Feb 2023 20:43:56 -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 034E861A01; Thu, 2 Feb 2023 04:43:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A00FC433A8; Thu, 2 Feb 2023 04:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313035; bh=F0/lM0ehn2dBgPa8cBm0sLlTTLRWC+SL/tZ/GpO45lI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GQtBzWYu3FDPs3gks4gvD/ybtlukRJG4c4dOKW7kzFU1ctOO2lNJEQWeJbIJxWbAA gGlcK/yq474y5U4bJ1NVNdZQsvnJW6C3cpeAim6F4VLimHMjAmBd33pfvXw7NrcBjC mp7HVlBF/cubFD+1F4PZVc/FsKFwLa2aeQSLardlN1xUP44b/fcvoNmHZwCN3qPVmE VwusoFBGesu2lBYOu6r6PpcUypI60Rl37TFFkXuZO2p5NzIb/fpqbWfjly51WAveAg X8tkRZkF7GyEu/EjtE6fZsJ8FfOssaUWl0H6w5bO5nPVIPf6+gku8a3c3QAI6B4vAL PM/hs1uYoPMRw== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 15/17] panic: Expose "warn_count" to sysfs Date: Wed, 1 Feb 2023 20:42:53 -0800 Message-Id: <20230202044255.128815-16-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-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?1756693188689783828?= X-GMAIL-MSGID: =?utf-8?q?1756693188689783828?= 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 8f72305dd501d..2c118645e7408 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #define PANIC_TIMER_STEP 100 @@ -81,6 +82,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; @@ -179,8 +199,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 Thu Feb 2 04:42: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: 51684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp38027wrn; Wed, 1 Feb 2023 20:47:06 -0800 (PST) X-Google-Smtp-Source: AK7set+eyt++Lagf1QsQdMc3MsMb0iS7wU4iu6vVc0f04GCzDNVFfYYnJcxJr59OY+3YsiA7dfCX X-Received: by 2002:a05:6a21:33a6:b0:be:c7e7:7988 with SMTP id yy38-20020a056a2133a600b000bec7e77988mr6845410pzb.59.1675313226112; Wed, 01 Feb 2023 20:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313226; cv=none; d=google.com; s=arc-20160816; b=PopjK46JuYEU7W80nvYFbhMo9cxnuqhFSMQKkejK6ozohDESyj0Fc+SAvX87KuQ4eN N1CRdLcFfFx5A2lnuOWqxhgvb69PIgWkUIW0DV7spUIvV1U7+VGzlQJNN4Ogf5ttkJxH H7AX4mwoWfPao5sEEkXMPH1c+GTqFjjtoLIlGsMx6IxgautdhildcAsDd76wCBK8WOLo /K1xa2pQp5M3ZcJUq3hblpMz8y/LV7vZdKf5fGtg6LRBpUihW+Isj6wTquR7QNUKQuX+ 5DTPxnAM0eFYzhJowk1JXLYw+SPyYCf/DDIMF7sGUHgcHVcnRnkn+lvD7m/VtqhLM2/X RFFw== 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=h3rZ0mz+HFhnakH+Ae8iXdew8Ktc0bXDCZ/kpTGs/WTboB+veKgD+SE1ZvZWIEbiax 7qxcwI3p0y0gdsWzAP/Ydb+flyrXFX2jc3VV5IaprxoiNq1v41+6QZd4VhI6OWwQctJo NkrWl6z3PFvQVon4rF6ntUvFRAKHnC17DITCI2+ULTMoe90cIrJZ+oNErR4JOcZ65RLg WyMN/v5ZjA/TmtTQzIqI0q7K7O2wBo4IzML4kgBFsbI7Q+HaT9cqQF6mSmYSWc7GRL71 rE68yL8oGMloWfhX8uJyak8nf6Q5SDuHDYDllBWdU863Kgh5RaxGUO7BKC/gU5q+Nm1E 5wSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nAvPdyTF; 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 k4-20020a170902e90400b0019655a451d0si18130590pld.203.2023.02.01.20.46.53; Wed, 01 Feb 2023 20:47: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=nAvPdyTF; 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 S231996AbjBBEpt (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231454AbjBBEof (ORCPT ); Wed, 1 Feb 2023 23:44:35 -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 B46B67DBF0; Wed, 1 Feb 2023 20:44: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 96CD2B82429; Thu, 2 Feb 2023 04:43:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1B04C433D2; Thu, 2 Feb 2023 04:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313036; bh=jO10o07RAKyXXgWsy3XBxX0WTtST48LzT0RY2uOU2ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nAvPdyTF1CQ/3SMGkgxIcGQ8mnvreRb6Y9/2ukXmDh1WFemGwMyBC0c7AqBi1xqPH JO2Uqg5rOhITiA5MiaREBArn7aI2aoKKKdUKADMfpRtU7LU1SlhAqcsvbqcPTht8wb lgaLkk83LDYAvizdVvzcoSPiWz71PbzCYFr1iXl5WvMezDDoDhE+kstRJA/9Byd3h7 aYlB7koEzmGZnSsBzoXQTsSxPin2ATSvQvjAl9bWyWlxwW9CT6oScrGrklt/23JCE4 TrK4XQIZn6y8WIjSL9ew+o63Wk3i7jimCXRu0iwkooyfUC5dDjsoSiwElziaOtAg/2 5yLSWMvkSowVQ== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 16/17] docs: Fix path paste-o for /sys/kernel/warn_count Date: Wed, 1 Feb 2023 20:42:54 -0800 Message-Id: <20230202044255.128815-17-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693241223926499?= X-GMAIL-MSGID: =?utf-8?q?1756693241223926499?= 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 Thu Feb 2 04:42: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: 51685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp38083wrn; Wed, 1 Feb 2023 20:47:18 -0800 (PST) X-Google-Smtp-Source: AK7set8HzmxX76Mm3wMDmQljW/sl23gvKsvy5NwdLOD5gAVqFiDes/DGAHG9DaEBOvu/uyZsKh86 X-Received: by 2002:a05:6a20:12d6:b0:be:c73d:d847 with SMTP id v22-20020a056a2012d600b000bec73dd847mr6239672pzg.28.1675313238563; Wed, 01 Feb 2023 20:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675313238; cv=none; d=google.com; s=arc-20160816; b=fFCvlDpLrFZKvImjTfZwQUEPzIe0hTBHBy2FjYTk9aOMuMn7FAjp816JqE/8unS5IY W+v9Hzf9vOJuuZBppSUtshOsvoG22Wgsz0EXY1KoEtwKa2GozWIlUJeF+9bRz9PUm5zq U/kB5PI4G3+CTaDi3njZYeJtj6oazIQ/RriD/+KPGTGnEg5PpvXNTIHiV8AU5rqPFiH3 xGCyYXgT0zoHTTx6r9Bu8y8ZByZAu5J0fNti7eDmAH8CVrIFmJZ7PK3KSPWsEbjWYsNu a6VvYFUDUN4bUbe5eTT8Ss2SJNNyWkKmlvhGC2YyJpSm+1DSfkK4/Vg7LsVn4+uOiuKO 9O/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=O7IS0ns/xBfhBTdduXcE6l+8WYG/RFkWGm+Sb+mobOk=; b=z8UwAFO/VKC8APxOZfu/nwBnusO2OIUfiBVlGQe+/GAgci/QlNiVMenvLchmRT68ef MoKHgSxoP5TbFZJNTZb15iF8EhwUz2WSptDl8b/xv4EXl4U0GB8HI0AVv78/zYMWL6FU aEvFTNIohOWGgNtS5Kv4S1tpv0QzEX+8+tUKMRxt5nmzThMUA5x8f0bFOZaeO1jaip1y jHsv2gCj4reP5dyeG+4eslYHGs8Uin4bcRXIwrqzvWBCRwKLZAjj/pU7V3Ve8HhHLCp6 +szZNhABF/ZfOgBlbANXxSOZhWzWc9AKwDax8X5qgR99N6Ud6tUyQAhI8nfo8Le5faLC 25eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OHTPXjge; 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 p12-20020a63740c000000b004ce0e7f1ed9si22277702pgc.77.2023.02.01.20.47.06; Wed, 01 Feb 2023 20:47:18 -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=OHTPXjge; 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 S232002AbjBBEpy (ORCPT + 99 others); Wed, 1 Feb 2023 23:45:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbjBBEof (ORCPT ); Wed, 1 Feb 2023 23:44:35 -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 B0A4279CA5; Wed, 1 Feb 2023 20:44: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 45C65B8242A; Thu, 2 Feb 2023 04:43:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DCDEC4339C; Thu, 2 Feb 2023 04:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675313037; bh=Ve+SUjFT/Nf/6L6DRSA5cH5fVqI+DU03ZS6m/x33UJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OHTPXjgewSa07lvxg9I89tCrtEl+IqTrKzX+leydnBtIb43mIsC93qQPhTycYT+N9 snADAtz6Adelf4rkYxsErFMeUkr72FOm2DtXPimSWdO4jn7zeXlVeXoeWkKrBkR0vA Kgas0fFV22oTfMtL7G3lLjWAJjDCbC4hkTBDH0NuCFICsjzrE6ASOq0V9p49x00aij rIIgOkrQCbcfpZV+80pYGZlEeWehKj5qwPeSKaZ2mqQVO0u6GT+CJXOk3Ajj0E8QQH Ey1VWpQehMTTMEkpSV9GURV5j78vHPr4wsmKZa2cNrDhTHZJBqHr/AZDEk+hxQtlbp dm298Vu+Wo00Q== From: Eric Biggers To: stable@vger.kernel.org Cc: Harshit Mogalapalli , 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.4 17/17] exit: Use READ_ONCE() for all oops/warn limit reads Date: Wed, 1 Feb 2023 20:42:55 -0800 Message-Id: <20230202044255.128815-18-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202044255.128815-1-ebiggers@kernel.org> References: <20230202044255.128815-1-ebiggers@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756693254798591198?= X-GMAIL-MSGID: =?utf-8?q?1756693254798591198?= 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 381282fb756c3..563bdaa766945 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -917,6 +917,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 @@ -928,8 +929,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 2c118645e7408..cef79466f9417 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -199,12 +199,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); } /**