From patchwork Thu Feb 22 07:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 204580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp78818dyb; Wed, 21 Feb 2024 23:09:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJzRuLPyLEjwzSaogaXY7r206B1/LiOmywUndpJFY70NYlKViM5E4hp9Sr8IKTAdYDDVmGAfl3u42XhsEPV+hd9vfAVQ== X-Google-Smtp-Source: AGHT+IH3EXcNoZMfHQYhuqmjijIqw7CLxxC9zg3ENeNudu0J3E432wGJpCwsMoDxU0Y/wFWCl76f X-Received: by 2002:ae9:c202:0:b0:787:2cc2:41c1 with SMTP id j2-20020ae9c202000000b007872cc241c1mr2454044qkg.25.1708585769326; Wed, 21 Feb 2024 23:09:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708585769; cv=pass; d=google.com; s=arc-20160816; b=BVBRdz8HjkTasYya+oaq3YuVgfJhe7pdXscsYsvUovAuuMv0r5OLH0mu0M7mVI4xPp dDyq7nVgPh/opa1jW2UFiVHHJdQLbJiLJ+p517CAJSyPwWktelQnW+GQ5qx1zB7ygMjS eGMPGrZnw6GwW5Et8Z0ek+mtna1fj9OORjw87fsAgJsVp7YzxjUr0Aqe5iPoxHwt7EdC 7iPKcaoUofUBeceN26p3o5L0AKiI/D3Mkg/fo9sDEoF530CyX8p6kIoNROhkb/xiHUzw Uv0DIY1CPDwcIUgKEqcwd2tOmJwni7nMhVRtpVzZXOqooU90N6UFfUIp3RLMLtcpv4+9 0+bg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76002-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b17-20020a05620a119100b007877aff36e8si4800476qkk.468.2024.02.21.23.09.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 23:09:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76002-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76002-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1EA271C216B6 for ; Thu, 22 Feb 2024 07:09:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4B651B7F3; Thu, 22 Feb 2024 07:08:28 +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 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?T?= =?utf-8?q?homas_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= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791582031399961966 X-GMAIL-MSGID: 1791582031399961966 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);