Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1279514lqp; Fri, 22 Mar 2024 10:09:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAZzh27AtbxtL87vUVaG8DRfKnzUaXWOC7qcSLl437PsbmkZomRSoBShulxxiSQE7Zs9Dx6Okg3HwT7AvyIh+MUxS4LFZwDhk2TjOvqg== X-Google-Smtp-Source: AGHT+IHuyU6BX2b47nNzmvhLUYl95vvF56K5Gtqw0AycWvD1IQso4ZxqfhYM+iTiMRCg74uTVqqs X-Received: by 2002:a17:902:e812:b0:1dd:da26:8597 with SMTP id u18-20020a170902e81200b001ddda268597mr384230plg.66.1711127343491; Fri, 22 Mar 2024 10:09:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711127343; cv=pass; d=google.com; s=arc-20160816; b=kmDnY/X3WIOArcn6dpB8Pj7z6WrfPJXN+Az+sntzkMzcaMHlfAarAvIQ2Uq3XuAGAm FN3mIhZh9SkZ6wOcA44OBvXt5DGGsJ0dE8YzNlGk2THZR2XfXt446Wz8a4imCYtgYW2Y jyY8qtObCftu8kes5VRGNMT5caymLQ9A/ubZPkVaY0aC38ppKjKpcRKq6o4C5Q8NncoJ AVzXgsfE7pp0wgLjoiUnhqoRO0/kf1SZxKfmGoPMb4v3ekTQ3HpiLTA6oln9TaRbK157 rVOKQCSX61fHgU2bC2EcR+FOVmCmfKxIa2ygVfkVYhNCPrTaKvZV965PN4QtQRoklk6X LIYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=w7Bgsd4ZxqeCeBBkV0AeJWDb42O8Wkl0JYTv66YXD3M=; fh=bv1xmQMLoUkjMaBG31+T8n2MW2r2VJMdwGgIEDt2AwQ=; b=mSPecKwp9U/+eqZf6lWJI0Mk5B29GEDSjXxYYK750aSewdpnzVJDChIlfD+f50lHP7 v1XZ5Qfl8msbtLTIm19ndAvfiCbrCDHlROAbXwV7pjEY3bn4bqEBVyFYIRf3aOM6OD9e 0LC9la3vj4LnltLcZ8yK0AyxIZrPfa/g0L5rs7V8UUGteigYrejA3Q2RA9HohDpCOr08 Z0DJWe0CIdEZs4S1jBgsuF+uUzMwM5e4sra0e2NMokX+66nfLySZAh4o+EcxOFcXVUmg 7OEBdcn/GuGgZnUEiNpyHgCAw+b82yJS7a8urR05C1XHCe9Iy+g+rFcApxaTE5cHM667 9IAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="TmF/Wipx"; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-111845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111845-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x9-20020a170902ec8900b001def230864csi683853plg.82.2024.03.22.10.09.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 10:09:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="TmF/Wipx"; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-111845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111845-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 06043B21735 for ; Fri, 22 Mar 2024 17:06:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57D3760252; Fri, 22 Mar 2024 17:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="TmF/Wipx" Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 0E7AC5D8F0; Fri, 22 Mar 2024 17:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711127168; cv=none; b=JPI0sQtZHpucV3EIHUIeA5/J1Y+XqSN94tcH6z67GA/1c0hOZe9rd6EacKHq0+GI7F+bKA8uwboszK5O0vshvWyNP0pASXkX3cT/lgPKft35IVGHVrEOAJMGdmYkbz5A4cj5wc54BjksljO/4UP7JeDQOenImd+rPMcgr/l7K5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711127168; c=relaxed/simple; bh=pKWmydccD60+SiYR6pnPoIGUdo4mn6q9g3JBlH5dGg4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PY/HDjZV+w/J5+LbLCLZQYzWtW5LT4/MJUyQcMscEpf7oNdbkmTEmZs4J89TNYPU/b84H7TFj214bOmOpjZru9aSevR8esoGfB/KecPORZlHYTAmYWEWUryvf6xyuDnep95YnGua10K4rq/ypeOMdCcTjecGqwCIMtgO680ynr0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=TmF/Wipx; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1711127160; bh=pKWmydccD60+SiYR6pnPoIGUdo4mn6q9g3JBlH5dGg4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TmF/WipxHKHJanklGRgo/cD7B2NyM0Bu+uXwRPyXWnATzoI9fzXN2RHFXkKEeYuTB Yek9tMJ+eLVIzfLTTOJeOa1NZLa2LoGLgGHy73oZlTIp22u3Nm/kPfA1+DbuScUDKq TOy2rEgVBCFr6TWSgDCd35tEB0kqLoL2VDr2q9Ng= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 22 Mar 2024 18:05:58 +0100 Subject: [PATCH v2 3/3] sysctl: drop now unnecessary out-of-bounds check Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240322-sysctl-empty-dir-v2-3-e559cf8ec7c0@weissschuh.net> References: <20240322-sysctl-empty-dir-v2-0-e559cf8ec7c0@weissschuh.net> In-Reply-To: <20240322-sysctl-empty-dir-v2-0-e559cf8ec7c0@weissschuh.net> To: "Eric W. Biederman" , Luis Chamberlain , Kees Cook , Joel Granados Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711127159; l=1390; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=pKWmydccD60+SiYR6pnPoIGUdo4mn6q9g3JBlH5dGg4=; b=e2QXcJQf+5J7TWOe5KTw0NSnhPXCh5BNorgGtCKLWzMkZ4ieztJk+0p9kVHGW8OEWOzmZtSik x4WRtM13pd/BmJ+gbkFlP00GzXbeRd6PvpkRta6m+vFWl3C1lhrFNHj X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Remove the now unneeded check for ctl_table_size; it is safe to do so as sysctl_set_perm_empty_ctl_header() does not access the ctl_table member anymore. This also makes the element of sysctl_mount_point unnecessary, so drop it at the same time. Signed-off-by: Thomas Weißschuh --- fs/proc/proc_sysctl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index fde7a2f773f0..7c0e27dc3d9d 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -30,9 +30,7 @@ static const struct file_operations proc_sys_dir_file_operations; static const struct inode_operations proc_sys_dir_operations; /* Support for permanently empty directories */ -static struct ctl_table sysctl_mount_point[] = { - { } -}; +static struct ctl_table sysctl_mount_point[] = { }; /** * register_sysctl_mount_point() - registers a sysctl mount point @@ -232,8 +230,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) return -EROFS; /* Am I creating a permanently empty directory? */ - if (header->ctl_table_size > 0 && - sysctl_is_perm_empty_ctl_header(header)) { + if (sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h); -- 2.44.0