sysctl: treewide: constify ctl_table_header::ctl_table_arg
Subsystems (15)
PATCH v2 1/1 sysctl: treewide: constify ctl_table_header::ctl_table_arg
To be able to constify instances of struct ctl_tables it is necessary to remove ways through which non-const versions are exposed from the sysctl core.
One of these is the ctl_table_arg member of struct ctl_table_header.
Constify this reference as a prerequisite for the full constification of struct ctl_table instances.
No functional change.
---
Changes in v2:
- Add link to original monolithic series
- Send to all maintainers again
- Link to v1: https://lore.kernel.org/r/[email protected]
---
This is a standalone version of PATCH 11 from my original const-sysctl
series at
https://lore.kernel.org/lkml/[email protected]/
It is based upon the branch constfy of
https://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git/
This patch is meant to be applied through the sysctl tree.
It was implemented by manually searching for "ctl_table_arg" throughout the tree and inspecing each found site.
If somebody comes up with a cocciscript for this, I'll be happy to use that.
--- drivers/net/vrf.c | 2 +- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c | 2 +- ipc/mq_sysctl.c | 2 +- kernel/ucount.c | 2 +- net/ax25/sysctl_net_ax25.c | 2 +- net/bridge/br_netfilter_hooks.c | 2 +- net/core/sysctl_net_core.c | 2 +- net/ieee802154/6lowpan/reassembly.c | 2 +- net/ipv4/devinet.c | 2 +- net/ipv4/ip_fragment.c | 2 +- net/ipv4/route.c | 2 +- net/ipv4/sysctl_net_ipv4.c | 2 +- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/addrconf.c | 2 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- net/ipv6/reassembly.c | 2 +- net/ipv6/sysctl_net_ipv6.c | 6 +++--- net/ipv6/xfrm6_policy.c | 2 +- net/mpls/af_mpls.c | 4 ++-- net/mptcp/ctrl.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 2 +- net/netfilter/nf_log.c | 2 +- net/sctp/sysctl.c | 2 +- net/smc/smc_sysctl.c | 2 +- net/unix/sysctl_net_unix.c | 2 +- net/xfrm/xfrm_sysctl.c | 2 +- 27 files changed, 30 insertions(+), 30 deletions(-)
drivers/net/vrf.c +1 -1
@@ -1971,7 +1971,7 @@ static int vrf_netns_init_sysctl(struct net *net, struct netns_vrf *nn_vrf)static void vrf_netns_exit_sysctl (struct net *net) {struct netns_vrf *nn_vrf =net_generic (net, vrf_net_id); -struct ctl_table *table; +const struct ctl_table *table; table = nn_vrf->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (nn_vrf->ctl_hdr);
include/linux/sysctl.h +1 -1
@@ -171,7 +171,7 @@ struct ctl_table_header {struct rcu_head rcu; };struct completion *unregistering; -struct ctl_table *ctl_table_arg; +const struct ctl_table *ctl_table_arg;struct ctl_table_root *root;struct ctl_table_set *set;struct ctl_dir *parent;
ipc/ipc_sysctl.c +1 -1
@@ -305,7 +305,7 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns)void retire_ipc_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->ipc_sysctls->ctl_table_arg;unregister_sysctl_table (ns->ipc_sysctls);
ipc/mq_sysctl.c +1 -1
@@ -159,7 +159,7 @@ bool setup_mq_sysctls(struct ipc_namespace *ns)void retire_mq_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->mq_sysctls->ctl_table_arg;unregister_sysctl_table (ns->mq_sysctls);
kernel/ucount.c +1 -1
@@ -119,7 +119,7 @@ bool setup_userns_sysctls(struct user_namespace *ns)void retire_userns_sysctls (struct user_namespace *ns) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->sysctls->ctl_table_arg;unregister_sysctl_table (ns->sysctls);
net/ax25/sysctl_net_ax25.c +1 -1
@@ -171,7 +171,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)void ax25_unregister_dev_sysctl (ax25_dev *ax25_dev) {struct ctl_table_header *header = ax25_dev->sysheader; -struct ctl_table *table; +const struct ctl_table *table;if (header) { ax25_dev->sysheader =NULL ;
net/bridge/br_netfilter_hooks.c +1 -1
@@ -1268,7 +1268,7 @@ static int br_netfilter_sysctl_init_net(struct net *net)static void br_netfilter_sysctl_exit_net (struct net *net,struct brnf_net *brnet) { -struct ctl_table *table = brnet->ctl_hdr->ctl_table_arg; +const struct ctl_table *table = brnet->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (brnet->ctl_hdr);if (!net_eq (net, &init_net))
net/core/sysctl_net_core.c +1 -1
@@ -743,7 +743,7 @@ static __net_init int sysctl_core_net_init(struct net *net) static __net_exit void sysctl_core_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->core.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->core.sysctl_hdr);
net/ieee802154/6lowpan/reassembly.c +1 -1
@@ -399,7 +399,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) static void __net_exit lowpan_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;struct netns_ieee802154_lowpan *ieee802154_lowpan =net_ieee802154_lowpan (net);
net/ipv4/devinet.c +1 -1
@@ -2749,7 +2749,7 @@ static __net_init int devinet_init_net(struct net *net) static __net_exit void devinet_exit_net(struct net *net) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.forw_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.forw_hdr);
net/ipv4/ip_fragment.c +1 -1
@@ -632,7 +632,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net) static void __net_exit ip4_frags_ns_ctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv4.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.frags_hdr);
net/ipv4/route.c +1 -1
@@ -3590,7 +3590,7 @@ static __net_init int sysctl_route_net_init(struct net *net) static __net_exit void sysctl_route_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.route_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.route_hdr);
net/ipv4/sysctl_net_ipv4.c +1 -1
@@ -1554,7 +1554,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net) static __net_exit void ipv4_sysctl_exit_net(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;kfree (net->ipv4.sysctl_local_reserved_ports); table = net->ipv4.ipv4_hdr->ctl_table_arg;
net/ipv4/xfrm4_policy.c +1 -1
@@ -186,7 +186,7 @@ static __net_init int xfrm4_net_sysctl_init(struct net *net) static __net_exit void xfrm4_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv4.xfrm4_hdr)return ;
net/ipv6/addrconf.c +1 -1
@@ -7235,7 +7235,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,static void __addrconf_sysctl_unregister (struct net *net,struct ipv6_devconf *p,int ifindex) { -struct ctl_table *table; +const struct ctl_table *table;if (!p->sysctl_header)return ;
net/ipv6/netfilter/nf_conntrack_reasm.c +1 -1
@@ -105,7 +105,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net) static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net) {struct nft_ct_frag6_pernet *nf_frag =nf_frag_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = nf_frag->nf_frag_frags_hdr->ctl_table_arg;unregister_net_sysctl_table (nf_frag->nf_frag_frags_hdr);
net/ipv6/reassembly.c +1 -1
@@ -487,7 +487,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net) static void __net_exit ip6_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv6.sysctl.frags_hdr);
net/ipv6/sysctl_net_ipv6.c +3 -3
@@ -313,9 +313,9 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) static void __net_exit ipv6_sysctl_net_exit(struct net *net) { -struct ctl_table *ipv6_table; -struct ctl_table *ipv6_route_table; -struct ctl_table *ipv6_icmp_table; +const struct ctl_table *ipv6_table; +const struct ctl_table *ipv6_route_table; +const struct ctl_table *ipv6_icmp_table; ipv6_table = net->ipv6.sysctl.hdr->ctl_table_arg; ipv6_route_table = net->ipv6.sysctl.route_hdr->ctl_table_arg;
net/ipv6/xfrm6_policy.c +1 -1
@@ -218,7 +218,7 @@ static int __net_init xfrm6_net_sysctl_init(struct net *net) static void __net_exit xfrm6_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv6.sysctl.xfrm6_hdr)return ;
net/mpls/af_mpls.c +2 -2
@@ -1438,7 +1438,7 @@ static void mpls_dev_sysctl_unregister(struct net_device *dev, struct mpls_dev *mdev) {struct net *net =dev_net (dev); -struct ctl_table *table; +const struct ctl_table *table;if (!mdev->sysctl)return ;
@@ -2706,7 +2706,7 @@ static void mpls_net_exit(struct net *net) {struct mpls_route __rcu **platform_label;size_t platform_labels; -struct ctl_table *table; +const struct ctl_table *table;unsigned int index; table = net->mpls.ctl->ctl_table_arg;
net/mptcp/ctrl.c +1 -1
@@ -198,7 +198,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)static void mptcp_pernet_del_table (struct mptcp_pernet *pernet) { -struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg; +const struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg;unregister_net_sysctl_table (pernet->ctl_table_hdr);
net/netfilter/nf_conntrack_standalone.c +1 -1
@@ -1122,7 +1122,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)static void nf_conntrack_standalone_fini_sysctl (struct net *net) {struct nf_conntrack_net *cnet =nf_ct_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = cnet->sysctl_header->ctl_table_arg;unregister_net_sysctl_table (cnet->sysctl_header);
net/netfilter/nf_log.c +1 -1
@@ -514,7 +514,7 @@ static int netfilter_log_sysctl_init(struct net *net)static void netfilter_log_sysctl_exit (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->nf.nf_log_dir_header->ctl_table_arg;unregister_net_sysctl_table (net->nf.nf_log_dir_header);
net/sctp/sysctl.c +1 -1
@@ -624,7 +624,7 @@ int sctp_sysctl_net_register(struct net *net)void sctp_sysctl_net_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->sctp.sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->sctp.sysctl_header);
net/smc/smc_sysctl.c +1 -1
@@ -133,7 +133,7 @@ int __net_init smc_sysctl_net_init(struct net *net) void __net_exit smc_sysctl_net_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->smc.smc_hdr->ctl_table_arg;unregister_net_sysctl_table (net->smc.smc_hdr);
net/unix/sysctl_net_unix.c +1 -1
@@ -52,7 +52,7 @@ int __net_init unix_sysctl_register(struct net *net)void unix_sysctl_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->unx.ctl->ctl_table_arg;unregister_net_sysctl_table (net->unx.ctl);
net/xfrm/xfrm_sysctl.c +1 -1
@@ -76,7 +76,7 @@ int __net_init xfrm_sysctl_init(struct net *net) void __net_exit xfrm_sysctl_fini(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->xfrm.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->xfrm.sysctl_hdr);
---
base-commit: 48a8b5270db856be233021e47a5f1dc02d47ed0d
change-id: 20231226-sysctl-const-table-arg-2c828e0264dc
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
Hi Thomas,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8735953278
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/33b9e702a248
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=845722
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Quoted 23 lines · Thomas Weißschuh
To be able to constify instances of struct
ctl_tablesit is necessary to remove ways through which non-const versions are exposed from the sysctl core.
One of these is thectl_table_argmember of structctl_table_header.Constify this reference as a prerequisite for the full constification of struct
ctl_tableinstances.
No functional change.Signed-off-by Thomas Weißschuh <[email protected]>---
Changes in v2:
- Add link to original monolithic series
- Send to all maintainers again
- Link to v1: https://lore.kernel.org/r/[email protected]
---
This is a standalone version of PATCH 11 from my original const-sysctl
series at
https://lore.kernel.org/lkml/[email protected]/It is based upon the branch constfy of
https://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git/
Quoted 7 lines
This patch is meant to be applied through the sysctl tree.
It was implemented by manually searching for "
ctl_table_arg" throughout the tree and inspecing each found site.If somebody comes up with a cocciscript for this, I'll be happy to use that.
My simple attempt doesn't find any additional instances:
@constify@
identifier VAR;
expression EXP;
@@
- struct ctl_table *VAR;
+ const struct ctl_table *VAR;
...
VAR = (EXP)->ctl_table_argit actually misses a few. :P
Quoted 403 lines
--- drivers/net/vrf.c | 2 +- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c | 2 +- ipc/mq_sysctl.c | 2 +- kernel/ucount.c | 2 +- net/ax25/sysctl_net_ax25.c | 2 +- net/bridge/br_netfilter_hooks.c | 2 +- net/core/sysctl_net_core.c | 2 +- net/ieee802154/6lowpan/reassembly.c | 2 +- net/ipv4/devinet.c | 2 +- net/ipv4/ip_fragment.c | 2 +- net/ipv4/route.c | 2 +- net/ipv4/sysctl_net_ipv4.c | 2 +- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/addrconf.c | 2 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- net/ipv6/reassembly.c | 2 +- net/ipv6/sysctl_net_ipv6.c | 6 +++--- net/ipv6/xfrm6_policy.c | 2 +- net/mpls/af_mpls.c | 4 ++-- net/mptcp/ctrl.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 2 +- net/netfilter/nf_log.c | 2 +- net/sctp/sysctl.c | 2 +- net/smc/smc_sysctl.c | 2 +- net/unix/sysctl_net_unix.c | 2 +- net/xfrm/xfrm_sysctl.c | 2 +- 27 files changed, 30 insertions(+), 30 deletions(-)drivers/net/vrf.c +1
-1@@ -1971,7 +1971,7 @@ static int vrf_netns_init_sysctl(struct net *net, struct netns_vrf *nn_vrf)static void vrf_netns_exit_sysctl (struct net *net) {struct netns_vrf *nn_vrf =net_generic (net, vrf_net_id); -struct ctl_table *table; +const struct ctl_table *table; table = nn_vrf->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (nn_vrf->ctl_hdr);include/linux/sysctl.h +1
-1@@ -171,7 +171,7 @@ struct ctl_table_header {struct rcu_head rcu; };struct completion *unregistering; -struct ctl_table *ctl_table_arg; +const struct ctl_table *ctl_table_arg;struct ctl_table_root *root;struct ctl_table_set *set;struct ctl_dir *parent;ipc/ipc_sysctl.c +1
-1@@ -305,7 +305,7 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns)void retire_ipc_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->ipc_sysctls->ctl_table_arg;unregister_sysctl_table (ns->ipc_sysctls);ipc/mq_sysctl.c +1
-1@@ -159,7 +159,7 @@ bool setup_mq_sysctls(struct ipc_namespace *ns)void retire_mq_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->mq_sysctls->ctl_table_arg;unregister_sysctl_table (ns->mq_sysctls);kernel/ucount.c +1
-1@@ -119,7 +119,7 @@ bool setup_userns_sysctls(struct user_namespace *ns)void retire_userns_sysctls (struct user_namespace *ns) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->sysctls->ctl_table_arg;unregister_sysctl_table (ns->sysctls);net/ax25/sysctl_net_ax25.c +1
-1@@ -171,7 +171,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)void ax25_unregister_dev_sysctl (ax25_dev *ax25_dev) {struct ctl_table_header *header = ax25_dev->sysheader; -struct ctl_table *table; +const struct ctl_table *table;if (header) { ax25_dev->sysheader =NULL ;net/bridge/br_netfilter_hooks.c +1
-1@@ -1268,7 +1268,7 @@ static int br_netfilter_sysctl_init_net(struct net *net)static void br_netfilter_sysctl_exit_net (struct net *net,struct brnf_net *brnet) { -struct ctl_table *table = brnet->ctl_hdr->ctl_table_arg; +const struct ctl_table *table = brnet->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (brnet->ctl_hdr);if (!net_eq (net, &init_net))net/core/sysctl_net_core.c +1
-1@@ -743,7 +743,7 @@ static __net_init int sysctl_core_net_init(struct net *net) static __net_exit void sysctl_core_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->core.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->core.sysctl_hdr);net/ieee802154/6lowpan/reassembly.c +1
-1@@ -399,7 +399,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) static void __net_exit lowpan_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;struct netns_ieee802154_lowpan *ieee802154_lowpan =net_ieee802154_lowpan (net);net/ipv4/devinet.c +1
-1@@ -2749,7 +2749,7 @@ static __net_init int devinet_init_net(struct net *net) static __net_exit void devinet_exit_net(struct net *net) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.forw_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.forw_hdr);net/ipv4/ip_fragment.c +1
-1@@ -632,7 +632,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net) static void __net_exit ip4_frags_ns_ctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv4.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.frags_hdr);net/ipv4/route.c +1
-1@@ -3590,7 +3590,7 @@ static __net_init int sysctl_route_net_init(struct net *net) static __net_exit void sysctl_route_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.route_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.route_hdr);net/ipv4/sysctl_net_ipv4.c +1
-1@@ -1554,7 +1554,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net) static __net_exit void ipv4_sysctl_exit_net(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;kfree (net->ipv4.sysctl_local_reserved_ports); table = net->ipv4.ipv4_hdr->ctl_table_arg;net/ipv4/xfrm4_policy.c +1
-1@@ -186,7 +186,7 @@ static __net_init int xfrm4_net_sysctl_init(struct net *net) static __net_exit void xfrm4_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv4.xfrm4_hdr)return ;net/ipv6/addrconf.c +1
-1@@ -7235,7 +7235,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,static void __addrconf_sysctl_unregister (struct net *net,struct ipv6_devconf *p,int ifindex) { -struct ctl_table *table; +const struct ctl_table *table;if (!p->sysctl_header)return ;net/ipv6/netfilter/nf_conntrack_reasm.c +1
-1@@ -105,7 +105,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net) static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net) {struct nft_ct_frag6_pernet *nf_frag =nf_frag_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = nf_frag->nf_frag_frags_hdr->ctl_table_arg;unregister_net_sysctl_table (nf_frag->nf_frag_frags_hdr);net/ipv6/reassembly.c +1
-1@@ -487,7 +487,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net) static void __net_exit ip6_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv6.sysctl.frags_hdr);net/ipv6/sysctl_net_ipv6.c +3
-3@@ -313,9 +313,9 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) static void __net_exit ipv6_sysctl_net_exit(struct net *net) { -struct ctl_table *ipv6_table; -struct ctl_table *ipv6_route_table; -struct ctl_table *ipv6_icmp_table; +const struct ctl_table *ipv6_table; +const struct ctl_table *ipv6_route_table; +const struct ctl_table *ipv6_icmp_table; ipv6_table = net->ipv6.sysctl.hdr->ctl_table_arg; ipv6_route_table = net->ipv6.sysctl.route_hdr->ctl_table_arg;net/ipv6/xfrm6_policy.c +1
-1@@ -218,7 +218,7 @@ static int __net_init xfrm6_net_sysctl_init(struct net *net) static void __net_exit xfrm6_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv6.sysctl.xfrm6_hdr)return ;net/mpls/af_mpls.c +2
-2@@ -1438,7 +1438,7 @@ static void mpls_dev_sysctl_unregister(struct net_device *dev, struct mpls_dev *mdev) {struct net *net =dev_net (dev); -struct ctl_table *table; +const struct ctl_table *table;if (!mdev->sysctl)return ;@@ -2706,7 +2706,7 @@ static void mpls_net_exit(struct net *net) {struct mpls_route __rcu **platform_label;size_t platform_labels; -struct ctl_table *table; +const struct ctl_table *table;unsigned int index; table = net->mpls.ctl->ctl_table_arg;net/mptcp/ctrl.c +1
-1@@ -198,7 +198,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)static void mptcp_pernet_del_table (struct mptcp_pernet *pernet) { -struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg; +const struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg;unregister_net_sysctl_table (pernet->ctl_table_hdr);net/netfilter/nf_conntrack_standalone.c +1
-1@@ -1122,7 +1122,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)static void nf_conntrack_standalone_fini_sysctl (struct net *net) {struct nf_conntrack_net *cnet =nf_ct_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = cnet->sysctl_header->ctl_table_arg;unregister_net_sysctl_table (cnet->sysctl_header);net/netfilter/nf_log.c +1
-1@@ -514,7 +514,7 @@ static int netfilter_log_sysctl_init(struct net *net)static void netfilter_log_sysctl_exit (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->nf.nf_log_dir_header->ctl_table_arg;unregister_net_sysctl_table (net->nf.nf_log_dir_header);net/sctp/sysctl.c +1
-1@@ -624,7 +624,7 @@ int sctp_sysctl_net_register(struct net *net)void sctp_sysctl_net_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->sctp.sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->sctp.sysctl_header);net/smc/smc_sysctl.c +1
-1@@ -133,7 +133,7 @@ int __net_init smc_sysctl_net_init(struct net *net) void __net_exit smc_sysctl_net_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->smc.smc_hdr->ctl_table_arg;unregister_net_sysctl_table (net->smc.smc_hdr);net/unix/sysctl_net_unix.c +1
-1@@ -52,7 +52,7 @@ int __net_init unix_sysctl_register(struct net *net)void unix_sysctl_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->unx.ctl->ctl_table_arg;unregister_net_sysctl_table (net->unx.ctl);net/xfrm/xfrm_sysctl.c +1
-2@@ -76,7 +76,7 @@ int __net_init xfrm_sysctl_init(struct net *net) void __net_exit xfrm_sysctl_fini(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->xfrm.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->xfrm.sysctl_hdr); ---base-commit:
48a8b5270db856be233021e47a5f1dc02d47ed0d
change-id: 20231226-sysctl-const-table-arg-2c828e0264dcBest regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
Signature · 1 line
Kees Cook
Quoted 51 lines · Thomas Weißschuh
To be able to constify instances of struct
ctl_tablesit is necessary to remove ways through which non-const versions are exposed from the sysctl core.
One of these is thectl_table_argmember of structctl_table_header.Constify this reference as a prerequisite for the full constification of struct
ctl_tableinstances.
No functional change.Signed-off-by Thomas Weißschuh <[email protected]>---
Changes in v2:
- Add link to original monolithic series
- Send to all maintainers again
- Link to v1: https://lore.kernel.org/r/[email protected]
---
This is a standalone version of PATCH 11 from my original const-sysctl
series at
https://lore.kernel.org/lkml/[email protected]/It is based upon the branch constfy of
https://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git/This patch is meant to be applied through the sysctl tree.
It was implemented by manually searching for "
ctl_table_arg" throughout the tree and inspecing each found site.If somebody comes up with a cocciscript for this, I'll be happy to use that.
--- drivers/net/vrf.c | 2 +- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c | 2 +- ipc/mq_sysctl.c | 2 +- kernel/ucount.c | 2 +- net/ax25/sysctl_net_ax25.c | 2 +- net/bridge/br_netfilter_hooks.c | 2 +- net/core/sysctl_net_core.c | 2 +- net/ieee802154/6lowpan/reassembly.c | 2 +- net/ipv4/devinet.c | 2 +- net/ipv4/ip_fragment.c | 2 +- net/ipv4/route.c | 2 +- net/ipv4/sysctl_net_ipv4.c | 2 +- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/addrconf.c | 2 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- net/ipv6/reassembly.c | 2 +- net/ipv6/sysctl_net_ipv6.c | 6 +++--- net/ipv6/xfrm6_policy.c | 2 +- net/mpls/af_mpls.c | 4 ++--
Quoted 8 lines
net/mptcp/ctrl.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 2 +- net/netfilter/nf_log.c | 2 +- net/sctp/sysctl.c | 2 +- net/smc/smc_sysctl.c | 2 +- net/unix/sysctl_net_unix.c | 2 +- net/xfrm/xfrm_sysctl.c | 2 +- 27 files changed, 30 insertions(+), 30 deletions(-)
I see that Kees has reviewed this, but most of it falls in the network subsystem. At this point I see three options:
1. I queue it all up in the sysctl changes going into 6.11 and it make its way to mainline that way.
2. Since its mostly network, it can all go through that path
3. We split this up into netwokring and non-networking changes and each takes its separate path.
I would like to hear from the network folks on these options.
Best
Quoted 374 lines
drivers/net/vrf.c +1
-1@@ -1971,7 +1971,7 @@ static int vrf_netns_init_sysctl(struct net *net, struct netns_vrf *nn_vrf)static void vrf_netns_exit_sysctl (struct net *net) {struct netns_vrf *nn_vrf =net_generic (net, vrf_net_id); -struct ctl_table *table; +const struct ctl_table *table; table = nn_vrf->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (nn_vrf->ctl_hdr);include/linux/sysctl.h +1
-1@@ -171,7 +171,7 @@ struct ctl_table_header {struct rcu_head rcu; };struct completion *unregistering; -struct ctl_table *ctl_table_arg; +const struct ctl_table *ctl_table_arg;struct ctl_table_root *root;struct ctl_table_set *set;struct ctl_dir *parent;ipc/ipc_sysctl.c +1
-1@@ -305,7 +305,7 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns)void retire_ipc_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->ipc_sysctls->ctl_table_arg;unregister_sysctl_table (ns->ipc_sysctls);ipc/mq_sysctl.c +1
-1@@ -159,7 +159,7 @@ bool setup_mq_sysctls(struct ipc_namespace *ns)void retire_mq_sysctls (struct ipc_namespace *ns) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->mq_sysctls->ctl_table_arg;unregister_sysctl_table (ns->mq_sysctls);kernel/ucount.c +1
-1@@ -119,7 +119,7 @@ bool setup_userns_sysctls(struct user_namespace *ns)void retire_userns_sysctls (struct user_namespace *ns) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = ns->sysctls->ctl_table_arg;unregister_sysctl_table (ns->sysctls);net/ax25/sysctl_net_ax25.c +1
-1@@ -171,7 +171,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)void ax25_unregister_dev_sysctl (ax25_dev *ax25_dev) {struct ctl_table_header *header = ax25_dev->sysheader; -struct ctl_table *table; +const struct ctl_table *table;if (header) { ax25_dev->sysheader =NULL ;net/bridge/br_netfilter_hooks.c +1
-1@@ -1268,7 +1268,7 @@ static int br_netfilter_sysctl_init_net(struct net *net)static void br_netfilter_sysctl_exit_net (struct net *net,struct brnf_net *brnet) { -struct ctl_table *table = brnet->ctl_hdr->ctl_table_arg; +const struct ctl_table *table = brnet->ctl_hdr->ctl_table_arg;unregister_net_sysctl_table (brnet->ctl_hdr);if (!net_eq (net, &init_net))net/core/sysctl_net_core.c +1
-1@@ -743,7 +743,7 @@ static __net_init int sysctl_core_net_init(struct net *net) static __net_exit void sysctl_core_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->core.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->core.sysctl_hdr);net/ieee802154/6lowpan/reassembly.c +1
-1@@ -399,7 +399,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) static void __net_exit lowpan_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;struct netns_ieee802154_lowpan *ieee802154_lowpan =net_ieee802154_lowpan (net);net/ipv4/devinet.c +1
-1@@ -2749,7 +2749,7 @@ static __net_init int devinet_init_net(struct net *net) static __net_exit void devinet_exit_net(struct net *net) {#ifdef CONFIG_SYSCTL -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.forw_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.forw_hdr);net/ipv4/ip_fragment.c +1
-1@@ -632,7 +632,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net) static void __net_exit ip4_frags_ns_ctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv4.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.frags_hdr);net/ipv4/route.c +1
-1@@ -3590,7 +3590,7 @@ static __net_init int sysctl_route_net_init(struct net *net) static __net_exit void sysctl_route_net_exit(struct net *net) { -struct ctl_table *tbl; +const struct ctl_table *tbl; tbl = net->ipv4.route_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.route_hdr);net/ipv4/sysctl_net_ipv4.c +1
-1@@ -1554,7 +1554,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net) static __net_exit void ipv4_sysctl_exit_net(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;kfree (net->ipv4.sysctl_local_reserved_ports); table = net->ipv4.ipv4_hdr->ctl_table_arg;net/ipv4/xfrm4_policy.c +1
-1@@ -186,7 +186,7 @@ static __net_init int xfrm4_net_sysctl_init(struct net *net) static __net_exit void xfrm4_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv4.xfrm4_hdr)return ;net/ipv6/addrconf.c +1
-1@@ -7235,7 +7235,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,static void __addrconf_sysctl_unregister (struct net *net,struct ipv6_devconf *p,int ifindex) { -struct ctl_table *table; +const struct ctl_table *table;if (!p->sysctl_header)return ;net/ipv6/netfilter/nf_conntrack_reasm.c +1
-1@@ -105,7 +105,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net) static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net) {struct nft_ct_frag6_pernet *nf_frag =nf_frag_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = nf_frag->nf_frag_frags_hdr->ctl_table_arg;unregister_net_sysctl_table (nf_frag->nf_frag_frags_hdr);net/ipv6/reassembly.c +1
-1@@ -487,7 +487,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net) static void __net_exit ip6_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv6.sysctl.frags_hdr);net/ipv6/sysctl_net_ipv6.c +3
-3@@ -313,9 +313,9 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) static void __net_exit ipv6_sysctl_net_exit(struct net *net) { -struct ctl_table *ipv6_table; -struct ctl_table *ipv6_route_table; -struct ctl_table *ipv6_icmp_table; +const struct ctl_table *ipv6_table; +const struct ctl_table *ipv6_route_table; +const struct ctl_table *ipv6_icmp_table; ipv6_table = net->ipv6.sysctl.hdr->ctl_table_arg; ipv6_route_table = net->ipv6.sysctl.route_hdr->ctl_table_arg;net/ipv6/xfrm6_policy.c +1
-1@@ -218,7 +218,7 @@ static int __net_init xfrm6_net_sysctl_init(struct net *net) static void __net_exit xfrm6_net_sysctl_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table;if (!net->ipv6.sysctl.xfrm6_hdr)return ;net/mpls/af_mpls.c +2
-2@@ -1438,7 +1438,7 @@ static void mpls_dev_sysctl_unregister(struct net_device *dev, struct mpls_dev *mdev) {struct net *net =dev_net (dev); -struct ctl_table *table; +const struct ctl_table *table;if (!mdev->sysctl)return ;@@ -2706,7 +2706,7 @@ static void mpls_net_exit(struct net *net) {struct mpls_route __rcu **platform_label;size_t platform_labels; -struct ctl_table *table; +const struct ctl_table *table;unsigned int index; table = net->mpls.ctl->ctl_table_arg;net/mptcp/ctrl.c +1
-1@@ -198,7 +198,7 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)static void mptcp_pernet_del_table (struct mptcp_pernet *pernet) { -struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg; +const struct ctl_table *table = pernet->ctl_table_hdr->ctl_table_arg;unregister_net_sysctl_table (pernet->ctl_table_hdr);net/netfilter/nf_conntrack_standalone.c +1
-1@@ -1122,7 +1122,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)static void nf_conntrack_standalone_fini_sysctl (struct net *net) {struct nf_conntrack_net *cnet =nf_ct_pernet (net); -struct ctl_table *table; +const struct ctl_table *table; table = cnet->sysctl_header->ctl_table_arg;unregister_net_sysctl_table (cnet->sysctl_header);net/netfilter/nf_log.c +1
-1@@ -514,7 +514,7 @@ static int netfilter_log_sysctl_init(struct net *net)static void netfilter_log_sysctl_exit (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->nf.nf_log_dir_header->ctl_table_arg;unregister_net_sysctl_table (net->nf.nf_log_dir_header);net/sctp/sysctl.c +1
-1@@ -624,7 +624,7 @@ int sctp_sysctl_net_register(struct net *net)void sctp_sysctl_net_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->sctp.sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->sctp.sysctl_header);net/smc/smc_sysctl.c +1
-1@@ -133,7 +133,7 @@ int __net_init smc_sysctl_net_init(struct net *net) void __net_exit smc_sysctl_net_exit(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->smc.smc_hdr->ctl_table_arg;unregister_net_sysctl_table (net->smc.smc_hdr);net/unix/sysctl_net_unix.c +1
-1@@ -52,7 +52,7 @@ int __net_init unix_sysctl_register(struct net *net)void unix_sysctl_unregister (struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->unx.ctl->ctl_table_arg;unregister_net_sysctl_table (net->unx.ctl);net/xfrm/xfrm_sysctl.c +1
-2@@ -76,7 +76,7 @@ int __net_init xfrm_sysctl_init(struct net *net) void __net_exit xfrm_sysctl_fini(struct net *net) { -struct ctl_table *table; +const struct ctl_table *table; table = net->xfrm.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->xfrm.sysctl_hdr); ---base-commit:
48a8b5270db856be233021e47a5f1dc02d47ed0d
change-id: 20231226-sysctl-const-table-arg-2c828e0264dcBest regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
Signature · 1 line
Joel Granados