Re: [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 26, 2023 at 04:06:25PM +0200, Joel Granados wrote:
> This is part of the effort to remove the sentinel element in the
> ctl_table arrays. 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.
> 
> 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.
> 
> Temporarily implement a size calculation in register_net_sysctl, which
> is an indirection call for all the network register calls.
> 
> Signed-off-by: Joel Granados <j.granados@xxxxxxxxxxx>
> ---
>  fs/proc/proc_sysctl.c  | 22 +++++++++++-----------
>  include/linux/sysctl.h |  2 +-
>  ipc/ipc_sysctl.c       |  4 +++-
>  ipc/mq_sysctl.c        |  4 +++-
>  kernel/ucount.c        |  3 ++-
>  net/sysctl_net.c       |  8 +++++++-
>  6 files changed, 27 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index fa1438f1a355..8d04f01a89c1 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -1354,27 +1354,20 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
>   */
>  struct ctl_table_header *__register_sysctl_table(
>  	struct ctl_table_set *set,
> -	const char *path, struct ctl_table *table)
> +	const char *path, struct ctl_table *table, size_t table_size)

Hi Joel,

Please consider adding table_size to the kernel doc for this function.

...



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux