@@ -1195,7 +1195,7 @@ static struct ctl_table sld_sysctls[] = {
static int __init sld_mitigate_sysctl_init(void)
{
- register_sysctl_init("kernel", sld_sysctls);
+ register_sysctl_init("kernel", sld_sysctls, ARRAY_SIZE(sld_sysctls));
return 0;
}
@@ -1692,7 +1692,8 @@ static struct ctl_table random_table[] = {
*/
static int __init random_sysctls_init(void)
{
- register_sysctl_init("kernel/random", random_table);
+ register_sysctl_init("kernel/random", random_table,
+ ARRAY_SIZE(random_table));
return 0;
}
device_initcall(random_sysctls_init);
@@ -3618,7 +3618,7 @@ static struct ctl_table tty_table[] = {
*/
int __init tty_init(void)
{
- register_sysctl_init("dev/tty", tty_table);
+ register_sysctl_init("dev/tty", tty_table, ARRAY_SIZE(tty_table));
cdev_init(&tty_cdev, &tty_fops);
if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
@@ -729,7 +729,8 @@ static int __init balloon_init(void)
#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
set_online_page_callback(&xen_online_page);
register_memory_notifier(&xen_memory_nb);
- register_sysctl_init("xen/balloon", balloon_table);
+ register_sysctl_init("xen/balloon", balloon_table,
+ ARRAY_SIZE(balloon_table));
#endif
balloon_add_regions();
@@ -244,7 +244,7 @@ static struct ctl_table aio_sysctls[] = {
static void __init aio_sysctl_init(void)
{
- register_sysctl_init("fs", aio_sysctls);
+ register_sysctl_init("fs", aio_sysctls, ARRAY_SIZE(aio_sysctls));
}
#else
#define aio_sysctl_init() do { } while (0)
@@ -984,7 +984,8 @@ static struct ctl_table coredump_sysctls[] = {
static int __init init_fs_coredump_sysctls(void)
{
- register_sysctl_init("kernel", coredump_sysctls);
+ register_sysctl_init("kernel", coredump_sysctls,
+ ARRAY_SIZE(coredump_sysctls));
return 0;
}
fs_initcall(init_fs_coredump_sysctls);
@@ -196,7 +196,8 @@ static struct ctl_table fs_dcache_sysctls[] = {
static int __init init_fs_dcache_sysctls(void)
{
- register_sysctl_init("fs", fs_dcache_sysctls);
+ register_sysctl_init("fs", fs_dcache_sysctls,
+ ARRAY_SIZE(fs_dcache_sysctls));
return 0;
}
fs_initcall(init_fs_dcache_sysctls);
@@ -2170,7 +2170,8 @@ static struct ctl_table fs_exec_sysctls[] = {
static int __init init_fs_exec_sysctls(void)
{
- register_sysctl_init("fs", fs_exec_sysctls);
+ register_sysctl_init("fs", fs_exec_sysctls,
+ ARRAY_SIZE(fs_exec_sysctls));
return 0;
}
@@ -120,7 +120,8 @@ static struct ctl_table fs_stat_sysctls[] = {
static int __init init_fs_stat_sysctls(void)
{
- register_sysctl_init("fs", fs_stat_sysctls);
+ register_sysctl_init("fs", fs_stat_sysctls,
+ ARRAY_SIZE(fs_stat_sysctls));
if (IS_ENABLED(CONFIG_BINFMT_MISC)) {
struct ctl_table_header *hdr;
hdr = register_sysctl_mount_point("fs/binfmt_misc");
@@ -135,7 +135,7 @@ static struct ctl_table inodes_sysctls[] = {
static int __init init_fs_inode_sysctls(void)
{
- register_sysctl_init("fs", inodes_sysctls);
+ register_sysctl_init("fs", inodes_sysctls, ARRAY_SIZE(inodes_sysctls));
return 0;
}
early_initcall(init_fs_inode_sysctls);
@@ -116,7 +116,7 @@ static struct ctl_table locks_sysctls[] = {
static int __init init_fs_locks_sysctls(void)
{
- register_sysctl_init("fs", locks_sysctls);
+ register_sysctl_init("fs", locks_sysctls, ARRAY_SIZE(locks_sysctls));
return 0;
}
early_initcall(init_fs_locks_sysctls);
@@ -1073,7 +1073,7 @@ static struct ctl_table namei_sysctls[] = {
static int __init init_fs_namei_sysctls(void)
{
- register_sysctl_init("fs", namei_sysctls);
+ register_sysctl_init("fs", namei_sysctls, ARRAY_SIZE(namei_sysctls));
return 0;
}
fs_initcall(init_fs_namei_sysctls);
@@ -4715,7 +4715,8 @@ static struct ctl_table fs_namespace_sysctls[] = {
static int __init init_fs_namespace_sysctls(void)
{
- register_sysctl_init("fs", fs_namespace_sysctls);
+ register_sysctl_init("fs", fs_namespace_sysctls,
+ ARRAY_SIZE(fs_namespace_sysctls));
return 0;
}
fs_initcall(init_fs_namespace_sysctls);
@@ -33,7 +33,8 @@ static struct ctl_table dnotify_sysctls[] = {
};
static void __init dnotify_sysctl_init(void)
{
- register_sysctl_init("fs", dnotify_sysctls);
+ register_sysctl_init("fs", dnotify_sysctls,
+ ARRAY_SIZE(dnotify_sysctls));
}
#else
#define dnotify_sysctl_init() do { } while (0)
@@ -1508,7 +1508,8 @@ static int __init init_pipe_fs(void)
}
}
#ifdef CONFIG_SYSCTL
- register_sysctl_init("fs", fs_pipe_sysctls);
+ register_sysctl_init("fs", fs_pipe_sysctls,
+ ARRAY_SIZE(fs_pipe_sysctls));
#endif
return err;
}
@@ -1443,16 +1443,9 @@ EXPORT_SYMBOL(register_sysctl);
* Context: if your base directory does not exist it will be created for you.
*/
void __init __register_sysctl_init(const char *path, struct ctl_table *table,
- const char *table_name)
+ const char *table_name, size_t table_size)
{
- int count = 0;
- struct ctl_table *entry;
- struct ctl_table_header t_hdr, *hdr;
-
- t_hdr.ctl_table = table;
- list_for_each_table_entry(entry, (&t_hdr))
- count++;
- hdr = register_sysctl(path, table, count);
+ struct ctl_table_header *hdr = register_sysctl(path, table, table_size);
if (unlikely(!hdr)) {
pr_err("failed when register_sysctl %s to %s\n", table_name, path);
@@ -2953,7 +2953,8 @@ static int __init dquot_init(void)
printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
- register_sysctl_init("fs/quota", fs_dqstats_table);
+ register_sysctl_init("fs/quota", fs_dqstats_table,
+ ARRAY_SIZE(fs_dqstats_table));
dquot_cachep = kmem_cache_create("dquot",
sizeof(struct dquot), sizeof(unsigned long) * 4,
@@ -31,7 +31,8 @@ static struct ctl_table fs_shared_sysctls[] = {
static int __init init_fs_sysctls(void)
{
- register_sysctl_init("fs", fs_shared_sysctls);
+ register_sysctl_init("fs", fs_shared_sysctls,
+ ARRAY_SIZE(fs_shared_sysctls));
return 0;
}
@@ -2219,7 +2219,8 @@ static int __init userfaultfd_init(void)
SLAB_HWCACHE_ALIGN|SLAB_PANIC,
init_once_userfaultfd_ctx);
#ifdef CONFIG_SYSCTL
- register_sysctl_init("vm", vm_userfaultfd_table);
+ register_sysctl_init("vm", vm_userfaultfd_table,
+ ARRAY_SIZE(vm_userfaultfd_table));
#endif
return 0;
}
@@ -233,8 +233,9 @@ void unregister_sysctl_table(struct ctl_table_header * table);
extern int sysctl_init_bases(void);
extern void __register_sysctl_init(const char *path, struct ctl_table *table,
- const char *table_name);
-#define register_sysctl_init(path, table) __register_sysctl_init(path, table, #table)
+ const char *table_name, size_t table_size);
+#define register_sysctl_init(path, table, size) \
+ __register_sysctl_init(path, table, #table, size)
extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
void do_sysctl_args(void);
@@ -254,7 +255,8 @@ extern int no_unaligned_warning;
#else /* CONFIG_SYSCTL */
-static inline void register_sysctl_init(const char *path, struct ctl_table *table)
+static inline void register_sysctl_init(const char *path, struct ctl_table *table,
+ size_t table_size)
{
}
@@ -34,7 +34,8 @@ static struct ctl_table kern_do_mounts_initrd_table[] = {
static __init int kernel_do_mounts_initrd_sysctls_init(void)
{
- register_sysctl_init("kernel", kern_do_mounts_initrd_table);
+ register_sysctl_init("kernel", kern_do_mounts_initrd_table,
+ ARRAY_SIZE(kern_do_mounts_initrd_table));
return 0;
}
late_initcall(kernel_do_mounts_initrd_sysctls_init);
@@ -89,7 +89,8 @@ static struct ctl_table kern_acct_table[] = {
static __init int kernel_acct_sysctls_init(void)
{
- register_sysctl_init("kernel", kern_acct_table);
+ register_sysctl_init("kernel", kern_acct_table,
+ ARRAY_SIZE(kern_acct_table));
return 0;
}
late_initcall(kernel_acct_sysctls_init);
@@ -5406,7 +5406,8 @@ static struct ctl_table bpf_syscall_table[] = {
static int __init bpf_syscall_sysctl_init(void)
{
- register_sysctl_init("kernel", bpf_syscall_table);
+ register_sysctl_init("kernel", bpf_syscall_table,
+ ARRAY_SIZE(bpf_syscall_table));
return 0;
}
late_initcall(bpf_syscall_sysctl_init);
@@ -79,7 +79,8 @@ static struct ctl_table kern_delayacct_table[] = {
static __init int kernel_delayacct_sysctls_init(void)
{
- register_sysctl_init("kernel", kern_delayacct_table);
+ register_sysctl_init("kernel", kern_delayacct_table,
+ ARRAY_SIZE(kern_delayacct_table));
return 0;
}
late_initcall(kernel_delayacct_sysctls_init);
@@ -95,7 +95,8 @@ static struct ctl_table kern_exit_table[] = {
static __init int kernel_exit_sysctls_init(void)
{
- register_sysctl_init("kernel", kern_exit_table);
+ register_sysctl_init("kernel", kern_exit_table,
+ ARRAY_SIZE(kern_exit_table));
return 0;
}
late_initcall(kernel_exit_sysctls_init);
@@ -318,7 +318,8 @@ static struct ctl_table hung_task_sysctls[] = {
static void __init hung_task_sysctl_init(void)
{
- register_sysctl_init("kernel", hung_task_sysctls);
+ register_sysctl_init("kernel", hung_task_sysctls,
+ ARRAY_SIZE(hung_task_sysctls));
}
#else
#define hung_task_sysctl_init() do { } while (0)
@@ -1007,7 +1007,8 @@ static struct ctl_table kexec_core_sysctls[] = {
static int __init kexec_core_sysctl_init(void)
{
- register_sysctl_init("kernel", kexec_core_sysctls);
+ register_sysctl_init("kernel", kexec_core_sysctls,
+ ARRAY_SIZE(kexec_core_sysctls));
return 0;
}
late_initcall(kexec_core_sysctl_init);
@@ -973,7 +973,8 @@ static struct ctl_table kprobe_sysctls[] = {
static void __init kprobe_sysctls_init(void)
{
- register_sysctl_init("debug", kprobe_sysctls);
+ register_sysctl_init("debug", kprobe_sysctls,
+ ARRAY_SIZE(kprobe_sysctls));
}
#endif /* CONFIG_SYSCTL */
@@ -293,7 +293,8 @@ static int __init init_lstats_procfs(void)
{
proc_create("latency_stats", 0644, NULL, &lstats_proc_ops);
#ifdef CONFIG_SYSCTL
- register_sysctl_init("kernel", latencytop_sysctl);
+ register_sysctl_init("kernel", latencytop_sysctl,
+ ARRAY_SIZE(latencytop_sysctl));
#endif
return 0;
}
@@ -102,7 +102,8 @@ static struct ctl_table kern_lockdep_table[] = {
static __init int kernel_lockdep_sysctls_init(void)
{
- register_sysctl_init("kernel", kern_lockdep_table);
+ register_sysctl_init("kernel", kern_lockdep_table,
+ ARRAY_SIZE(kern_lockdep_table));
return 0;
}
late_initcall(kernel_lockdep_sysctls_init);
@@ -104,7 +104,8 @@ static struct ctl_table kern_panic_table[] = {
static __init int kernel_panic_sysctls_init(void)
{
- register_sysctl_init("kernel", kern_panic_table);
+ register_sysctl_init("kernel", kern_panic_table,
+ ARRAY_SIZE(kern_panic_table));
return 0;
}
late_initcall(kernel_panic_sysctls_init);
@@ -472,7 +472,8 @@ static __init int pid_namespaces_init(void)
pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC | SLAB_ACCOUNT);
#ifdef CONFIG_CHECKPOINT_RESTORE
- register_sysctl_init("kernel", pid_ns_ctl_table);
+ register_sysctl_init("kernel", pid_ns_ctl_table,
+ ARRAY_SIZE(pid_ns_ctl_table));
#endif
register_pid_ns_sysctl_table_vm();
@@ -81,5 +81,6 @@ static struct ctl_table printk_sysctls[] = {
void __init printk_sysctl_init(void)
{
- register_sysctl_init("kernel", printk_sysctls);
+ register_sysctl_init("kernel", printk_sysctls,
+ ARRAY_SIZE(printk_sysctls));
}
@@ -1277,7 +1277,8 @@ static struct ctl_table kern_reboot_table[] = {
static void __init kernel_reboot_sysctls_init(void)
{
- register_sysctl_init("kernel", kern_reboot_table);
+ register_sysctl_init("kernel", kern_reboot_table,
+ ARRAY_SIZE(kern_reboot_table));
}
#else
#define kernel_reboot_sysctls_init() do { } while (0)
@@ -24,7 +24,8 @@ static struct ctl_table sched_autogroup_sysctls[] = {
static void __init sched_autogroup_sysctl_init(void)
{
- register_sysctl_init("kernel", sched_autogroup_sysctls);
+ register_sysctl_init("kernel", sched_autogroup_sysctls,
+ ARRAY_SIZE(sched_autogroup_sysctls));
}
#else
#define sched_autogroup_sysctl_init() do { } while (0)
@@ -4677,7 +4677,8 @@ static struct ctl_table sched_core_sysctls[] = {
};
static int __init sched_core_sysctl_init(void)
{
- register_sysctl_init("kernel", sched_core_sysctls);
+ register_sysctl_init("kernel", sched_core_sysctls,
+ ARRAY_SIZE(sched_core_sysctls));
return 0;
}
late_initcall(sched_core_sysctl_init);
@@ -46,7 +46,8 @@ static struct ctl_table sched_dl_sysctls[] = {
static int __init sched_dl_sysctl_init(void)
{
- register_sysctl_init("kernel", sched_dl_sysctls);
+ register_sysctl_init("kernel", sched_dl_sysctls,
+ ARRAY_SIZE(sched_dl_sysctls));
return 0;
}
late_initcall(sched_dl_sysctl_init);
@@ -217,7 +217,8 @@ static struct ctl_table sched_fair_sysctls[] = {
static int __init sched_fair_sysctl_init(void)
{
- register_sysctl_init("kernel", sched_fair_sysctls);
+ register_sysctl_init("kernel", sched_fair_sysctls,
+ ARRAY_SIZE(sched_fair_sysctls));
return 0;
}
late_initcall(sched_fair_sysctl_init);
@@ -57,7 +57,8 @@ static struct ctl_table sched_rt_sysctls[] = {
static int __init sched_rt_sysctl_init(void)
{
- register_sysctl_init("kernel", sched_rt_sysctls);
+ register_sysctl_init("kernel", sched_rt_sysctls,
+ ARRAY_SIZE(sched_rt_sysctls));
return 0;
}
late_initcall(sched_rt_sysctl_init);
@@ -255,7 +255,8 @@ static struct ctl_table sched_energy_aware_sysctls[] = {
static int __init sched_energy_aware_sysctl_init(void)
{
- register_sysctl_init("kernel", sched_energy_aware_sysctls);
+ register_sysctl_init("kernel", sched_energy_aware_sysctls,
+ ARRAY_SIZE(sched_energy_aware_sysctls));
return 0;
}
@@ -2386,7 +2386,8 @@ static struct ctl_table seccomp_sysctl_table[] = {
static int __init seccomp_sysctl_init(void)
{
- register_sysctl_init("kernel/seccomp", seccomp_sysctl_table);
+ register_sysctl_init("kernel/seccomp", seccomp_sysctl_table,
+ ARRAY_SIZE(seccomp_sysctl_table));
return 0;
}
@@ -4788,7 +4788,8 @@ static struct ctl_table signal_debug_table[] = {
static int __init init_signal_sysctls(void)
{
- register_sysctl_init("debug", signal_debug_table);
+ register_sysctl_init("debug", signal_debug_table,
+ ARRAY_SIZE(signal_debug_table));
return 0;
}
early_initcall(init_signal_sysctls);
@@ -59,7 +59,8 @@ static struct ctl_table stackleak_sysctls[] = {
static int __init stackleak_sysctls_init(void)
{
- register_sysctl_init("kernel", stackleak_sysctls);
+ register_sysctl_init("kernel", stackleak_sysctls,
+ ARRAY_SIZE(stackleak_sysctls));
return 0;
}
late_initcall(stackleak_sysctls_init);
@@ -2321,8 +2321,8 @@ static struct ctl_table vm_table[] = {
int __init sysctl_init_bases(void)
{
- register_sysctl_init("kernel", kern_table);
- register_sysctl_init("vm", vm_table);
+ register_sysctl_init("kernel", kern_table, ARRAY_SIZE(kern_table));
+ register_sysctl_init("vm", vm_table, ARRAY_SIZE(vm_table));
return 0;
}
@@ -8219,7 +8219,8 @@ static struct ctl_table ftrace_sysctls[] = {
static int __init ftrace_sysctl_init(void)
{
- register_sysctl_init("kernel", ftrace_sysctls);
+ register_sysctl_init("kernel", ftrace_sysctls,
+ ARRAY_SIZE(ftrace_sysctls));
return 0;
}
late_initcall(ftrace_sysctl_init);
@@ -2563,7 +2563,8 @@ static int __init trace_events_user_init(void)
if (dyn_event_register(&user_event_dops))
pr_warn("user_events could not register with dyn_events\n");
- register_sysctl_init("kernel", user_event_sysctls);
+ register_sysctl_init("kernel", user_event_sysctls,
+ ARRAY_SIZE(user_event_sysctls));
return 0;
}
@@ -565,7 +565,8 @@ static struct ctl_table usermodehelper_table[] = {
static int __init init_umh_sysctls(void)
{
- register_sysctl_init("kernel/usermodehelper", usermodehelper_table);
+ register_sysctl_init("kernel/usermodehelper", usermodehelper_table,
+ ARRAY_SIZE(usermodehelper_table));
return 0;
}
early_initcall(init_umh_sysctls);
@@ -847,7 +847,8 @@ static struct ctl_table watchdog_sysctls[] = {
static void __init watchdog_sysctl_init(void)
{
- register_sysctl_init("kernel", watchdog_sysctls);
+ register_sysctl_init("kernel", watchdog_sysctls,
+ ARRAY_SIZE(watchdog_sysctls));
}
#else
#define watchdog_sysctl_init() do { } while (0)
@@ -3145,7 +3145,7 @@ static int __init kcompactd_init(void)
for_each_node_state(nid, N_MEMORY)
kcompactd_run(nid);
- register_sysctl_init("vm", vm_compaction);
+ register_sysctl_init("vm", vm_compaction, ARRAY_SIZE(vm_compaction));
return 0;
}
subsys_initcall(kcompactd_init)
@@ -4681,7 +4681,7 @@ static struct ctl_table hugetlb_table[] = {
static void hugetlb_sysctl_init(void)
{
- register_sysctl_init("vm", hugetlb_table);
+ register_sysctl_init("vm", hugetlb_table, ARRAY_SIZE(hugetlb_table));
}
#endif /* CONFIG_SYSCTL */
@@ -597,7 +597,8 @@ static int __init hugetlb_vmemmap_init(void)
for_each_hstate(h) {
if (hugetlb_vmemmap_optimizable(h)) {
- register_sysctl_init("vm", hugetlb_vmemmap_sysctls);
+ register_sysctl_init("vm", hugetlb_vmemmap_sysctls,
+ ARRAY_SIZE(hugetlb_vmemmap_sysctls));
break;
}
}
@@ -148,7 +148,8 @@ static struct ctl_table memory_failure_table[] = {
static int __init memory_failure_sysctl_init(void)
{
- register_sysctl_init("vm", memory_failure_table);
+ register_sysctl_init("vm", memory_failure_table,
+ ARRAY_SIZE(memory_failure_table));
return 0;
}
late_initcall(memory_failure_sysctl_init);
@@ -734,7 +734,8 @@ static int __init oom_init(void)
{
oom_reaper_th = kthread_run(oom_reaper, NULL, "oom_reaper");
#ifdef CONFIG_SYSCTL
- register_sysctl_init("vm", vm_oom_kill_table);
+ register_sysctl_init("vm", vm_oom_kill_table,
+ ARRAY_SIZE(vm_oom_kill_table));
#endif
return 0;
}
@@ -2320,7 +2320,8 @@ void __init page_writeback_init(void)
cpuhp_setup_state(CPUHP_MM_WRITEBACK_DEAD, "mm/writeback:dead", NULL,
page_writeback_cpu_online);
#ifdef CONFIG_SYSCTL
- register_sysctl_init("vm", vm_page_writeback_sysctls);
+ register_sysctl_init("vm", vm_page_writeback_sysctls,
+ ARRAY_SIZE(vm_page_writeback_sysctls));
#endif
}
@@ -71,7 +71,7 @@ struct ctl_table key_sysctls[] = {
static int __init init_security_keys_sysctls(void)
{
- register_sysctl_init("kernel/keys", key_sysctls);
+ register_sysctl_init("kernel/keys", key_sysctls, ARRAY_SIZE(key_sysctls));
return 0;
}
early_initcall(init_security_keys_sysctls);