Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp504532rdb; Wed, 17 Jan 2024 08:26:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHknO2YbNE6cM26RGvWAy8r+RTMA9LyoLzvowA4yVp+pAeLYwwlJ9CPZ+a6sloXizrm0quK X-Received: by 2002:a17:90a:e007:b0:28f:fc0b:7ed5 with SMTP id u7-20020a17090ae00700b0028ffc0b7ed5mr756687pjy.64.1705508805351; Wed, 17 Jan 2024 08:26:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705508805; cv=pass; d=google.com; s=arc-20160816; b=jUaI5lb65v9a/XmAeqwyg2syWbdf718LiH42wi8seOhBP+UUjUeYYcKscueV3KTV0i X20Pg9XmaTGQxb3l6fKsVR6Hj7LcGJCCmzdKXYECbpyTSwbYwuaqWKNzM5whSw/ZraRp GqusOhFmfo3yRVEdpUyx+pAreZf6M7/hkQfZgh0gNusgP2Vt/C7bpt/EGxYTNaf+m3wh YrAvSpdj6XE+4qkRGvuCEJrOx605TLTO5QUpz7Ply753hjTl1zhBtno+WaaTcNtKvkBT ILMLCM30drgtx0aLjNP3fJ+cgok0xeBWzaSzH823Ax8+NVKi3J+8uZKNWOWP5mboP1Fy IWkA== 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=DMIwppfDFtVsVkhkJAC34YqIuC0oTG/FedMP6I7fc6M=; fh=mzZ5OKkyWbFHsrLyCorOBXM9JoluhtmgZuUWxRX6aw0=; b=Abxsb2TSuSj7ODkbLXO3je2QUqX824rWORJs2TpC3TG01i5IWErB1HRw1eWEbJv3nR KA3qGiW+MJg/idOvVbdav9bpxcgL5hVaXfydvWTvKWwRy5WvJPm+oQkdzme/is6kzcoa KRUnx/mhSB6tVG7BOPtfgNDdixOX22iYqqoYzqel1dAg0TvIaXpw6JFMgcki6ovijS3W gCxh7sb2WpA+BNsTgpp4K9EB2hSTags7fAXStbQrDVuY3ZB2sU5OsCVto6RNGpuKsmiN 60AEvEi6bAaTlpMNVMOwwo6hyM5DGQpCzJ2De2SjXdG1YoVGWQxdAKiVo2ak793uHFBG e5tg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GfNGTXOD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29201-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29201-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 23-20020a17090a0c1700b0028bec55f1b3si13982035pjs.98.2024.01.17.08.26.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 08:26:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29201-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GfNGTXOD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-29201-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29201-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5833E281ED0 for ; Wed, 17 Jan 2024 16:15:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56DFE22606; Wed, 17 Jan 2024 16:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GfNGTXOD" 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 75DBF224F1; Wed, 17 Jan 2024 16:15:09 +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=1705508109; cv=none; b=m9HtLf3m8BEEchxTR20AnzzlAljwO9hlnDRHRxweU/ynMpd26mGvzc0XsafnJDYMiv/4mDhuadyMl1ma8vM3DUHD7fIXH2fS06KmKyqgX0RpNpvB0h73m667JinST7wGcTtSz998axQvwjof1s3bGKyMQ11pfsSWwDPZadop9dc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705508109; c=relaxed/simple; bh=9hto33msnD5StAxQOT593RifYAulOEFb566w3+Gvz0Y=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=BfgtHBsGva4jA7vsuuJh8FHGCEB+hPTC7kKKiMrCzhVPbCZ5I4Cg/zQECofbGgJsoPGy7uIWj/VHpFrXq50rTUo0femiyoLEYN2/JXng/rIFiu3/WjpkEChpSXjvH0QxvFg9wc3TTb4lZjB/JlLrlhTJtYnQ4wwichVrhG2GJ2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GfNGTXOD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FCCFC433A6; Wed, 17 Jan 2024 16:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705508108; bh=9hto33msnD5StAxQOT593RifYAulOEFb566w3+Gvz0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GfNGTXODLFiLsBVDsLJVvkfO5IV9m3xe3V1IyY9QDAunprrLmIybo1nR4EASgkYNV ZxPQIlNRhxCRwAxYGZDieP3mteI7PlVqT6M6G9/8gAEmGLFszo/GkHXoVWxEhGCbWB GfAdkBo2+ABWF5lVOu8hwXqwdmT5VxzE/6yKc717wIJmBUW6jziYmNUNHzx6b4t2EG y0+BwYYFdCGNNt9/M+0W+hwybVBy5e4GnXZisSfO8fNh6gu7uDHmNFncKLj9IOS9av RSGF7dBcaoqCcC/8kIJ8oaGkf89HJAPGrnkfu1IZJpIDSD/joHHVrBLAX3SfSL/BGF v7PL8XppMBEmg== 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 2/4] fs/locks: Add CONFIG_FLOCK_ACCOUNTING Date: Wed, 17 Jan 2024 08:14:44 -0800 Message-ID: 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 Content-Transfer-Encoding: 8bit Allow flock cache accounting to be disabled at build time. Signed-off-by: Josh Poimboeuf --- fs/Kconfig | 15 +++++++++++++++ fs/locks.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/fs/Kconfig b/fs/Kconfig index a3159831ba98..591f54a03059 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -129,6 +129,21 @@ config FILE_LOCKING for filesystems like NFS and for the flock() system call. Disabling this option saves about 11k. +config FLOCK_ACCOUNTING + bool "Enable kernel memory accounting for file locks" if EXPERT + depends on FILE_LOCKING + default y + help + This option enables kernel memory accounting for file locks. This + prevents task groups from exceeding their memcg allocation limits. + However, it may cause slowdowns in the flock() system call. + + Disabling this option is not recommended as it may allow a rogue task + to DoS the system by forcing the kernel to allocate memory beyond the + task group's memcg limits. + + If unsure, say Y. + source "fs/crypto/Kconfig" source "fs/verity/Kconfig" diff --git a/fs/locks.c b/fs/locks.c index 235ac56c557d..e2799a18c4e8 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2905,7 +2905,7 @@ static int __init proc_locks_init(void) fs_initcall(proc_locks_init); #endif -static bool flock_accounting __ro_after_init = true; +static bool flock_accounting __ro_after_init = IS_ENABLED(CONFIG_FLOCK_ACCOUNTING); static int __init flock_accounting_cmdline(char *str) { -- 2.43.0