From patchwork Wed Jan 17 16:14:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 188887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:414:b0:176:5f3:c5eb with SMTP id 20csp779492rwd; Wed, 17 Jan 2024 08:16:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTMCg9l90lrtvu8cKwcmtMzMEB5QlGX72ATYthv1CLQXVvNAVxOWVRPIcXAvqudTcv18Ud X-Received: by 2002:a05:622a:1710:b0:429:a14e:12c1 with SMTP id h16-20020a05622a171000b00429a14e12c1mr12125903qtk.27.1705508212951; Wed, 17 Jan 2024 08:16:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705508212; cv=pass; d=google.com; s=arc-20160816; b=bN4qfRHRFjniTGve6EqbaifIS0uZIvsfTI8DAiWSmv57/sYcvVqOus6qSoJJm5w+TB gq0rlmK4TkmUEighIqAkpTSZobY0CHRlyci6aW1PBec8QHRqeAgEQ7bEP3UgWWpGKm1p Ck6RGM8R7EkLnaGDbpGbKboIuqcGbZMMOaLRo+Q9RUvNLz6BtgiKLMnqCNDsTJQalU7e /QZSr/n2MXRXZ9TeC5imYuo51t4e9Mox5bipbWLK0EtBa2gmheLgzjHjNb5DEA09aklp fAWLzc62dMGNc5f3ZjJ2xukLJ7nW7JtPA4zim9dfCT24GQ7ztOoHz7+m1R7zG8N0k5gj iNhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Kmbez58j5lCnAqbtgiv72eK9zQgDnqcShPxrJ1mOWnM=; fh=mzZ5OKkyWbFHsrLyCorOBXM9JoluhtmgZuUWxRX6aw0=; b=swPsi2ambz04mQtet+1cB+F4tSNO8YECJG7TiH9bgV5IB7/Db18p8r3OZxpUI52hEV rYa8ye14WJWUWODyeAjDpO9AqcxznTTEZDh6K2vTlsu8vOPHWRJFj8XkUY9eqSZ3oXVG jJLlcGSqTxcXyD1EkW4MyVj2RmkbT0o6dArMhhK5Oibke1UGluJ9QvcaeNU5l4fyPDeM q4vOcnpaOOMoKnLQnZc1ZkHrVSBgY2rfWWACxrE4WCsfcUipQ923qoXNyGSTngRNzLuq AqQKpxMInItI5UVphDV42Yy583WHMkUD7EjSuPAnzveWb8wHbXNNty/Kxtb4L9dc3dOk kv+Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=maEHAzHm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29203-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29203-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e18-20020ac85992000000b00429986ca00asi11930878qte.511.2024.01.17.08.16.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 08:16:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29203-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=maEHAzHm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29203-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29203-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5B38C1C257A3 for ; Wed, 17 Jan 2024 16:16:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4B2B23752; Wed, 17 Jan 2024 16:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="maEHAzHm" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E403822638; Wed, 17 Jan 2024 16:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705508111; cv=none; b=PIgYJawRp8KGcLl1nPR7I2ndMWRaRL/807XYJOcQWTgOYaxXm6OMH593HvTt1fXQuxTpoa7GLJDVrEHBmCn44k62d/PAD/crmO9O1mDkj8X3eimWJUcE0MlPjKoH/0VWV7oN9jYsY1R/fwiS5DqmKR1LGApfl1B/i2v29PC8vhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705508111; c=relaxed/simple; bh=jDzObRYwRkapJySKK0oWQtxYQUq2OVssGctw+1duV94=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=OTy5/2m4f+xv2yh+ryQzqaccw+hp68wgY/9EtZWhg0sTteIdBN/I5H8GxkpCiLGIA40I3M0jYzKfwCae7O28tf9/HwJdss9yiHHRqeB8Fyp10OeH72/8qRf2SJ8JSmNdgopbTXxe/TBFXdpY5/qnbalzwhh9o76Y37YXfPsuo+0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=maEHAzHm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF1BAC43609; Wed, 17 Jan 2024 16:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705508110; bh=jDzObRYwRkapJySKK0oWQtxYQUq2OVssGctw+1duV94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=maEHAzHmX242xFhjDsTXdUbPh+/313gooww6/wGhfud2C6V+ivwG3IIUyyDsblUjI 05Cfc0FLTgiLtets7cdvt9U1BAaDYytmPqjoHp9v4TnGh8hJFgappYvNSadYIZD/lD Ma/df36cpC/lrmGPKu+YGfwmLsCZBQVQEtwaL1F7tdtCu8EBEZBhvc7RrCn1L8LYwJ fvIikk7HgNpBwTIlWV3cNxJgTC0GW6JTKfU1AfajNo4VedSGPAITaQkqyC23exjI6M Yll3SXrambsT2BAdjL4GzfrmGfa7A3h8IX0XJECuRirErY6rcQYAcJ2Vo4ChBB1lwD Yw7CgleyUXxhg== From: Josh Poimboeuf To: Linus Torvalds , Jeff Layton , Chuck Lever , Shakeel Butt , Roman Gushchin , Johannes Weiner , Michal Hocko Cc: linux-kernel@vger.kernel.org, Jens Axboe , Tejun Heo , Vasily Averin , Michal Koutny , Waiman Long , Muchun Song , Jiri Kosina , cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH RFC 4/4] mitigations: Add flock cache accounting to 'mitigations=off' Date: Wed, 17 Jan 2024 08:14:46 -0800 Message-ID: <3e803d5aee5dd1f4c738f0de1e839e6cfcb9dc41.1705507931.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788354980055765088 X-GMAIL-MSGID: 1788354980055765088 Allow flock cache accounting to be disabled with 'mitigations=off', as it fits the profile for that option: trusted user space combined with a performance-impacting mitigation. Also, for consistency with the other CONFIG_MITIGATION_* options, rename CONFIG_FLOCK_ACCOUNTING to CONFIG_MITIGATION_FLOCK_ACCOUNTING. Signed-off-by: Josh Poimboeuf --- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ fs/Kconfig | 2 +- fs/locks.c | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 24e873351368..b31fe7433b48 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3427,6 +3427,10 @@ ssbd=force-off [ARM64] tsx_async_abort=off [X86] + Software mitigations: + --------------------- + flock_accounting=off [KNL] + Exceptions: This does not have any effect on kvm.nx_huge_pages when diff --git a/fs/Kconfig b/fs/Kconfig index 591f54a03059..4345b79d3b40 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -129,7 +129,7 @@ config FILE_LOCKING for filesystems like NFS and for the flock() system call. Disabling this option saves about 11k. -config FLOCK_ACCOUNTING +config MITIGATION_FLOCK_ACCOUNTING bool "Enable kernel memory accounting for file locks" if EXPERT depends on FILE_LOCKING default y diff --git a/fs/locks.c b/fs/locks.c index e2799a18c4e8..fd4157ccd504 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -64,6 +64,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -2905,7 +2906,7 @@ static int __init proc_locks_init(void) fs_initcall(proc_locks_init); #endif -static bool flock_accounting __ro_after_init = IS_ENABLED(CONFIG_FLOCK_ACCOUNTING); +static bool flock_accounting __ro_after_init = IS_ENABLED(CONFIG_MITIGATION_FLOCK_ACCOUNTING); static int __init flock_accounting_cmdline(char *str) { @@ -2930,7 +2931,7 @@ static int __init filelock_init(void) int i; slab_flags_t flags = SLAB_PANIC; - if (!flock_accounting) + if (mitigations_off() || !flock_accounting) pr_err(FLOCK_ACCOUNTING_MSG); else flags |= SLAB_ACCOUNT;