netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] net: constify ctl_table arguments of utility functions
@ 2024-05-27 17:04 Thomas Weißschuh
  2024-05-27 17:04 ` [PATCH net-next 1/5] net/neighbour: constify ctl_table arguments of utility function Thomas Weißschuh
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2024-05-27 17:04 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	David Ahern, Simon Horman, Julian Anastasov, Pablo Neira Ayuso,
	Jozsef Kadlecsik
  Cc: Joel Granados, Luis Chamberlain, netdev, linux-kernel, lvs-devel,
	netfilter-devel, coreteam, Thomas Weißschuh

The sysctl core is preparing to only expose instances of
struct ctl_table as "const".
This will also affect the ctl_table argument of sysctl handlers.

As the function prototype of all sysctl handlers throughout the tree
needs to stay consistent that change will be done in one commit.

To reduce the size of that final commit, switch utility functions which
are not bound by "typedef proc_handler" to "const struct ctl_table".

No functional change.

This patch(set) is meant to be applied through your subsystem tree.
Or at your preference through the sysctl tree.

Motivation
==========

Moving structures containing function pointers into unmodifiable .rodata
prevents attackers or bugs from corrupting and diverting those pointers.

Also the "struct ctl_table" exposed by the sysctl core were never meant
to be mutated by users.

For this goal changes to both the sysctl core and "const" qualifiers for
various sysctl APIs are necessary.

Full Process
============

* Drop ctl_table modifications from the sysctl core ([0], in mainline)
* Constify arguments to ctl_table_root::{set_ownership,permissions}
  ([1], in mainline)
* Migrate users of "ctl_table_header::ctl_table_arg" to "const".
  (in mainline)
* Afterwards convert "ctl_table_header::ctl_table_arg" itself to const.
  (in mainline)
* Prepare helpers used to implement proc_handlers throughout the tree to
  use "const struct ctl_table *". ([2], in progress, this patch)
* Afterwards switch over all proc_handlers callbacks to use
  "const struct ctl_table *" in one commit. ([2], in progress)
  Only custom handlers will be affected, the big commit avoids a
  disruptive and messy transition phase.
* Switch over the internals of the sysctl core to "const struct ctl_table *" (to be done)
* Switch include/linux/sysctl.h to "const struct ctl_table *" (to be done)
* Transition instances of "struct ctl_table" through the tree to const (to be done)

A work-in-progress view containing all the outlined changes can be found at
https://git.sr.ht/~t-8ch/linux sysctl-constfy

[0] https://lore.kernel.org/lkml/20240322-sysctl-empty-dir-v2-0-e559cf8ec7c0@weissschuh.net/
[1] https://lore.kernel.org/lkml/20240315-sysctl-const-ownership-v3-0-b86680eae02e@weissschuh.net/
[2] https://lore.kernel.org/lkml/20240423-sysctl-const-handler-v3-0-e0beccb836e2@weissschuh.net/

---
Thomas Weißschuh (5):
      net/neighbour: constify ctl_table arguments of utility function
      net/ipv4/sysctl: constify ctl_table arguments of utility functions
      net/ipv6/addrconf: constify ctl_table arguments of utility functions
      net/ipv6/ndisc: constify ctl_table arguments of utility function
      ipvs: constify ctl_table arguments of utility functions

 net/core/neighbour.c           | 2 +-
 net/ipv4/sysctl_net_ipv4.c     | 6 ++++--
 net/ipv6/addrconf.c            | 8 ++++----
 net/ipv6/ndisc.c               | 2 +-
 net/netfilter/ipvs/ip_vs_ctl.c | 7 ++++---
 5 files changed, 14 insertions(+), 11 deletions(-)
---
base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
change-id: 20240523-sysctl-const-handler-net-824d4ad5a15a

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-29  2:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27 17:04 [PATCH net-next 0/5] net: constify ctl_table arguments of utility functions Thomas Weißschuh
2024-05-27 17:04 ` [PATCH net-next 1/5] net/neighbour: constify ctl_table arguments of utility function Thomas Weißschuh
2024-05-27 17:04 ` [PATCH net-next 2/5] net/ipv4/sysctl: constify ctl_table arguments of utility functions Thomas Weißschuh
2024-05-27 17:04 ` [PATCH net-next 3/5] net/ipv6/addrconf: " Thomas Weißschuh
2024-05-27 17:04 ` [PATCH net-next 4/5] net/ipv6/ndisc: constify ctl_table arguments of utility function Thomas Weißschuh
2024-05-27 17:04 ` [PATCH net-next 5/5] ipvs: constify ctl_table arguments of utility functions Thomas Weißschuh
2024-05-29  2:57 ` [PATCH net-next 0/5] net: " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).