@@ -46,5 +46,5 @@ register_isa_ports(unsigned int membase, unsigned int portbase, unsigned int por
isa_membase = membase;
isa_portbase = portbase;
isa_portshift = portshift;
- isa_sysctl_header = register_sysctl("bus/isa", ctl_isa_vars);
+ isa_sysctl_header = register_sysctl("bus/isa", ctl_isa_vars, ARRAY_SIZE(ctl_isa_vars));
}
@@ -569,7 +569,7 @@ static void __init register_insn_emulation(struct insn_emulation *insn)
sysctl->extra2 = &insn->max;
sysctl->proc_handler = emulation_proc_handler;
- register_sysctl("abi", sysctl);
+ register_sysctl("abi", sysctl, 1);
}
}
@@ -595,7 +595,8 @@ static struct ctl_table sve_default_vl_table[] = {
static int __init sve_sysctl_init(void)
{
if (system_supports_sve())
- if (!register_sysctl("abi", sve_default_vl_table))
+ if (!register_sysctl("abi", sve_default_vl_table,
+ ARRAY_SIZE(sve_default_vl_table)))
return -EINVAL;
return 0;
@@ -619,7 +620,8 @@ static struct ctl_table sme_default_vl_table[] = {
static int __init sme_sysctl_init(void)
{
if (system_supports_sme())
- if (!register_sysctl("abi", sme_default_vl_table))
+ if (!register_sysctl("abi", sme_default_vl_table,
+ ARRAY_SIZE(sme_default_vl_table)))
return -EINVAL;
return 0;
@@ -729,7 +729,8 @@ static struct ctl_table tagged_addr_sysctl_table[] = {
static int __init tagged_addr_init(void)
{
- if (!register_sysctl("abi", tagged_addr_sysctl_table))
+ if (!register_sysctl("abi", tagged_addr_sysctl_table,
+ ARRAY_SIZE(tagged_addr_sysctl_table)))
return -EINVAL;
return 0;
}
@@ -248,7 +248,8 @@ machine_crash_setup(void)
if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)
return ret;
#ifdef CONFIG_SYSCTL
- register_sysctl("kernel", kdump_ctl_table);
+ register_sysctl("kernel", kdump_ctl_table,
+ ARRAY_SIZE(kdump_ctl_table));
#endif
return 0;
}
@@ -111,7 +111,8 @@ static struct ctl_table powersave_nap_ctl_table[] = {
static int __init
register_powersave_nap_sysctl(void)
{
- register_sysctl("kernel", powersave_nap_ctl_table);
+ register_sysctl("kernel", powersave_nap_ctl_table,
+ ARRAY_SIZE(powersave_nap_ctl_table));
return 0;
}
@@ -65,7 +65,8 @@ static struct ctl_table nmi_wd_lpm_factor_ctl_table[] = {
static int __init register_nmi_wd_lpm_factor_sysctl(void)
{
- register_sysctl("kernel", nmi_wd_lpm_factor_ctl_table);
+ register_sysctl("kernel", nmi_wd_lpm_factor_ctl_table,
+ ARRAY_SIZE(nmi_wd_lpm_factor_ctl_table));
return 0;
}
@@ -408,7 +408,9 @@ static int __init appldata_init(void)
appldata_wq = alloc_ordered_workqueue("appldata", 0);
if (!appldata_wq)
return -ENOMEM;
- appldata_sysctl_header = register_sysctl(appldata_proc_name, appldata_table);
+ appldata_sysctl_header = register_sysctl(appldata_proc_name,
+ appldata_table,
+ ARRAY_SIZE(appldata_table));
return 0;
}
@@ -1564,7 +1564,8 @@ static int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view,
*/
static int __init debug_init(void)
{
- s390dbf_sysctl_header = register_sysctl("s390dbf", s390dbf_table);
+ s390dbf_sysctl_header = register_sysctl("s390dbf", s390dbf_table,
+ ARRAY_SIZE(s390dbf_table));
mutex_lock(&debug_mutex);
debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT, NULL);
initialized = 1;
@@ -647,7 +647,8 @@ static int __init topology_init(void)
set_topology_timer();
else
topology_update_polarization_simple();
- register_sysctl("s390", topology_ctl_table);
+ register_sysctl("s390", topology_ctl_table,
+ ARRAY_SIZE(topology_ctl_table));
dev_root = bus_get_dev_root(&cpu_subsys);
if (dev_root) {
@@ -379,7 +379,8 @@ static int __init cmm_init(void)
{
int rc = -ENOMEM;
- cmm_sysctl_header = register_sysctl("vm", cmm_table);
+ cmm_sysctl_header = register_sysctl("vm", cmm_table,
+ ARRAY_SIZE(cmm_table));
if (!cmm_sysctl_header)
goto out_sysctl;
#ifdef CONFIG_CMM_IUCV
@@ -35,7 +35,8 @@ static struct ctl_table page_table_sysctl[] = {
static int __init page_table_register_sysctl(void)
{
- return register_sysctl("vm", page_table_sysctl) ? 0 : -ENOMEM;
+ return register_sysctl("vm", page_table_sysctl,
+ ARRAY_SIZE(page_table_sysctl)) ? 0 : -ENOMEM;
}
__initcall(page_table_register_sysctl);
@@ -72,7 +72,7 @@ static struct ctl_table abi_table2[] = {
static __init int ia32_binfmt_init(void)
{
- register_sysctl("abi", abi_table2);
+ register_sysctl("abi", abi_table2, ARRAY_SIZE(abi_table2));
return 0;
}
__initcall(ia32_binfmt_init);
@@ -105,7 +105,8 @@ int sched_set_itmt_support(void)
return 0;
}
- itmt_sysctl_header = register_sysctl("kernel", itmt_kern_table);
+ itmt_sysctl_header = register_sysctl("kernel", itmt_kern_table,
+ ARRAY_SIZE(itmt_kern_table));
if (!itmt_sysctl_header) {
mutex_unlock(&itmt_update_mutex);
return -ENOMEM;
@@ -70,7 +70,8 @@ static struct ctl_table_header *crypto_sysctls;
static void crypto_proc_fips_init(void)
{
- crypto_sysctls = register_sysctl("crypto", crypto_sysctl_table);
+ crypto_sysctls = register_sysctl("crypto", crypto_sysctl_table,
+ ARRAY_SIZE(crypto_sysctl_table));
}
static void crypto_proc_fips_exit(void)
@@ -50,9 +50,9 @@ static struct ctl_table firmware_config_table[] = {
static struct ctl_table_header *firmware_config_sysct_table_header;
int register_firmware_config_sysctl(void)
{
- firmware_config_sysct_table_header =
- register_sysctl("kernel/firmware_config",
- firmware_config_table);
+ firmware_config_sysct_table_header = register_sysctl("kernel/firmware_config",
+ firmware_config_table,
+ ARRAY_SIZE(firmware_config_table));
if (!firmware_config_sysct_table_header)
return -ENOMEM;
return 0;
@@ -3680,7 +3680,8 @@ static void cdrom_sysctl_register(void)
if (!atomic_add_unless(&initialized, 1, 1))
return;
- cdrom_sysctl_header = register_sysctl("dev/cdrom", cdrom_table);
+ cdrom_sysctl_header = register_sysctl("dev/cdrom", cdrom_table,
+ ARRAY_SIZE(cdrom_table));
/* set the defaults */
cdrom_sysctl_settings.autoclose = autoclose;
@@ -1027,7 +1027,8 @@ static int __init hpet_init(void)
if (result < 0)
return -ENODEV;
- sysctl_header = register_sysctl("dev/hpet", hpet_table);
+ sysctl_header = register_sysctl("dev/hpet", hpet_table,
+ ARRAY_SIZE(hpet_table));
result = acpi_bus_register_driver(&hpet_acpi_driver);
if (result < 0) {
@@ -675,7 +675,8 @@ static int __init ipmi_poweroff_init(void)
pr_info("Power cycle is enabled\n");
#ifdef CONFIG_PROC_FS
- ipmi_table_header = register_sysctl("dev/ipmi", ipmi_table);
+ ipmi_table_header = register_sysctl("dev/ipmi", ipmi_table,
+ ARRAY_SIZE(ipmi_table));
if (!ipmi_table_header) {
pr_err("Unable to register powercycle sysctl\n");
rv = -ENOMEM;
@@ -5266,7 +5266,8 @@ static int destroy_config(int id, void *p, void *data)
int i915_perf_sysctl_register(void)
{
- sysctl_header = register_sysctl("dev/i915", oa_table);
+ sysctl_header = register_sysctl("dev/i915", oa_table,
+ ARRAY_SIZE(oa_table));
return 0;
}
@@ -302,7 +302,8 @@ int __init hv_common_init(void)
* message recording won't be available in isolated
* guests should the following registration fail.
*/
- hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table);
+ hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table,
+ ARRAY_SIZE(hv_ctl_table));
if (!hv_ctl_table_hdr)
pr_err("Hyper-V: sysctl table register error");
@@ -243,7 +243,8 @@ static struct ctl_table_header *mac_hid_sysctl_header;
static int __init mac_hid_init(void)
{
- mac_hid_sysctl_header = register_sysctl("dev/mac_hid", mac_hid_files);
+ mac_hid_sysctl_header = register_sysctl("dev/mac_hid", mac_hid_files,
+ ARRAY_SIZE(mac_hid_files));
if (!mac_hid_sysctl_header)
return -ENOMEM;
@@ -9633,7 +9633,8 @@ static int __init md_init(void)
mdp_major = ret;
register_reboot_notifier(&md_notifier);
- raid_table_header = register_sysctl("dev/raid", raid_table);
+ raid_table_header = register_sysctl("dev/raid", raid_table,
+ ARRAY_SIZE(raid_table));
md_geninit();
return 0;
@@ -1236,8 +1236,10 @@ xpc_init(void)
goto out_1;
}
- xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc);
- xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb);
+ xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc,
+ ARRAY_SIZE(xpc_sys_xpc));
+ xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb,
+ ARRAY_SIZE(xpc_sys_xpc_hb));
/*
* Fill the partition reserved page with the information needed by
@@ -464,7 +464,8 @@ int parport_proc_register(struct parport *port)
err = -ENOENT;
goto exit_free_tmp_dir_path;
}
- t->devices_header = register_sysctl(tmp_dir_path, t->device_dir);
+ t->devices_header = register_sysctl(tmp_dir_path, t->device_dir,
+ ARRAY_SIZE(t->device_dir));
if (t->devices_header == NULL) {
err = -ENOENT;
goto exit_free_tmp_dir_path;
@@ -478,7 +479,8 @@ int parport_proc_register(struct parport *port)
goto unregister_devices_h;
}
- t->port_header = register_sysctl(tmp_dir_path, t->vars);
+ t->port_header = register_sysctl(tmp_dir_path, t->vars,
+ ARRAY_SIZE(t->vars));
if (t->port_header == NULL) {
err = -ENOENT;
goto unregister_devices_h;
@@ -544,7 +546,7 @@ int parport_device_proc_register(struct pardevice *device)
t->vars[0].data = &device->timeslice;
- t->sysctl_header = register_sysctl(tmp_dir_path, t->vars);
+ t->sysctl_header = register_sysctl(tmp_dir_path, t->vars, ARRAY_SIZE(t->vars));
if (t->sysctl_header == NULL) {
kfree(t);
t = NULL;
@@ -579,7 +581,8 @@ static int __init parport_default_proc_register(void)
int ret;
parport_default_sysctl_table.sysctl_header =
- register_sysctl("dev/parport/default", parport_default_sysctl_table.vars);
+ register_sysctl("dev/parport/default", parport_default_sysctl_table.vars,
+ ARRAY_SIZE(parport_default_sysctl_table.vars));
if (!parport_default_sysctl_table.sysctl_header)
return -ENOMEM;
ret = parport_bus_init();
@@ -1188,7 +1188,8 @@ static void armv8_pmu_register_sysctl_table(void)
static u32 tbl_registered = 0;
if (!cmpxchg_relaxed(&tbl_registered, 0, 1))
- register_sysctl("kernel", armv8_pmu_sysctl_table);
+ register_sysctl("kernel", armv8_pmu_sysctl_table,
+ ARRAY_SIZE(armv8_pmu_sysctl_table));
}
static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name,
@@ -25,7 +25,8 @@ static struct ctl_table_header *scsi_table_header;
int __init scsi_init_sysctl(void)
{
- scsi_table_header = register_sysctl("dev/scsi", scsi_table);
+ scsi_table_header = register_sysctl("dev/scsi", scsi_table,
+ ARRAY_SIZE(scsi_table));
if (!scsi_table_header)
return -ENOMEM;
return 0;
@@ -1646,7 +1646,8 @@ static struct ctl_table_header *hdr;
static void register_sg_sysctls(void)
{
if (!hdr)
- hdr = register_sysctl("kernel", sg_sysctls);
+ hdr = register_sysctl("kernel", sg_sysctls,
+ ARRAY_SIZE(sg_sysctls));
}
static void unregister_sg_sysctls(void)
@@ -24,7 +24,8 @@ static struct ctl_table cachefiles_sysctls[] = {
int __init cachefiles_register_error_injection(void)
{
- cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls);
+ cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls,
+ ARRAY_SIZE(cachefiles_sysctls));
if (!cachefiles_sysctl)
return -ENOMEM;
return 0;
@@ -42,7 +42,8 @@ static struct ctl_table coda_table[] = {
void coda_sysctl_init(void)
{
if ( !fs_table_header )
- fs_table_header = register_sysctl("coda", coda_table);
+ fs_table_header = register_sysctl("coda", coda_table,
+ ARRAY_SIZE(coda_table));
}
void coda_sysctl_clean(void)
@@ -612,7 +612,8 @@ static int __init init_devpts_fs(void)
{
int err = register_filesystem(&devpts_fs_type);
if (!err) {
- register_sysctl("kernel/pty", pty_table);
+ register_sysctl("kernel/pty", pty_table,
+ ARRAY_SIZE(pty_table));
}
return err;
}
@@ -327,7 +327,7 @@ static struct ctl_table epoll_table[] = {
static void __init epoll_sysctls_init(void)
{
- register_sysctl("fs/epoll", epoll_table);
+ register_sysctl("fs/epoll", epoll_table, ARRAY_SIZE(epoll_table));
}
#else
#define epoll_sysctls_init() do { } while (0)
@@ -626,7 +626,8 @@ static int __init init_nlm(void)
#ifdef CONFIG_SYSCTL
err = -ENOMEM;
- nlm_sysctl_table = register_sysctl("fs/nfs", nlm_sysctls);
+ nlm_sysctl_table = register_sysctl("fs/nfs", nlm_sysctls,
+ ARRAY_SIZE(nlm_sysctls));
if (nlm_sysctl_table == NULL)
goto err_sysctl;
#endif
@@ -40,7 +40,8 @@ static struct ctl_table nfs4_cb_sysctls[] = {
int nfs4_register_sysctl(void)
{
nfs4_callback_sysctl_table = register_sysctl("fs/nfs",
- nfs4_cb_sysctls);
+ nfs4_cb_sysctls,
+ ARRAY_SIZE(nfs4_cb_sysctls));
if (nfs4_callback_sysctl_table == NULL)
return -ENOMEM;
return 0;
@@ -34,7 +34,8 @@ static struct ctl_table nfs_cb_sysctls[] = {
int nfs_register_sysctl(void)
{
- nfs_callback_sysctl_table = register_sysctl("fs/nfs", nfs_cb_sysctls);
+ nfs_callback_sysctl_table = register_sysctl("fs/nfs", nfs_cb_sysctls,
+ ARRAY_SIZE(nfs_cb_sysctls));
if (nfs_callback_sysctl_table == NULL)
return -ENOMEM;
return 0;
@@ -91,7 +91,8 @@ static struct ctl_table fanotify_table[] = {
static void __init fanotify_sysctls_init(void)
{
- register_sysctl("fs/fanotify", fanotify_table);
+ register_sysctl("fs/fanotify", fanotify_table,
+ ARRAY_SIZE(fanotify_table));
}
#else
#define fanotify_sysctls_init() do { } while (0)
@@ -90,7 +90,8 @@ static struct ctl_table inotify_table[] = {
static void __init inotify_sysctls_init(void)
{
- register_sysctl("fs/inotify", inotify_table);
+ register_sysctl("fs/inotify", inotify_table,
+ ARRAY_SIZE(inotify_table));
}
#else
@@ -44,7 +44,8 @@ int ntfs_sysctl(int add)
{
if (add) {
BUG_ON(sysctls_root_table);
- sysctls_root_table = register_sysctl("fs", ntfs_sysctls);
+ sysctls_root_table = register_sysctl("fs", ntfs_sysctls,
+ ARRAY_SIZE(ntfs_sysctls));
if (!sysctls_root_table)
return -ENOMEM;
} else {
@@ -673,7 +673,8 @@ static int __init ocfs2_stack_glue_init(void)
strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
- ocfs2_table_header = register_sysctl("fs/ocfs2/nm", ocfs2_nm_table);
+ ocfs2_table_header = register_sysctl("fs/ocfs2/nm", ocfs2_nm_table,
+ ARRAY_SIZE(ocfs2_nm_table));
if (!ocfs2_table_header) {
printk(KERN_ERR
"ocfs2 stack glue: unable to register sysctl\n");
@@ -43,7 +43,7 @@ struct ctl_table sysctl_mount_point[] = {
*/
struct ctl_table_header *register_sysctl_mount_point(const char *path)
{
- return register_sysctl(path, sysctl_mount_point);
+ return register_sysctl(path, sysctl_mount_point, 0);
}
EXPORT_SYMBOL(register_sysctl_mount_point);
@@ -1414,17 +1414,11 @@ struct ctl_table_header *__register_sysctl_table(
*
* See __register_sysctl_table for more details.
*/
-struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
+struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table,
+ size_t table_size)
{
- int count = 0;
- struct ctl_table *entry;
- struct ctl_table_header t_hdr;
-
- t_hdr.ctl_table = table;
- list_for_each_table_entry(entry, (&t_hdr))
- count++;
return __register_sysctl_table(&sysctl_table_root.default_set,
- path, table, count);
+ path, table, table_size);
}
EXPORT_SYMBOL(register_sysctl);
@@ -1451,7 +1445,14 @@ EXPORT_SYMBOL(register_sysctl);
void __init __register_sysctl_init(const char *path, struct ctl_table *table,
const char *table_name)
{
- struct ctl_table_header *hdr = register_sysctl(path, table);
+ 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);
if (unlikely(!hdr)) {
pr_err("failed when register_sysctl %s to %s\n", table_name, path);
@@ -103,7 +103,9 @@ static struct ctl_table fsverity_sysctl_table[] = {
static int __init fsverity_sysctl_init(void)
{
- fsverity_sysctl_header = register_sysctl("fs/verity", fsverity_sysctl_table);
+ fsverity_sysctl_header = register_sysctl("fs/verity",
+ fsverity_sysctl_table,
+ ARRAY_SIZE(fsverity_sysctl_table));
if (!fsverity_sysctl_header) {
pr_err("sysctl registration failed!\n");
return -ENOMEM;
@@ -213,7 +213,8 @@ static struct ctl_table xfs_table[] = {
int
xfs_sysctl_register(void)
{
- xfs_table_header = register_sysctl("fs/xfs", xfs_table);
+ xfs_table_header = register_sysctl("fs/xfs", xfs_table,
+ ARRAY_SIZE(xfs_table));
if (!xfs_table_header)
return -ENOMEM;
return 0;
@@ -227,7 +227,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set);
struct ctl_table_header *__register_sysctl_table(
struct ctl_table_set *set,
const char *path, struct ctl_table *table, size_t table_size);
-struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
+struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table,
+ size_t table_size);
void unregister_sysctl_table(struct ctl_table_header * table);
extern int sysctl_init_bases(void);
@@ -262,7 +263,8 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *p
return NULL;
}
-static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
+static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table,
+ size_t table_size)
{
return NULL;
}
@@ -48,7 +48,7 @@ static struct ctl_table pid_ns_ctl_table_vm[] = {
};
static inline void register_pid_ns_sysctl_table_vm(void)
{
- register_sysctl("vm", pid_ns_ctl_table_vm);
+ register_sysctl("vm", pid_ns_ctl_table_vm, ARRAY_SIZE(pid_ns_ctl_table_vm));
}
#else
static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns) {}
@@ -265,7 +265,7 @@ static struct ctl_table timer_sysctl[] = {
static int __init timer_sysctl_init(void)
{
- register_sysctl("kernel", timer_sysctl);
+ register_sysctl("kernel", timer_sysctl, ARRAY_SIZE(timer_sysctl));
return 0;
}
device_initcall(timer_sysctl_init);
@@ -365,7 +365,7 @@ static __init int user_namespace_sysctl_init(void)
* default set so that registrations in the child sets work
* properly.
*/
- user_header = register_sysctl("user", empty);
+ user_header = register_sysctl("user", empty, 0);
kmemleak_ignore(user_header);
BUG_ON(!user_header);
BUG_ON(!setup_userns_sysctls(&init_user_ns));
@@ -138,7 +138,7 @@ void uts_proc_notify(enum uts_proc proc)
static int __init utsname_sysctl_init(void)
{
- register_sysctl("kernel", uts_kern_table);
+ register_sysctl("kernel", uts_kern_table, ARRAY_SIZE(uts_kern_table));
return 0;
}
@@ -166,7 +166,8 @@ static int test_sysctl_setup_node_tests(void)
test_data.bitmap_0001 = kzalloc(SYSCTL_TEST_BITMAP_SIZE/8, GFP_KERNEL);
if (!test_data.bitmap_0001)
return -ENOMEM;
- sysctl_test_headers.test_h_setup_node = register_sysctl("debug/test_sysctl", test_table);
+ sysctl_test_headers.test_h_setup_node = register_sysctl("debug/test_sysctl", test_table,
+ ARRAY_SIZE(test_table));
if (!sysctl_test_headers.test_h_setup_node) {
kfree(test_data.bitmap_0001);
return -ENOMEM;
@@ -192,7 +193,8 @@ static int test_sysctl_run_unregister_nested(void)
struct ctl_table_header *unregister;
unregister = register_sysctl("debug/test_sysctl/unregister_error",
- test_table_unregister);
+ test_table_unregister,
+ ARRAY_SIZE(test_table_unregister));
if (!unregister)
return -ENOMEM;
@@ -209,7 +211,8 @@ static int test_sysctl_run_register_mount_point(void)
sysctl_test_headers.test_h_mnterror
= register_sysctl("debug/test_sysctl/mnt/mnt_error",
- test_table_unregister);
+ test_table_unregister,
+ ARRAY_SIZE(test_table_unregister));
/*
* Don't check the result.:
* If it fails (expected behavior), return 0.
@@ -167,7 +167,8 @@ void
rpc_register_sysctl(void)
{
if (!sunrpc_table_header)
- sunrpc_table_header = register_sysctl("sunrpc", debug_table);
+ sunrpc_table_header = register_sysctl("sunrpc", debug_table,
+ ARRAY_SIZE(debug_table));
}
void
@@ -246,7 +246,8 @@ static int svc_rdma_proc_init(void)
goto out_err;
svcrdma_table_header = register_sysctl("sunrpc/svc_rdma",
- svcrdma_parm_table);
+ svcrdma_parm_table,
+ ARRAY_SIZE(svcrdma_parm_table));
return 0;
out_err:
@@ -790,7 +790,9 @@ int xprt_rdma_init(void)
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
if (!sunrpc_table_header)
- sunrpc_table_header = register_sysctl("sunrpc", xr_tunables_table);
+ sunrpc_table_header = register_sysctl("sunrpc",
+ xr_tunables_table,
+ ARRAY_SIZE(xr_tunables_table));
#endif
return 0;
}
@@ -3169,7 +3169,9 @@ static struct xprt_class xs_bc_tcp_transport = {
int init_socket_xprt(void)
{
if (!sunrpc_table_header)
- sunrpc_table_header = register_sysctl("sunrpc", xs_tunables_table);
+ sunrpc_table_header = register_sysctl("sunrpc",
+ xs_tunables_table,
+ ARRAY_SIZE(xs_tunables_table));
xprt_register_transport(&xs_local_transport);
xprt_register_transport(&xs_udp_transport);
@@ -101,7 +101,7 @@ __init int net_sysctl_init(void)
* registering "/proc/sys/net" as an empty directory not in a
* network namespace.
*/
- net_header = register_sysctl("net", empty);
+ net_header = register_sysctl("net", empty, 0);
if (!net_header)
goto out;
ret = register_pernet_subsys(&sysctl_pernet_ops);
@@ -1785,7 +1785,8 @@ static struct ctl_table apparmor_sysctl_table[] = {
static int __init apparmor_init_sysctl(void)
{
- return register_sysctl("kernel", apparmor_sysctl_table) ? 0 : -ENOMEM;
+ return register_sysctl("kernel", apparmor_sysctl_table,
+ ARRAY_SIZE(apparmor_sysctl_table)) ? 0 : -ENOMEM;
}
#else
static inline int apparmor_init_sysctl(void)
@@ -256,7 +256,8 @@ static int __init loadpin_init(void)
enforce ? "" : "not ");
parse_exclude();
#ifdef CONFIG_SYSCTL
- if (!register_sysctl("kernel/loadpin", loadpin_sysctl_table))
+ if (!register_sysctl("kernel/loadpin", loadpin_sysctl_table,
+ ARRAY_SIZE(loadpin_sysctl_table)))
pr_notice("sysctl registration failed!\n");
#endif
security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");
@@ -461,7 +461,8 @@ static struct ctl_table yama_sysctl_table[] = {
};
static void __init yama_init_sysctl(void)
{
- if (!register_sysctl("kernel/yama", yama_sysctl_table))
+ if (!register_sysctl("kernel/yama", yama_sysctl_table,
+ ARRAY_SIZE(yama_sysctl_table)))
panic("Yama: sysctl registration failed.\n");
}
#else
In order to remove the end element from the ctl_table struct arrays, we explicitly define the size when registering the targes. We add a size argument to register_sysctl and change all the callers to pass the ARRAY_SIZE of their table arg. Signed-off-by: Joel Granados <j.granados@samsung.com> --- arch/arm/kernel/isa.c | 2 +- arch/arm64/kernel/armv8_deprecated.c | 2 +- arch/arm64/kernel/fpsimd.c | 6 +++-- arch/arm64/kernel/process.c | 3 ++- arch/ia64/kernel/crash.c | 3 ++- arch/powerpc/kernel/idle.c | 3 ++- arch/powerpc/platforms/pseries/mobility.c | 3 ++- arch/s390/appldata/appldata_base.c | 4 +++- arch/s390/kernel/debug.c | 3 ++- arch/s390/kernel/topology.c | 3 ++- arch/s390/mm/cmm.c | 3 ++- arch/s390/mm/pgalloc.c | 3 ++- arch/x86/entry/vdso/vdso32-setup.c | 2 +- arch/x86/kernel/itmt.c | 3 ++- crypto/fips.c | 3 ++- drivers/base/firmware_loader/fallback_table.c | 6 ++--- drivers/cdrom/cdrom.c | 3 ++- drivers/char/hpet.c | 3 ++- drivers/char/ipmi/ipmi_poweroff.c | 3 ++- drivers/gpu/drm/i915/i915_perf.c | 3 ++- drivers/hv/hv_common.c | 3 ++- drivers/macintosh/mac_hid.c | 3 ++- drivers/md/md.c | 3 ++- drivers/misc/sgi-xp/xpc_main.c | 6 +++-- drivers/parport/procfs.c | 11 +++++---- drivers/perf/arm_pmuv3.c | 3 ++- drivers/scsi/scsi_sysctl.c | 3 ++- drivers/scsi/sg.c | 3 ++- fs/cachefiles/error_inject.c | 3 ++- fs/coda/sysctl.c | 3 ++- fs/devpts/inode.c | 3 ++- fs/eventpoll.c | 2 +- fs/lockd/svc.c | 3 ++- fs/nfs/nfs4sysctl.c | 3 ++- fs/nfs/sysctl.c | 3 ++- fs/notify/fanotify/fanotify_user.c | 3 ++- fs/notify/inotify/inotify_user.c | 3 ++- fs/ntfs/sysctl.c | 3 ++- fs/ocfs2/stackglue.c | 3 ++- fs/proc/proc_sysctl.c | 23 ++++++++++--------- fs/verity/signature.c | 4 +++- fs/xfs/xfs_sysctl.c | 3 ++- include/linux/sysctl.h | 6 +++-- kernel/pid_sysctl.h | 2 +- kernel/time/timer.c | 2 +- kernel/ucount.c | 2 +- kernel/utsname_sysctl.c | 2 +- lib/test_sysctl.c | 9 +++++--- net/sunrpc/sysctl.c | 3 ++- net/sunrpc/xprtrdma/svc_rdma.c | 3 ++- net/sunrpc/xprtrdma/transport.c | 4 +++- net/sunrpc/xprtsock.c | 4 +++- net/sysctl_net.c | 2 +- security/apparmor/lsm.c | 3 ++- security/loadpin/loadpin.c | 3 ++- security/yama/yama_lsm.c | 3 ++- 56 files changed, 133 insertions(+), 76 deletions(-)