Const Qualifying

Const qualify the net directory

The reason why net sysctl is not const: #. ensure_safe_net_sysctl call. This will change the ->mode bits (remove

writable) to ensure that the base net sysctl variables are not overridden by nsnet variables.

  1. The kmemdup pattern. A ctl_table array’s .data/.extra fields must point at per-netns storage, so most sites where ctl_table is created can’t register the static array as-is for every namespace.

Note

  • net sysctl use the kmemdup pattern: in order to give a sysctl to a namespace they duplicate a template sysctl and create a “personalized” namespace sysctl.

  • Const qualifying makes sense even though the array gets kmemdup’ed as the original template gets to lived “untouched” in .rodata.

  • For all the patterns that use kmemdup, Don’t try to const qualify. We need another solution for that.!!!!!!

Proposal

  1. The first thing to do to const qualify the net sysctl is to remove the modification in the ensure_save_net_sysctl. This would mean to just return error instead of making it readonly. `Removing the ->mode change`_

  2. The kmemdup pattern. A ctl_table array’s .data/.extra fields must point at per-netns storage, so most sites can’t register the static array as-is. This makes there classes for the call sites: - SAFE-alias (init_net registers the static array untouched), - ALWAYS-DUP (never aliases the global — already const-clean), - IN-PLACE (mutates the global for init_net — the hard cases).

390 internal ctl_table

  • For Now ignore the inner non-const ctl_table definitions for s390.

  • There are two proc_handlers with inner ctl_tables: cmm_pages_handler and cmm_timed_pages_handler.

  • These handle two variables. One variable is used when writing and the other when reading

  • cmm_timed_pages_handler is special in that it does not set the variable when it is in writing mode (its not doing a var=value). It is incrementing the value (its doing a var+=value). This currently does not fit into any proc_handlers.

loadpin_sysctl_table

  • Pending: implement a new proc_handler function that handles the setting of load_root_writable

  • Creating a custom proc_handler: - It is not possible to create a proc_handler that defines param to pass to

    do_proc_dointvec because do_proc_dointvec is static.

    • we need to do like what is done for proc_dointvec_jiffies which defies the push towards moving everything away from sysctl.c

  • We are tackling this in :ref: Release 7.00

  • I see this in mainline ✅ DONE

memory_allocation_profiling_sysctls

  • We are tackling this in :ref: Release 7.00

  • I see this in mainline ✅ DONE