1. 15 Aug, 2023 9 commits
    • Joel Granados's avatar
      ax.25: Update to register_net_sysctl_sz · 7737e46d
      Joel Granados authored
      Move from register_net_sysctl to register_net_sysctl_sz and pass the
      ARRAY_SIZE of the ctl_table array that was used to create the table
      variable. We need to move to the new function in preparation for when we
      change SIZE_MAX to ARRAY_SIZE() in the register_net_sysctl macro.
      Failing to do so would erroneously allow ARRAY_SIZE() to be called on a
      pointer. We hold off the SIZE_MAX to ARRAY_SIZE change until we have
      migrated all the relevant net sysctl registering functions to
      register_net_sysctl_sz in subsequent commits.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      7737e46d
    • Joel Granados's avatar
      sysctl: Add size to register_net_sysctl function · 95d49778
      Joel Granados authored
      This commit adds size to the register_net_sysctl indirection function to
      facilitate the removal of the sentinel elements (last empty markers)
      from the ctl_table arrays. Though we don't actually remove any sentinels
      in this commit, register_net_sysctl* now has the capability of
      forwarding table_size for when that happens.
      
      We create a new function register_net_sysctl_sz with an extra size
      argument. A macro replaces the existing register_net_sysctl. The size in
      the macro is SIZE_MAX instead of ARRAY_SIZE to avoid compilation errors
      while we systematically migrate to register_net_sysctl_sz. Will change
      to ARRAY_SIZE in subsequent commits.
      
      Care is taken to add table_size to the stopping criteria in such a way
      that when we remove the empty sentinel element, it will continue
      stopping in the last element of the ctl_table array.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      95d49778
    • Joel Granados's avatar
      sysctl: Add size arg to __register_sysctl_init · 3bc269cf
      Joel Granados authored
      This commit adds table_size to __register_sysctl_init in preparation for
      the removal of the sentinel elements in the ctl_table arrays (last empty
      markers). And though we do *not* remove any sentinels in this commit, we
      set things up by calculating the ctl_table array size with ARRAY_SIZE.
      
      We add a table_size argument to __register_sysctl_init and modify the
      register_sysctl_init macro to calculate the array size with ARRAY_SIZE.
      The original callers do not need to be updated as they will go through
      the new macro.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      3bc269cf
    • Joel Granados's avatar
      sysctl: Add size to register_sysctl · 9edbfe92
      Joel Granados authored
      This commit adds table_size to register_sysctl in preparation for the
      removal of the sentinel elements in the ctl_table arrays (last empty
      markers). And though we do *not* remove any sentinels in this commit, we
      set things up by either passing the table_size explicitly or using
      ARRAY_SIZE on the ctl_table arrays.
      
      We replace the register_syctl function with a macro that will add the
      ARRAY_SIZE to the new register_sysctl_sz function. In this way the
      callers that are already using an array of ctl_table structs do not
      change. For the callers that pass a ctl_table array pointer, we pass the
      table_size to register_sysctl_sz instead of the macro.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Suggested-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      9edbfe92
    • Joel Granados's avatar
      sysctl: Add a size arg to __register_sysctl_table · bff97cf1
      Joel Granados authored
      We make these changes in order to prepare __register_sysctl_table and
      its callers for when we remove the sentinel element (empty element at
      the end of ctl_table arrays). We don't actually remove any sentinels in
      this commit, but we *do* make sure to use ARRAY_SIZE so the table_size
      is available when the removal occurs.
      
      We add a table_size argument to __register_sysctl_table and adjust
      callers, all of which pass ctl_table pointers and need an explicit call
      to ARRAY_SIZE. We implement a size calculation in register_net_sysctl in
      order to forward the size of the array pointer received from the network
      register calls.
      
      The new table_size argument does not yet have any effect in the
      init_header call which is still dependent on the sentinel's presence.
      table_size *does* however drive the `kzalloc` allocation in
      __register_sysctl_table with no adverse effects as the allocated memory
      is either one element greater than the calculated ctl_table array (for
      the calls in ipc_sysctl.c, mq_sysctl.c and ucount.c) or the exact size
      of the calculated ctl_table array (for the call from sysctl_net.c and
      register_sysctl). This approach will allows us to "just" remove the
      sentinel without further changes to __register_sysctl_table as
      table_size will represent the exact size for all the callers at that
      point.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      bff97cf1
    • Joel Granados's avatar
      sysctl: Add size argument to init_header · b1f01e2b
      Joel Granados authored
      In this commit, we add a table_size argument to the init_header function
      in order to initialize the ctl_table_size variable in ctl_table_header.
      Even though the size is not yet used, it is now initialized within the
      sysctl subsys. We need this commit for when we start adding the
      table_size arguments to the sysctl functions (e.g. register_sysctl,
      __register_sysctl_table and __register_sysctl_init).
      
      Note that in __register_sysctl_table we temporarily use a calculated
      size until we add the size argument to that function in subsequent
      commits.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      b1f01e2b
    • Joel Granados's avatar
      sysctl: Add ctl_table_size to ctl_table_header · 1e887723
      Joel Granados authored
      The new ctl_table_size element will hold the size of the ctl_table
      arrays contained in the ctl_table_header. This value should eventually
      be passed by the callers to the sysctl register infrastructure. And
      while this commit introduces the variable, it does not set nor use it
      because that requires case by case considerations for each caller.
      
      It provides two important things: (1) A place to put the
      result of the ctl_table array calculation when it gets introduced for
      each caller. And (2) the size that will be used as the additional
      stopping criteria in the list_for_each_table_entry macro (to be added
      when all the callers are migrated)
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      1e887723
    • Joel Granados's avatar
      sysctl: Use ctl_table_header in list_for_each_table_entry · 18d4b42e
      Joel Granados authored
      We replace the ctl_table with the ctl_table_header pointer in
      list_for_each_table_entry which is the macro responsible for traversing
      the ctl_table arrays. This is a preparation commit that will make it
      easier to add the ctl_table array size (that will be added to
      ctl_table_header in subsequent commits) to the already existing loop
      logic based on empty ctl_table elements (so called sentinels).
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      18d4b42e
    • Joel Granados's avatar
      sysctl: Prefer ctl_table_header in proc_sysctl · cc9f7ee0
      Joel Granados authored
      This is a preparation commit that replaces ctl_table with
      ctl_table_header as the pointer that is passed around in proc_sysctl.c.
      This will become necessary in subsequent commits when the size of the
      ctl_table array can no longer be calculated by searching for an empty
      sentinel (last empty ctl_table element) but will be carried along inside
      the ctl_table_header struct.
      Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      cc9f7ee0
  2. 09 Jul, 2023 10 commits
  3. 08 Jul, 2023 21 commits