Received: by 2002:a05:6500:1b8a:b0:1ef:a0f1:aef6 with SMTP id df10csp3256lqb; Sun, 10 Mar 2024 01:18:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5IYDS8F9XPPcAs+PCU5Mzgr7wBrIpsdg/YiVzYg+m/b0FFfwZlvbwHkevZ2Q7qz6u99/ejLIyUEv+/5pXIH10MQQ8TmqNH6Coz+F5Ig== X-Google-Smtp-Source: AGHT+IFDnoFKbB/qu/lr2++O0l533MjCLIZjPmuAHDv8WPt7sV6oUtU0l4e2M2xav4L7C8Hr9OHa X-Received: by 2002:a17:906:fb0a:b0:a45:f92d:eeab with SMTP id lz10-20020a170906fb0a00b00a45f92deeabmr1948459ejb.12.1710062314583; Sun, 10 Mar 2024 01:18:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1710062314; cv=pass; d=google.com; s=arc-20160816; b=CNm4O7ObwDHbl6HyMkCzXhQht3mPE7bOPRq+zBal7SjDE3Ok9sVsmjPHYKvYKP26+n ByCnq5MbT28oPN+hMzXOhcQXqvyjmpkTfHmYmXAsbPWqNCtFQR9w6pCrP0yPcfzicDOa ccgwiXfQHNNQoTnBtAmG5ssx9Jfkc6DFDLs6lTwWYTCODCkEkpkPjCZsv5YSzbS1rCSX /bqPwipRFCKXdrYtZ6DbYs48oh/Ky4NQHXyBKo/uCqXHvVjsTTuCrBZ2kFBVPGefpSmg wdJyBf4Wr+pF+SkWt90KRr+QQCA1ZGV5zWFhfnQyYc/hsFahPEeGrYqtKmvHb+I03ga8 k9Tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gYUHEwLq39PIkoN4vHqZFVloZqrkWZUc9ZQqi3klNkg=; fh=K/uDYfemp62/Ebt1NzfuhXKZQUuZk4AqF9HfLsmBPa0=; b=QcrC5O+gNJf/WU/Tgfnc9rc0q1ply+KzbdtAOkXpcyIUv8NuB0jgLTUcnerP7eCU82 DffeAe72+/Bsp0qpbTsYawAozRfr7EzEUdHJ5YaGm8UayWrqrLvfp6hCRjyEOKVPueQq 89o8K9RGqJ/tzyeB+G1gw9UNGYPEkBceCxFpQ8P33MByzmvm0Sl5oSJdQliDnkXeRdjU /HZEQ1Zi8gyCG5jY4aeeVQxlHjJ/wFpiANbi2I5CfrKtfbHbKAcx7gNOJ5ZgnC8jifwz /izjGuI7f0scHGyUFEF6pdW9BRFMb1rCxxX7J/Jh0gMo6IQaWCSHgZsCqgPPYWlLVbJt sWDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=Yz1JSqQ9; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-98166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98166-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 o18-20020a1709064f9200b00a45ad52c44bsi1412703eju.493.2024.03.10.01.18.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Mar 2024 01:18:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98166-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=Yz1JSqQ9; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-98166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98166-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 2ABD51F2137B for ; Sun, 10 Mar 2024 09:18:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A2BF1EB42; Sun, 10 Mar 2024 09:18:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Yz1JSqQ9" 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 5985B1BC49; Sun, 10 Mar 2024 09:18:16 +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=1710062301; cv=none; b=LH7TbgeTK+PobWNjNM8G++T+82NlAsC4P8fKK4n2T70FP2MRRe7uhDuSxRjkkQ9SlTLuHjW1djan63GI1eVaz3qH24XghAi6A1npfqQ5u8oQr6QBSQyY5GpiPRnUKuGG8fOIuD1zwjRIJ2rHKJs89bcgYTkeWtq15CRVGTa2w8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710062301; c=relaxed/simple; bh=4/Etg5IAaCmbmxqxtDclWTx/CGLXoTnwU28WEm0VocA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OTxbQfHt0OWwJ0v4onY154SHC08neG8jMlfidPfvjapcEOFalhqqVjNkCtRH5tZJu/9EzlyoJGV7E4pXgb7V1T2SVkMDfp2W+ey+JokDGaoaBzZXnYDXrsYJ/8KR452OM5063oyhAi8lmV3uhspmXFBBV1oA6n+7/ktkiMfrKVA= 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=Yz1JSqQ9; 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=1710062288; bh=4/Etg5IAaCmbmxqxtDclWTx/CGLXoTnwU28WEm0VocA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Yz1JSqQ9iMbvoFUbuHmRaYiRtps/bZUuKgWK0FcDrfCyxM4eFWcO5PeMGg4tbMZuf 7WIWRQw5Hy1O2U9WjFbFjaVwcq3gJ4LSbMRy5C59qi0SYCwxediET+Xc+HJzZmtQo+ pRLB2xl8ZxwSjYjL/Qd65Ff8HRV+o892y2pdAO4c= Date: Sun, 10 Mar 2024 10:18:07 +0100 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Joel Granados Cc: Luis Chamberlain , Kees Cook , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v2] sysctl: treewide: constify ctl_table_root::permissions Message-ID: References: <20240223-sysctl-const-permissions-v2-1-0f988d0a6548@weissschuh.net> <20240303143408.sxrbd7pykmyhwu5f@joelS2.panther.com> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240303143408.sxrbd7pykmyhwu5f@joelS2.panther.com> Hi! On 2024-03-03 15:34:08+0100, Joel Granados wrote: > Just to be sure I'm following. This is V2 of "[PATCH] sysctl: treewide: > constify ctl_table_root::set_ownership". Right? I ask, because the > subject changes slightly. No, the v1 of this patch is linked in the patch log below. The patches for ::set_ownership and ::permissions are changing two different callbacks and both of them are needed. The v2 for set_ownership is here: https://lore.kernel.org/lkml/20240223-sysctl-const-ownership-v2-1-f9ba1795aaf2@weissschuh.net/ Regards > > Best > > On Fri, Feb 23, 2024 at 04:52:16PM +0100, Thomas Weißschuh wrote: > > The permissions callback is not supposed to modify the ctl_table. > > Enforce this expectation via the typesystem. > > > > The patch was created with the following coccinelle script: > > > > @@ > > identifier func, head, ctl; > > @@ > > > > int func( > > struct ctl_table_header *head, > > - struct ctl_table *ctl) > > + const struct ctl_table *ctl) > > { ... } > > > > (insert_entry() from fs/proc/proc_sysctl.c is a false-positive) > > > > The three changed locations were validated through manually inspection > > and compilation. > > > > In addition a search for '.permissions =' was done over the full tree to > > look for places that were missed by coccinelle. > > None were found. > > > > This change also is a step to put "struct ctl_table" into .rodata > > throughout the kernel. > > > > Signed-off-by: Thomas Weißschuh > > --- > > To: Luis Chamberlain > > To: Kees Cook > > To: Joel Granados > > To: David S. Miller > > Signed-off-by: Thomas Weißschuh > > > > Changes in v2: > > - flesh out commit messages > > - Integrate changes to set_ownership and ctl_table_args into a single > > series > > - Link to v1: https://lore.kernel.org/r/20231226-sysctl-const-permissions-v1-1-5cd3c91f6299@weissschuh.net > > --- > > The patch is meant to be merged via the sysctl tree. > > > > There is an upcoming series that will introduce a new implementation of > > .permission which would need to be adapted [0]. > > The adaption would be trivial as the 'table' parameter also not modified > > there. > > > > This change was originally part of the sysctl-const series [1]. > > To slim down that series and reduce the message load on other > > maintainers to a minimumble, submit this patch on its own. > > > > [0] https://lore.kernel.org/lkml/20240222160915.315255-1-aleksandr.mikhalitsyn@canonical.com/ > > [1] https://lore.kernel.org/lkml/20231204-const-sysctl-v2-2-7a5060b11447@weissschuh.net/ > > --- > > include/linux/sysctl.h | 2 +- > > ipc/ipc_sysctl.c | 2 +- > > kernel/ucount.c | 2 +- > > net/sysctl_net.c | 2 +- > > 4 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h > > index ee7d33b89e9e..0a55b5aade16 100644 > > --- a/include/linux/sysctl.h > > +++ b/include/linux/sysctl.h > > @@ -207,7 +207,7 @@ struct ctl_table_root { > > void (*set_ownership)(struct ctl_table_header *head, > > struct ctl_table *table, > > kuid_t *uid, kgid_t *gid); > > - int (*permissions)(struct ctl_table_header *head, struct ctl_table *table); > > + int (*permissions)(struct ctl_table_header *head, const struct ctl_table *table); > > }; > > > > #define register_sysctl(path, table) \ > > diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c > > index 8c62e443f78b..b087787f608f 100644 > > --- a/ipc/ipc_sysctl.c > > +++ b/ipc/ipc_sysctl.c > > @@ -190,7 +190,7 @@ static int set_is_seen(struct ctl_table_set *set) > > return ¤t->nsproxy->ipc_ns->ipc_set == set; > > } > > > > -static int ipc_permissions(struct ctl_table_header *head, struct ctl_table *table) > > +static int ipc_permissions(struct ctl_table_header *head, const struct ctl_table *table) > > { > > int mode = table->mode; > > > > diff --git a/kernel/ucount.c b/kernel/ucount.c > > index 4aa6166cb856..90300840256b 100644 > > --- a/kernel/ucount.c > > +++ b/kernel/ucount.c > > @@ -38,7 +38,7 @@ static int set_is_seen(struct ctl_table_set *set) > > } > > > > static int set_permissions(struct ctl_table_header *head, > > - struct ctl_table *table) > > + const struct ctl_table *table) > > { > > struct user_namespace *user_ns = > > container_of(head->set, struct user_namespace, set); > > diff --git a/net/sysctl_net.c b/net/sysctl_net.c > > index 051ed5f6fc93..ba9a49de9600 100644 > > --- a/net/sysctl_net.c > > +++ b/net/sysctl_net.c > > @@ -40,7 +40,7 @@ static int is_seen(struct ctl_table_set *set) > > > > /* Return standard mode bits for table entry. */ > > static int net_ctl_permissions(struct ctl_table_header *head, > > - struct ctl_table *table) > > + const struct ctl_table *table) > > { > > struct net *net = container_of(head->set, struct net, sysctls); > > > > > > --- > > base-commit: ffd2cb6b718e189e7e2d5d0c19c25611f92e061a > > change-id: 20231226-sysctl-const-permissions-d7cfd02a7637 > > > > Best regards, > > -- > > Thomas Weißschuh > > > > -- > > Joel Granados