Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp172455rdb; Wed, 21 Feb 2024 23:08:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUS9ZrJtqPvVtJ9L4PxRbSvNmYFSr0a9xb+nlkshiyJlARjXlhpHXbKoxcptqOlndy5YcWApSHv6qBidvCak6SHHzVTCldq7PMD3mZmng== X-Google-Smtp-Source: AGHT+IFde1kI2/kYwVVGW+tD8ctVNl+rh5PW9yyH/kRglOKEZtOPNwF9LiNIVzmPaUzEKUC0pZaG X-Received: by 2002:aa7:cb51:0:b0:565:2581:8c3e with SMTP id w17-20020aa7cb51000000b0056525818c3emr1075520edt.8.1708585735862; Wed, 21 Feb 2024 23:08:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708585735; cv=pass; d=google.com; s=arc-20160816; b=Funby99KtJSFfyDfh7RcXhS0OFrV5fGU3VQcQq0qDr8ptivGcidTrOZjFmMfUFgiq9 oaYzYs+l73WAYk8/V0rEca2mjtNvXfvFg7HoBGyW+IX6ZfaKZnzurGoELzoec1fPZ4la aLGKZOfaex8bwMO9da4iyVzjwtIbt7OjSWNwvbm+O+hneTCJkQGzUd2Ct+X9rRO+frz5 JUduuJKpGhqb5f+88uW42QszAeUO12pVnKyQWbjqjeGy9cOXnVG3HU/2bf2IJMM1Ern3 OcB/WJerVI5yanzDmxvO90zJ32rlRXplowGt5I5hFX2Y/XR8/5kGMFTZ83EINEPyaYgZ J2wg== 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=DELvgqmLMNroFvNwOOw4aSnjkKoLQseUGqDHzB1fqqw=; fh=bv1xmQMLoUkjMaBG31+T8n2MW2r2VJMdwGgIEDt2AwQ=; b=txhUAiGR8WdRYb2car9/SwrZXv2mZemzJ7aTfSbwc2HiHoelvl6IHY0untC3CKBpbC RXZL8mA3oWhXGgK7qui51/HP3bYqkJihQoDvbPs2cnG+Xhy1fiPqe/tLAqJKqlpQRaP1 ZEGw9amniC9J3ENqsogd6Mi30OpL7VP7DD+Lr7B6zGPLxbSApWrbaznFSkIW03ArfMFa KYyPl88jR89n46x8vxjz0Aa3N1KjOHfaBI+hKwjViLxDYZSQBWwxfCiHtRr+5ctIvUoi 620wLgYUEWodCDcrHsbZDcMBW0YAmy5q+QqKg8OGUX0rS7efrTLtiE7VEsTtAiveT3fD D63w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=HcAI79BJ; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-76002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76002-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y24-20020aa7ccd8000000b005639f161e2fsi4988253edt.109.2024.02.21.23.08.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 23:08:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=HcAI79BJ; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-76002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76002-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8FC691F23A8E for ; Thu, 22 Feb 2024 07:08:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB3EE17C71; Thu, 22 Feb 2024 07:08:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="HcAI79BJ" 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 53775175A4; Thu, 22 Feb 2024 07:08:21 +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=1708585706; cv=none; b=K5s4PB4+r048+ywB1f8R+QHY5j7TUJImnTCn0uGpM6XwddUTAG7H6rPjZa7oYvQI2jaCD/6k2oyNCqJhPTdUPlK4QPrAwdKK+WCMzJIsp9yR/mUM1xz1X1gjePIfuUupKVFJdCMbsDpcVJtI/sb4kaaO9I/MYyYrQbBlR/vfkJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708585706; c=relaxed/simple; bh=JCJJxjzDXGYJItYXCEzMjq/GSfQbqYm3SGRGNchibxI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WC4/MsfvLXcCPbJJ8iRqbsmPWN2Su3YDCM5DKoT/cH844OB1wWNZWmVhsEgJPyQU5FqT4VIWiPxE3Ie3K7nUbzT+/TLUTLEcOJynTw/fhNWmtYVpoVG58ScpDIzcUDaUrVkMh4P9Ph6n8tQU+yLGerfiIp1JypMJGTjzXN5t1nI= 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=HcAI79BJ; 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=1708585697; bh=JCJJxjzDXGYJItYXCEzMjq/GSfQbqYm3SGRGNchibxI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HcAI79BJ0jlUL64zT1OuRh30+urTZW+qC87py30RIz7eGcHIx66WFDtT39zDGmBJm HM3AVr97CHd1Z8uGeyoAPguoaxClQUfFoLFvizAGCSHNeEYre8uZUt8gUbcb1VYQSC /WwVQMPXKIeLbMGJhKlB0+r/vFxcH0nAiNkLKK28= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 22 Feb 2024 08:07:38 +0100 Subject: [PATCH 3/4] 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: <20240222-sysctl-empty-dir-v1-3-45ba9a6352e8@weissschuh.net> References: <20240222-sysctl-empty-dir-v1-0-45ba9a6352e8@weissschuh.net> In-Reply-To: <20240222-sysctl-empty-dir-v1-0-45ba9a6352e8@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=1708585698; l=869; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=JCJJxjzDXGYJItYXCEzMjq/GSfQbqYm3SGRGNchibxI=; b=XWUZnHu/nkrMeHxEs4qbmkwfAlq1rR7FWvv8k9GTBVFOuFcu7uJK8PSl+A+MtiSLWEAvAhI0I j8M7KbOPm+UA6bCmIRyLxiSyxfCwt6TFMzbkTTAlz2f+gifo220SAsx X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The type field is now part of the header so sysctl_is_perm_empty_ctl_header() can safely be executed even without any ctl_tables. Signed-off-by: Thomas Weißschuh --- fs/proc/proc_sysctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index fde7a2f773f0..4cdf98c6a9a4 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -232,8 +232,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.43.2