Message ID | 20221202210617.never.105-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1075039wrr; Fri, 2 Dec 2022 13:19:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf7gNe5lBrKlM4qpvx5NxonlFgto0fpeP60rEtaCaB7/s7wYtapINyBstlVou+jTvmTbsKAA X-Received: by 2002:a17:906:2e96:b0:7ad:8f76:17c7 with SMTP id o22-20020a1709062e9600b007ad8f7617c7mr49773903eji.315.1670015969938; Fri, 02 Dec 2022 13:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670015969; cv=none; d=google.com; s=arc-20160816; b=YFizxg3z/j8iMnkk9lYmP6978xsUXXRFjiisCX/7r+1A18X7D3s7hll4jzPsVtKDAd GkUXjR5x3M69OLDvb0z4d86euhIXh0OoFxOVjpis0UQgJ3y8ZfcpP6DtahGMQj3QwySo t0qa4zeCocXYqnrHPg9enuaOkZhOH+brGVRLP1C60+yJaNBafuyLNsMXJDL+IsKj0mCi g55o/sy/HBQb/M2oApfvEoKJTpOrA8t2QKzSf1gBRV7rPzckv/qNtnzWt/JoxTdBoUbE rog9OsL5gb/NwSJ3hPN2fo43Z6eE2f+7fbJvTyR8x7yXB77bghfW9BFjVqu5+58soaKg DpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=b+Cwu0oORJoqtBf3SwedAguHYFCuhYbPDgOJRY8RxDc=; b=iKIuHckFMpr/n/uFC4FDNVRnz2WEVDmwcEne96G4hR11s4UWw9/NpTzS7Ahs3nda7R iyCmPsC+x9F+Inbk2mjcSKtQIZXiCeh+W2Q3GN4SGc0LTp6e1OHED97p7Jtz1Hnda6Oe ZDPfu+AnnktZLhfJkQCm2k4gCcjj6IbDWnRJzCbWhlG8dHUE0OdUudaWEYJDj5q72rkz Xhv1VQ6EKTdwj/EKbloTD+PTpA5+I1mYrDzkQo/eE0SsCN2cONdrH+K1MAs/M/1qFEZA RIYHgSrNhj/dYXmwYUGbXDOi11nQOZ+BUj9bYm2tAh7UrVpww/7mUvXvPm3oBYZeDrCH slsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eTjCt2wy; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa31-20020a170907869f00b0077d854aa10dsi8455910ejc.57.2022.12.02.13.19.05; Fri, 02 Dec 2022 13:19:29 -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=@chromium.org header.s=google header.b=eTjCt2wy; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234159AbiLBVG1 (ORCPT <rfc822;lhua1029@gmail.com> + 99 others); Fri, 2 Dec 2022 16:06:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234139AbiLBVGZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 2 Dec 2022 16:06:25 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 564B2EAB42 for <linux-kernel@vger.kernel.org>; Fri, 2 Dec 2022 13:06:24 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so6210602pjm.2 for <linux-kernel@vger.kernel.org>; Fri, 02 Dec 2022 13:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b+Cwu0oORJoqtBf3SwedAguHYFCuhYbPDgOJRY8RxDc=; b=eTjCt2wyDeZrFaTFP2qLMErlY0YdrzSBrPZhKR0WLOuKHEKfcJBdp7tFzCGtTSLbh1 kmDWxQa18M/FQqLL+dqsSTz0qVBAp8o1fc833wIKkIqXjXnvUGMEzIdo5hdEwQzR3PuH Vyzb1d4jqy1v0Va24229nMjG1lyIWKPucvJrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b+Cwu0oORJoqtBf3SwedAguHYFCuhYbPDgOJRY8RxDc=; b=WZgnxqmU6ybETC9kAczCQ5iDL+AhItuakxvIw1PLKx/z2zEs9Mz4cJ+Murc2IQ6irR PU//7Hhmlm+WQggBxz91d5MHXUFogmSAR+HMmWos0ys8s+caMyaTUdesiIUmlgye2K+J HROgH4W2TobeRg0wb1PeYvLdT8pYNk7rOl3q4HvRiqA25U7Neki4vEfG1kSBC6QVxuhS MSQ8Z7TC8MU4pvfOt5zLHVWkXDWYzRTGzPyzOyWDlmsPVltqDnzdITaoiR0mApJlHzIb Cs/SacltwvirfJu3eAIfzFNq012tQ9VAIwlonS8W8YiwJSMzgukm+WvyHQ3c7wESm+fq F0vQ== X-Gm-Message-State: ANoB5pk4kbR2NYgp1+f+a4MOrOsp7OjF/JXuYkSa33ZK32x+D/twdFbR Yn5AaX2JuQd3o+pqIbdv80A7Fg== X-Received: by 2002:a17:902:da82:b0:189:adf8:54f8 with SMTP id j2-20020a170902da8200b00189adf854f8mr13076731plx.81.1670015183731; Fri, 02 Dec 2022 13:06:23 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id e9-20020aa79809000000b0056d98e31439sm5703448pfl.140.2022.12.02.13.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 13:06:23 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Jann Horn <jannh@google.com> Cc: Kees Cook <keescook@chromium.org>, Seth Jenkins <sethjenkins@google.com>, Jonathan Corbet <corbet@lwn.net>, Andrew Morton <akpm@linux-foundation.org>, Baolin Wang <baolin.wang@linux.alibaba.com>, "Jason A. Donenfeld" <Jason@zx2c4.com>, Eric Biggers <ebiggers@google.com>, Huang Ying <ying.huang@intel.com>, "Eric W. Biederman" <ebiederm@xmission.com>, Arnd Bergmann <arnd@arndb.de>, linux-doc@vger.kernel.org, "Guilherme G. Piccoli" <gpiccoli@igalia.com>, Joel Savitz <jsavitz@redhat.com>, Laurent Dufour <ldufour@linux.ibm.com>, Rob Herring <robh@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>, Ingo Molnar <mingo@kernel.org>, "Peter Zijlstra (Intel)" <peterz@infradead.org>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] exit: Allow oops_limit to be disabled Date: Fri, 2 Dec 2022 13:06:21 -0800 Message-Id: <20221202210617.never.105-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2081; h=from:subject:message-id; bh=T618w/j0axgITyjfLRoHa8B3lQ31JWaln373s8Gn90k=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjimjM6qX21BtN+gD442We20DY1hyv1ftI0+cWAqVS K5tQeg6JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY4pozAAKCRCJcvTf3G3AJghuD/ 9UFGZVzFXoKQtfKm4Z7rtqz7Bk0KS/u8l0ck+I/oBsHNXXAjV+6tN2P2nqF0DQl3da32+fwwQHh0i6 Z6ZKIDsRx7EBxTEYlabrnE7QECT185s0e/iICdJgafEOPopGz+Bl774b/2pOGTJ0uQu6nGP2SqQIPt Wmv4NiR8DEpWPrXyZND8eT51yallcOhfqfR6xkLc522a9eOxUWcucdx/gedtRqTknHTQ/i/dV6hzOK GXrZ8QM51UOYjbd46kEemIUjC8/qTk98x1fPszQ0/qV1NZN8LMLTRXd1W7hSXcL+lQ9QVcvIL2kRGi KahFf4+aZVlmGDa94Gd7LWcPrHjjhH+TiVr+xB1OewiC8A37NCf2XiH20uH9M4CYw2UZkc6V2CbBGi qwXUYkk2uK+QAc/h5o0a/cwYfLjAlCBeZHEGJlTCVno2PXrOugFNJWPuvhtiWEtklH9Bpz348otyIi xyDnD4fpFIvgGtNUHo+SuP4jp0a9XiATdUBsE9nDsT9U1jnALIdN2rX9xxRPpvTJpwgpHJHokmpXkP 0vScld0Rz0VVyCwok2o560CtbEUjtN9H3D27q9uq26BIIbBtxMeY+LmPKBxN1xLMGiQsunmP5DPYKi Vkf5P1XIF/5L19BTArdDGeArZNtd78UqtHN1iXYTeSny1jM65A8zU9w/Ua1g== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751138666058368820?= X-GMAIL-MSGID: =?utf-8?q?1751138666058368820?= |
Series |
exit: Allow oops_limit to be disabled
|
|
Commit Message
Kees Cook
Dec. 2, 2022, 9:06 p.m. UTC
In preparation for keeping oops_limit logic in sync with warn_limit,
have oops_limit == 0 disable checking the Oops counter.
Cc: Jann Horn <jannh@google.com>
Cc: Seth Jenkins <sethjenkins@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
I've changed the warn_limit logic to match...
---
Documentation/admin-guide/sysctl/kernel.rst | 5 +++--
kernel/exit.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
Comments
On Fri, Dec 02, 2022 at 01:06:21PM -0800, Kees Cook wrote: > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -954,7 +954,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); > That's dodgy, please write as: limit = READ_ONCE(oops_limit); if (atomic_inc_return(&oops_count) >= limit && limit) So we don't explicitly add a reload that negates the whole READ_ONCE().
On Fri, Dec 16, 2022 at 03:05:13PM +0100, Peter Zijlstra wrote: > On Fri, Dec 02, 2022 at 01:06:21PM -0800, Kees Cook wrote: > > > --- a/kernel/exit.c > > +++ b/kernel/exit.c > > @@ -954,7 +954,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); > > > > That's dodgy, please write as: > > limit = READ_ONCE(oops_limit); > if (atomic_inc_return(&oops_count) >= limit && limit) > > So we don't explicitly add a reload that negates the whole READ_ONCE(). Yup, that's more correct. Sent: https://lore.kernel.org/lkml/20221216203024.never.640-kees@kernel.org
diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index 09f3fb2f8585..a31d8d81ea07 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -671,8 +671,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 dc1a32149f94..deffb8e4b1b2 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -954,7 +954,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); /*