Commit a05aea98 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'sysctl-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux

Pull sysctl updates from Luis Chamberlain:
 "To help make the move of sysctls out of kernel/sysctl.c not incur a
  size penalty sysctl has been changed to allow us to not require the
  sentinel, the final empty element on the sysctl array. Joel Granados
  has been doing all this work.

  In the v6.6 kernel we got the major infrastructure changes required to
  support this. For v6.7 we had all arch/ and drivers/ modified to
  remove the sentinel. For v6.8-rc1 we get a few more updates for fs/
  directory only.

  The kernel/ directory is left but we'll save that for v6.9-rc1 as
  those patches are still being reviewed. After that we then can expect
  also the removal of the no longer needed check for procname == NULL.

  Let us recap the purpose of this work:

   - this helps reduce the overall build time size of the kernel and run
     time memory consumed by the kernel by about ~64 bytes per array

   - the extra 64-byte penalty is no longer inncurred now when we move
     sysctls out from kernel/sysctl.c to their own files

  Thomas Weißschuh also sent a few cleanups, for v6.9-rc1 we expect to
  see further work by Thomas Weißschuh with the constificatin of the
  struct ctl_table.

  Due to Joel Granados's work, and to help bring in new blood, I have
  suggested for him to become a maintainer and he's accepted. So for
  v6.9-rc1 I look forward to seeing him sent you a pull request for
  further sysctl changes. This also removes Iurii Zaikin as a maintainer
  as he has moved on to other projects and has had no time to help at
  all"

* tag 'sysctl-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux:
  sysctl: remove struct ctl_path
  sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR
  coda: Remove the now superfluous sentinel elements from ctl_table array
  sysctl: Remove the now superfluous sentinel elements from ctl_table array
  fs: Remove the now superfluous sentinel elements from ctl_table array
  cachefiles: Remove the now superfluous sentinel element from ctl_table array
  sysclt: Clarify the results of selftest run
  sysctl: Add a selftest for handling empty dirs
  sysctl: Fix out of bounds access for empty sysctl registers
  MAINTAINERS: Add Joel Granados as co-maintainer for proc sysctl
  MAINTAINERS: remove Iurii Zaikin from proc sysctl
parents 78273df7 56142980
......@@ -17412,7 +17412,7 @@ F: tools/testing/selftests/proc/
PROC SYSCTL
M: Luis Chamberlain <mcgrof@kernel.org>
M: Kees Cook <keescook@chromium.org>
M: Iurii Zaikin <yzaikin@google.com>
M: Joel Granados <j.granados@samsung.com>
L: linux-kernel@vger.kernel.org
L: linux-fsdevel@vger.kernel.org
S: Maintained
......
......@@ -239,7 +239,6 @@ static struct ctl_table aio_sysctls[] = {
.mode = 0644,
.proc_handler = proc_doulongvec_minmax,
},
{}
};
static void __init aio_sysctl_init(void)
......
......@@ -19,7 +19,6 @@ static struct ctl_table cachefiles_sysctls[] = {
.mode = 0644,
.proc_handler = proc_douintvec,
},
{}
};
int __init cachefiles_register_error_injection(void)
......
......@@ -36,7 +36,6 @@ static struct ctl_table coda_table[] = {
.mode = 0600,
.proc_handler = proc_dointvec
},
{}
};
void coda_sysctl_init(void)
......
......@@ -981,7 +981,6 @@ static struct ctl_table coredump_sysctls[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ }
};
static int __init init_fs_coredump_sysctls(void)
......
......@@ -191,7 +191,6 @@ static struct ctl_table fs_dcache_sysctls[] = {
.mode = 0444,
.proc_handler = proc_nr_dentry,
},
{ }
};
static int __init init_fs_dcache_sysctls(void)
......
......@@ -69,7 +69,6 @@ static struct ctl_table pty_table[] = {
.data = &pty_count,
.proc_handler = proc_dointvec,
},
{}
};
struct pts_mount_opts {
......
......@@ -322,7 +322,6 @@ static struct ctl_table epoll_table[] = {
.extra1 = &long_zero,
.extra2 = &long_max,
},
{ }
};
static void __init epoll_sysctls_init(void)
......
......@@ -2165,7 +2165,6 @@ static struct ctl_table fs_exec_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
{ }
};
static int __init init_fs_exec_sysctls(void)
......
......@@ -130,7 +130,6 @@ static struct ctl_table fs_stat_sysctls[] = {
.extra1 = &sysctl_nr_open_min,
.extra2 = &sysctl_nr_open_max,
},
{ }
};
static int __init init_fs_stat_sysctls(void)
......
......@@ -129,7 +129,6 @@ static struct ctl_table inodes_sysctls[] = {
.mode = 0444,
.proc_handler = proc_nr_inodes,
},
{ }
};
static int __init init_fs_inode_sysctls(void)
......
......@@ -473,7 +473,6 @@ static struct ctl_table nlm_sysctls[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ }
};
#endif /* CONFIG_SYSCTL */
......
......@@ -111,7 +111,6 @@ static struct ctl_table locks_sysctls[] = {
.proc_handler = proc_dointvec,
},
#endif /* CONFIG_MMU */
{}
};
static int __init init_fs_locks_sysctls(void)
......
......@@ -1071,7 +1071,6 @@ static struct ctl_table namei_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_TWO,
},
{ }
};
static int __init init_fs_namei_sysctls(void)
......
......@@ -5447,7 +5447,6 @@ static struct ctl_table fs_namespace_sysctls[] = {
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ONE,
},
{ }
};
static int __init init_fs_namespace_sysctls(void)
......
......@@ -34,7 +34,6 @@ static struct ctl_table nfs4_cb_sysctls[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ }
};
int nfs4_register_sysctl(void)
......
......@@ -29,7 +29,6 @@ static struct ctl_table nfs_cb_sysctls[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ }
};
int nfs_register_sysctl(void)
......
......@@ -29,7 +29,6 @@ static struct ctl_table dnotify_sysctls[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{}
};
static void __init dnotify_sysctl_init(void)
{
......
......@@ -86,7 +86,6 @@ static struct ctl_table fanotify_table[] = {
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO
},
{ }
};
static void __init fanotify_sysctls_init(void)
......
......@@ -85,7 +85,6 @@ static struct ctl_table inotify_table[] = {
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO
},
{ }
};
static void __init inotify_sysctls_init(void)
......
......@@ -28,7 +28,6 @@ static struct ctl_table ntfs_sysctls[] = {
.mode = 0644, /* Mode, proc handler. */
.proc_handler = proc_dointvec
},
{}
};
/* Storage for the sysctls header. */
......
......@@ -658,7 +658,6 @@ static struct ctl_table ocfs2_nm_table[] = {
.mode = 0644,
.proc_handler = proc_dostring,
},
{ }
};
static struct ctl_table_header *ocfs2_table_header;
......
......@@ -1507,7 +1507,6 @@ static struct ctl_table fs_pipe_sysctls[] = {
.mode = 0644,
.proc_handler = proc_doulongvec_minmax,
},
{ }
};
#endif
......
......@@ -44,7 +44,7 @@ static struct ctl_table sysctl_mount_point[] = {
*/
struct ctl_table_header *register_sysctl_mount_point(const char *path)
{
return register_sysctl_sz(path, sysctl_mount_point, 0);
return register_sysctl(path, sysctl_mount_point);
}
EXPORT_SYMBOL(register_sysctl_mount_point);
......@@ -71,7 +71,6 @@ static struct ctl_table root_table[] = {
.procname = "",
.mode = S_IFDIR|S_IRUGO|S_IXUGO,
},
{ }
};
static struct ctl_table_root sysctl_table_root = {
.default_set.dir.header = {
......@@ -233,7 +232,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)
return -EROFS;
/* Am I creating a permanently empty directory? */
if (sysctl_is_perm_empty_ctl_table(header->ctl_table)) {
if (header->ctl_table_size > 0 &&
sysctl_is_perm_empty_ctl_table(header->ctl_table)) {
if (!RB_EMPTY_ROOT(&dir->root))
return -EINVAL;
sysctl_set_perm_empty_ctl_header(dir_h);
......@@ -1213,6 +1213,10 @@ static bool get_links(struct ctl_dir *dir,
struct ctl_table_header *tmp_head;
struct ctl_table *entry, *link;
if (header->ctl_table_size == 0 ||
sysctl_is_perm_empty_ctl_table(header->ctl_table))
return true;
/* Are there links available for every entry in table? */
list_for_each_table_entry(entry, header) {
const char *procname = entry->procname;
......
......@@ -2969,7 +2969,6 @@ static struct ctl_table fs_dqstats_table[] = {
.proc_handler = proc_dointvec,
},
#endif
{ },
};
static int __init dquot_init(void)
......
......@@ -26,7 +26,6 @@ static struct ctl_table fs_shared_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_MAXOLDUID,
},
{ }
};
static int __init init_fs_sysctls(void)
......
......@@ -45,7 +45,6 @@ static struct ctl_table vm_userfaultfd_table[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
{ }
};
#endif
......
......@@ -24,7 +24,6 @@ static struct ctl_table fsverity_sysctl_table[] = {
.extra2 = SYSCTL_ONE,
},
#endif
{ }
};
static void __init fsverity_init_sysctl(void)
......
......@@ -206,8 +206,6 @@ static struct ctl_table xfs_table[] = {
.extra2 = &xfs_params.stats_clear.max
},
#endif /* CONFIG_PROC_FS */
{}
};
int
......
......@@ -210,11 +210,6 @@ struct ctl_table_root {
int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
};
/* struct ctl_path describes where in the hierarchy a table is added */
struct ctl_path {
const char *procname;
};
#define register_sysctl(path, table) \
register_sysctl_sz(path, table, ARRAY_SIZE(table))
......@@ -255,8 +250,6 @@ extern int unaligned_enabled;
extern int unaligned_dump_stack;
extern int no_unaligned_warning;
#define SYSCTL_PERM_EMPTY_DIR (1 << 0)
#else /* CONFIG_SYSCTL */
static inline void register_sysctl_init(const char *path, struct ctl_table *table)
......
......@@ -35,6 +35,8 @@ static struct {
struct ctl_table_header *test_h_setup_node;
struct ctl_table_header *test_h_mnt;
struct ctl_table_header *test_h_mnterror;
struct ctl_table_header *empty_add;
struct ctl_table_header *empty;
} sysctl_test_headers;
struct test_sysctl_data {
......@@ -130,7 +132,6 @@ static struct ctl_table test_table[] = {
.mode = 0644,
.proc_handler = proc_do_large_bitmap,
},
{ }
};
static void test_sysctl_calc_match_int_ok(void)
......@@ -184,7 +185,6 @@ static struct ctl_table test_table_unregister[] = {
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
},
{}
};
static int test_sysctl_run_unregister_nested(void)
......@@ -220,6 +220,25 @@ static int test_sysctl_run_register_mount_point(void)
return 0;
}
static struct ctl_table test_table_empty[] = { };
static int test_sysctl_run_register_empty(void)
{
/* Tets that an empty dir can be created */
sysctl_test_headers.empty_add
= register_sysctl("debug/test_sysctl/empty_add", test_table_empty);
if (!sysctl_test_headers.empty_add)
return -ENOMEM;
/* Test that register on top of an empty dir works */
sysctl_test_headers.empty
= register_sysctl("debug/test_sysctl/empty_add/empty", test_table_empty);
if (!sysctl_test_headers.empty)
return -ENOMEM;
return 0;
}
static int __init test_sysctl_init(void)
{
int err;
......@@ -233,6 +252,10 @@ static int __init test_sysctl_init(void)
goto out;
err = test_sysctl_run_register_mount_point();
if (err)
goto out;
err = test_sysctl_run_register_empty();
out:
return err;
......@@ -248,6 +271,10 @@ static void __exit test_sysctl_exit(void)
unregister_sysctl_table(sysctl_test_headers.test_h_mnt);
if (sysctl_test_headers.test_h_mnterror)
unregister_sysctl_table(sysctl_test_headers.test_h_mnterror);
if (sysctl_test_headers.empty)
unregister_sysctl_table(sysctl_test_headers.empty);
if (sysctl_test_headers.empty_add)
unregister_sysctl_table(sysctl_test_headers.empty_add);
}
module_exit(test_sysctl_exit);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment