Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1277075lqp; Fri, 22 Mar 2024 10:06:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTWVtifseoWnYpw+ZmJTT6XnS67pmqj3l8jR85T+fRtcmMLITPgOFBpZdenWbFg6J0Gr2mcvmnaZSn2Biv60ojMBsy2p4VpcQPciWj0A== X-Google-Smtp-Source: AGHT+IE0CPZ9SJC1XsuJG1jGI3PKL2W+nEKKO8uwiF0FU47vXrOmaJJF6uBo151jqAziHV4dOT5i X-Received: by 2002:ac2:5288:0:b0:515:7686:2609 with SMTP id q8-20020ac25288000000b0051576862609mr32127lfm.18.1711127191150; Fri, 22 Mar 2024 10:06:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711127191; cv=pass; d=google.com; s=arc-20160816; b=DR6Wtf2oHb7CcGphEokXpa2wh70Ae2XR+ZWzpBRw2oheJJQlB2uP4hcC4+ZT/8T8OQ nsM+0T6UNkoHaZ7Sowvp3HwDq5vQcY+RFJwJmMfcMJN/Sh2+1h+o3sZYQnfaujZOjVOA c6bf084JC2uOm0tp9F3JRDmCBzXXeQxoHSkSN5+qpqZUj7uQBflIuMGAnQ7VGGYcI5CY 5yZhPPwqxUCkMNC0zRp0r8o/ySuwyioHFIS9E6+DhKqX7T7pF0zhRbzUVDFgyX/UQdz6 cDPYmtOFK7uFqmN5pVAOuf3h1aULs1TLU2bUxP0bA78WphYrpgCOYEvaABMc6KDjwIgH l7tA== 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=TF5lGDsoF29RtnRU88g8wViGHUhz869s4sJAnj0wYTU=; fh=bv1xmQMLoUkjMaBG31+T8n2MW2r2VJMdwGgIEDt2AwQ=; b=XCPy0+L+0urV3aL7oFpjxQxL05yfxDehlYH4C2Mk3neGgScqjRJERb2kPGrEcjtdrC svusT/vw4IK16+ZKC0mVRF9jnumfPLsId+s5ev1OhoHIjau2IyTOcaQ1q3+k69lrCwbM xvvDrlqcSZDqtlFwYbqe2hB0ouQa6G8JguYHSyRghtqB7U2rKuVGhiizbX3EVE+Fc+BF zOewMgyyiGOJ/8yYj3H8kHKel5w0TdbuEIfd5FOuxfRvd9ApyhsuckC6VsNlmsmIRH4t aVHJ/c+heSMoW/Sw+4FJqJNGm9/7C0waHEmu3GfMsvqEhFIzY9y5STEQTxNrhl/pYipp 3EfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=iQny1SKi; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-111844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111844-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 v1-20020aa7cd41000000b00568c4c1fd0asi13395edw.481.2024.03.22.10.06.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 10:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111844-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=iQny1SKi; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-111844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111844-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 D734F1F2447E for ; Fri, 22 Mar 2024 17:06:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A576A5FDC8; Fri, 22 Mar 2024 17:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="iQny1SKi" 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 E75BD5D75F; 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=1711127167; cv=none; b=CFab3naLbsnP4MwWmQIWHO3hfj9AnujXoYY9ST1xRqJ6Sd9D0KpRBnWCBUSZRPJdbYipwkRATA7U3IXPdKqHLAF8lCsH/fsBnOedUlB2n01CublcyAolYKUD/HDm8+QXmWF1Ylm3yQKmdgOEctNvrRPdZcfVwK+3gY6FBB4pRRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711127167; c=relaxed/simple; bh=UNKfueCHNBcmXRHOtTAvJsS3aYDsMC1mej59C9wE9T8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J4OGxzDW1zSECvuTycu3qJxusy1kDzTFm1hn0pmXcy7XkSrRkeprBGJz4CIz0yGPNNYpE0+PypDBncj6caq4xBPsaDlPN3qJWdJ/NT3ZSdYl/Cl1g9rwNPMNgjbvPLEQzpJAWL2fZpcdCarHZfmrl/g9l6FnQ7D0GfssXOLanlc= 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=iQny1SKi; 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=UNKfueCHNBcmXRHOtTAvJsS3aYDsMC1mej59C9wE9T8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iQny1SKi+jtKTEA3LueQvoHYfTtxHWpeo92cQQ4OBMF1kOBAbiHy2zciRaL1HQwju BnKdgTXx2QNKvT7ZjfZtRSEGJJMOs3RQWIWwNN/XIlKdBBBg+/wFpEuVeaf1E+p24U O91a9sCeKmiuAZD//CWdJiaEr1JAuaWNYfVSPM2g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 22 Mar 2024 18:05:56 +0100 Subject: [PATCH v2 1/3] sysctl: drop sysctl_is_perm_empty_ctl_table 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-1-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=2025; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=UNKfueCHNBcmXRHOtTAvJsS3aYDsMC1mej59C9wE9T8=; b=5fseNA5fs6C4QJ0MV+zpKMytFpZsRbKFlT5V4AVL7WSkldAQxOgU2euTtH345bsAfsYEJzy5B /x+5sR4hOklDM03BMarh0YPulieYYd6zNDhfTS2c9l/tI1KVZ75l8bu X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= It is used only twice and those callers are simpler with sysctl_is_perm_empty_ctl_header(). So use this sibling function. This is part of an effort to constify definition of struct ctl_table. For this effort the mutable member 'type' is moved from struct ctl_table to struct ctl_table_header. Unifying the macros sysctl_is_perm_empty_ctl_* makes this easier. Signed-off-by: Thomas Weißschuh --- fs/proc/proc_sysctl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 37cde0efee57..2f4d4329d83d 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -48,10 +48,8 @@ struct ctl_table_header *register_sysctl_mount_point(const char *path) } EXPORT_SYMBOL(register_sysctl_mount_point); -#define sysctl_is_perm_empty_ctl_table(tptr) \ - (tptr[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) #define sysctl_is_perm_empty_ctl_header(hptr) \ - (sysctl_is_perm_empty_ctl_table(hptr->ctl_table)) + (hptr->ctl_table[0].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) #define sysctl_set_perm_empty_ctl_header(hptr) \ (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) #define sysctl_clear_perm_empty_ctl_header(hptr) \ @@ -233,7 +231,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) /* Am I creating a permanently empty directory? */ if (header->ctl_table_size > 0 && - sysctl_is_perm_empty_ctl_table(header->ctl_table)) { + sysctl_is_perm_empty_ctl_header(header)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; sysctl_set_perm_empty_ctl_header(dir_h); @@ -1204,7 +1202,7 @@ static bool get_links(struct ctl_dir *dir, struct ctl_table *entry, *link; if (header->ctl_table_size == 0 || - sysctl_is_perm_empty_ctl_table(header->ctl_table)) + sysctl_is_perm_empty_ctl_header(header)) return true; /* Are there links available for every entry in table? */ -- 2.44.0