Skip to content

Commit 1751f87

Browse files
committed
treewide: const qualify ctl_tables where applicable
Add the const qualifier to all the ctl_tables in the tree except for watchdog_hardlockup_sysctl, memory_allocation_profiling_sysctls, loadpin_sysctl_table and the ones calling register_net_sysctl (./net, drivers/inifiniband dirs). These are special cases as they use a registration function with a non-const qualified ctl_table argument or modify the arrays before passing them on to the registration function. Constifying ctl_table structs will prevent the modification of proc_handler function pointers as the arrays would reside in .rodata. This is made possible after commit 78eb4ea ("sysctl: treewide: constify the ctl_table argument of proc_handlers") constified all the proc_handlers. Created this by running an spatch followed by a sed command: Spatch: virtual patch @ depends on !(file in "net") disable optional_qualifier @ identifier table_name != { watchdog_hardlockup_sysctl, iwcm_ctl_table, ucma_ctl_table, memory_allocation_profiling_sysctls, loadpin_sysctl_table }; @@ + const struct ctl_table table_name [] = { ... }; sed: sed --in-place \ -e "s/struct ctl_table .table = &uts_kern/const struct ctl_table *table = \&uts_kern/" \ kernel/utsname_sysctl.c Reviewed-by: Song Liu <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> # for kernel/trace/ Reviewed-by: Martin K. Petersen <[email protected]> # SCSI Reviewed-by: Darrick J. Wong <[email protected]> # xfs Acked-by: Jani Nikula <[email protected]> Acked-by: Corey Minyard <[email protected]> Acked-by: Wei Liu <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Reviewed-by: Bill O'Donnell <[email protected]> Acked-by: Baoquan He <[email protected]> Acked-by: Ashutosh Dixit <[email protected]> Acked-by: Anna Schumaker <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent 6d61a53 commit 1751f87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+114
-114
lines changed

arch/arm/kernel/isa.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
static unsigned int isa_membase, isa_portbase, isa_portshift;
1818

19-
static struct ctl_table ctl_isa_vars[] = {
19+
static const struct ctl_table ctl_isa_vars[] = {
2020
{
2121
.procname = "membase",
2222
.data = &isa_membase,

arch/arm64/kernel/fpsimd.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static int vec_proc_do_default_vl(const struct ctl_table *table, int write,
562562
return 0;
563563
}
564564

565-
static struct ctl_table sve_default_vl_table[] = {
565+
static const struct ctl_table sve_default_vl_table[] = {
566566
{
567567
.procname = "sve_default_vector_length",
568568
.mode = 0644,
@@ -585,7 +585,7 @@ static int __init sve_sysctl_init(void) { return 0; }
585585
#endif /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */
586586

587587
#if defined(CONFIG_ARM64_SME) && defined(CONFIG_SYSCTL)
588-
static struct ctl_table sme_default_vl_table[] = {
588+
static const struct ctl_table sme_default_vl_table[] = {
589589
{
590590
.procname = "sme_default_vector_length",
591591
.mode = 0644,

arch/arm64/kernel/process.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ long get_tagged_addr_ctrl(struct task_struct *task)
859859
* disable it for tasks that already opted in to the relaxed ABI.
860860
*/
861861

862-
static struct ctl_table tagged_addr_sysctl_table[] = {
862+
static const struct ctl_table tagged_addr_sysctl_table[] = {
863863
{
864864
.procname = "tagged_addr_disabled",
865865
.mode = 0644,

arch/powerpc/kernel/idle.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void power4_idle(void)
9797
/*
9898
* Register the sysctl to set/clear powersave_nap.
9999
*/
100-
static struct ctl_table powersave_nap_ctl_table[] = {
100+
static const struct ctl_table powersave_nap_ctl_table[] = {
101101
{
102102
.procname = "powersave-nap",
103103
.data = &powersave_nap,

arch/powerpc/platforms/pseries/mobility.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct update_props_workarea {
5353
static unsigned int nmi_wd_lpm_factor = 200;
5454

5555
#ifdef CONFIG_SYSCTL
56-
static struct ctl_table nmi_wd_lpm_factor_ctl_table[] = {
56+
static const struct ctl_table nmi_wd_lpm_factor_ctl_table[] = {
5757
{
5858
.procname = "nmi_wd_lpm_factor",
5959
.data = &nmi_wd_lpm_factor,

arch/riscv/kernel/process.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ static bool try_to_set_pmm(unsigned long value)
364364
* disable it for tasks that already opted in to the relaxed ABI.
365365
*/
366366

367-
static struct ctl_table tagged_addr_sysctl_table[] = {
367+
static const struct ctl_table tagged_addr_sysctl_table[] = {
368368
{
369369
.procname = "tagged_addr_disabled",
370370
.mode = 0644,

arch/riscv/kernel/vector.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ long riscv_v_vstate_ctrl_set_current(unsigned long arg)
287287

288288
#ifdef CONFIG_SYSCTL
289289

290-
static struct ctl_table riscv_v_default_vstate_table[] = {
290+
static const struct ctl_table riscv_v_default_vstate_table[] = {
291291
{
292292
.procname = "riscv_v_default_allow",
293293
.data = &riscv_v_implicit_uacc,

arch/s390/appldata/appldata_base.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int appldata_interval_handler(const struct ctl_table *ctl, int write,
5252
void *buffer, size_t *lenp, loff_t *ppos);
5353

5454
static struct ctl_table_header *appldata_sysctl_header;
55-
static struct ctl_table appldata_table[] = {
55+
static const struct ctl_table appldata_table[] = {
5656
{
5757
.procname = "timer",
5858
.mode = S_IRUGO | S_IWUSR,

arch/s390/kernel/debug.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ static int s390dbf_procactive(const struct ctl_table *table, int write,
11221122
return 0;
11231123
}
11241124

1125-
static struct ctl_table s390dbf_table[] = {
1125+
static const struct ctl_table s390dbf_table[] = {
11261126
{
11271127
.procname = "debug_stoppable",
11281128
.data = &debug_stoppable,

arch/s390/kernel/hiperdispatch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static int hiperdispatch_ctl_handler(const struct ctl_table *ctl, int write,
292292
return 0;
293293
}
294294

295-
static struct ctl_table hiperdispatch_ctl_table[] = {
295+
static const struct ctl_table hiperdispatch_ctl_table[] = {
296296
{
297297
.procname = "hiperdispatch",
298298
.mode = 0644,

arch/s390/kernel/topology.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ static int polarization_ctl_handler(const struct ctl_table *ctl, int write,
667667
return set_polarization(polarization);
668668
}
669669

670-
static struct ctl_table topology_ctl_table[] = {
670+
static const struct ctl_table topology_ctl_table[] = {
671671
{
672672
.procname = "topology",
673673
.mode = 0644,

arch/s390/mm/cmm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int cmm_timeout_handler(const struct ctl_table *ctl, int write,
332332
return 0;
333333
}
334334

335-
static struct ctl_table cmm_table[] = {
335+
static const struct ctl_table cmm_table[] = {
336336
{
337337
.procname = "cmm_pages",
338338
.mode = 0644,

arch/s390/mm/pgalloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
int page_table_allocate_pgste = 0;
2222
EXPORT_SYMBOL(page_table_allocate_pgste);
2323

24-
static struct ctl_table page_table_sysctl[] = {
24+
static const struct ctl_table page_table_sysctl[] = {
2525
{
2626
.procname = "allocate_pgste",
2727
.data = &page_table_allocate_pgste,

arch/x86/entry/vdso/vdso32-setup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ __setup_param("vdso=", vdso_setup, vdso32_setup, 0);
5757
/* Register vsyscall32 into the ABI table */
5858
#include <linux/sysctl.h>
5959

60-
static struct ctl_table abi_table2[] = {
60+
static const struct ctl_table abi_table2[] = {
6161
{
6262
.procname = "vsyscall32",
6363
.data = &vdso32_enabled,

arch/x86/kernel/cpu/bus_lock.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static unsigned int sysctl_sld_mitigate = 1;
4949
static DEFINE_SEMAPHORE(buslock_sem, 1);
5050

5151
#ifdef CONFIG_PROC_SYSCTL
52-
static struct ctl_table sld_sysctls[] = {
52+
static const struct ctl_table sld_sysctls[] = {
5353
{
5454
.procname = "split_lock_mitigate",
5555
.data = &sysctl_sld_mitigate,

crypto/fips.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ __setup("fips=", fips_enable);
4141
static char fips_name[] = FIPS_MODULE_NAME;
4242
static char fips_version[] = FIPS_MODULE_VERSION;
4343

44-
static struct ctl_table crypto_sysctl_table[] = {
44+
static const struct ctl_table crypto_sysctl_table[] = {
4545
{
4646
.procname = "fips_enabled",
4747
.data = &fips_enabled,

drivers/base/firmware_loader/fallback_table.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct firmware_fallback_config fw_fallback_config = {
2525
EXPORT_SYMBOL_NS_GPL(fw_fallback_config, "FIRMWARE_LOADER_PRIVATE");
2626

2727
#ifdef CONFIG_SYSCTL
28-
static struct ctl_table firmware_config_table[] = {
28+
static const struct ctl_table firmware_config_table[] = {
2929
{
3030
.procname = "force_sysfs_fallback",
3131
.data = &fw_fallback_config.force_sysfs_fallback,

drivers/cdrom/cdrom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3612,7 +3612,7 @@ static int cdrom_sysctl_handler(const struct ctl_table *ctl, int write,
36123612
}
36133613

36143614
/* Place files in /proc/sys/dev/cdrom */
3615-
static struct ctl_table cdrom_table[] = {
3615+
static const struct ctl_table cdrom_table[] = {
36163616
{
36173617
.procname = "info",
36183618
.data = &cdrom_sysctl_settings.info,

drivers/char/hpet.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ static int hpet_is_known(struct hpet_data *hdp)
724724
return 0;
725725
}
726726

727-
static struct ctl_table hpet_table[] = {
727+
static const struct ctl_table hpet_table[] = {
728728
{
729729
.procname = "max-user-freq",
730730
.data = &hpet_max_freq,

drivers/char/ipmi/ipmi_poweroff.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ static struct ipmi_smi_watcher smi_watcher = {
650650
#ifdef CONFIG_PROC_FS
651651
#include <linux/sysctl.h>
652652

653-
static struct ctl_table ipmi_table[] = {
653+
static const struct ctl_table ipmi_table[] = {
654654
{ .procname = "poweroff_powercycle",
655655
.data = &poweroff_powercycle,
656656
.maxlen = sizeof(poweroff_powercycle),

drivers/char/random.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,7 @@ static int proc_do_rointvec(const struct ctl_table *table, int write, void *buf,
16651665
return write ? 0 : proc_dointvec(table, 0, buf, lenp, ppos);
16661666
}
16671667

1668-
static struct ctl_table random_table[] = {
1668+
static const struct ctl_table random_table[] = {
16691669
{
16701670
.procname = "poolsize",
16711671
.data = &sysctl_poolsize,

drivers/gpu/drm/i915/i915_perf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4802,7 +4802,7 @@ int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
48024802
return ret;
48034803
}
48044804

4805-
static struct ctl_table oa_table[] = {
4805+
static const struct ctl_table oa_table[] = {
48064806
{
48074807
.procname = "perf_stream_paranoid",
48084808
.data = &i915_perf_stream_paranoid,

drivers/gpu/drm/xe/xe_observation.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
5656
}
5757
}
5858

59-
static struct ctl_table observation_ctl_table[] = {
59+
static const struct ctl_table observation_ctl_table[] = {
6060
{
6161
.procname = "observation_paranoid",
6262
.data = &xe_observation_paranoid,

drivers/hv/hv_common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static int sysctl_record_panic_msg = 1;
141141
* sysctl option to allow the user to control whether kmsg data should be
142142
* reported to Hyper-V on panic.
143143
*/
144-
static struct ctl_table hv_ctl_table[] = {
144+
static const struct ctl_table hv_ctl_table[] = {
145145
{
146146
.procname = "hyperv_record_panic_msg",
147147
.data = &sysctl_record_panic_msg,

drivers/md/md.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void mddev_destroy_serial_pool(struct mddev *mddev, struct md_rdev *rdev)
294294

295295
static struct ctl_table_header *raid_table_header;
296296

297-
static struct ctl_table raid_table[] = {
297+
static const struct ctl_table raid_table[] = {
298298
{
299299
.procname = "speed_limit_min",
300300
.data = &sysctl_speed_limit_min,

drivers/misc/sgi-xp/xpc_main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ int xpc_disengage_timelimit = XPC_DISENGAGE_DEFAULT_TIMELIMIT;
9393
static int xpc_disengage_min_timelimit; /* = 0 */
9494
static int xpc_disengage_max_timelimit = 120;
9595

96-
static struct ctl_table xpc_sys_xpc_hb[] = {
96+
static const struct ctl_table xpc_sys_xpc_hb[] = {
9797
{
9898
.procname = "hb_interval",
9999
.data = &xpc_hb_interval,
@@ -111,7 +111,7 @@ static struct ctl_table xpc_sys_xpc_hb[] = {
111111
.extra1 = &xpc_hb_check_min_interval,
112112
.extra2 = &xpc_hb_check_max_interval},
113113
};
114-
static struct ctl_table xpc_sys_xpc[] = {
114+
static const struct ctl_table xpc_sys_xpc[] = {
115115
{
116116
.procname = "disengage_timelimit",
117117
.data = &xpc_disengage_timelimit,

drivers/perf/arm_pmuv3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ static int armv8pmu_proc_user_access_handler(const struct ctl_table *table, int
12791279
return 0;
12801280
}
12811281

1282-
static struct ctl_table armv8_pmu_sysctl_table[] = {
1282+
static const struct ctl_table armv8_pmu_sysctl_table[] = {
12831283
{
12841284
.procname = "perf_user_access",
12851285
.data = &sysctl_perf_user_access,

drivers/perf/riscv_pmu_sbi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ static int riscv_pmu_proc_user_access_handler(const struct ctl_table *table,
13171317
return 0;
13181318
}
13191319

1320-
static struct ctl_table sbi_pmu_sysctl_table[] = {
1320+
static const struct ctl_table sbi_pmu_sysctl_table[] = {
13211321
{
13221322
.procname = "perf_user_access",
13231323
.data = &sysctl_perf_user_access,

drivers/scsi/scsi_sysctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "scsi_priv.h"
1313

1414

15-
static struct ctl_table scsi_table[] = {
15+
static const struct ctl_table scsi_table[] = {
1616
{ .procname = "logging_level",
1717
.data = &scsi_logging_level,
1818
.maxlen = sizeof(scsi_logging_level),

drivers/scsi/sg.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))");
16391639
#ifdef CONFIG_SYSCTL
16401640
#include <linux/sysctl.h>
16411641

1642-
static struct ctl_table sg_sysctls[] = {
1642+
static const struct ctl_table sg_sysctls[] = {
16431643
{
16441644
.procname = "sg-big-buff",
16451645
.data = &sg_big_buff,

drivers/tty/tty_io.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3617,7 +3617,7 @@ void console_sysfs_notify(void)
36173617
sysfs_notify(&consdev->kobj, NULL, "active");
36183618
}
36193619

3620-
static struct ctl_table tty_table[] = {
3620+
static const struct ctl_table tty_table[] = {
36213621
{
36223622
.procname = "legacy_tiocsti",
36233623
.data = &tty_legacy_tiocsti,

drivers/xen/balloon.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module_param(balloon_boot_timeout, uint, 0444);
8484
#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
8585
static int xen_hotplug_unpopulated;
8686

87-
static struct ctl_table balloon_table[] = {
87+
static const struct ctl_table balloon_table[] = {
8888
{
8989
.procname = "hotplug_unpopulated",
9090
.data = &xen_hotplug_unpopulated,

fs/aio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static unsigned long aio_nr; /* current system wide number of aio requests */
224224
static unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
225225
/*----end sysctl variables---*/
226226
#ifdef CONFIG_SYSCTL
227-
static struct ctl_table aio_sysctls[] = {
227+
static const struct ctl_table aio_sysctls[] = {
228228
{
229229
.procname = "aio-nr",
230230
.data = &aio_nr,

fs/cachefiles/error_inject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
unsigned int cachefiles_error_injection_state;
1212

1313
static struct ctl_table_header *cachefiles_sysctl;
14-
static struct ctl_table cachefiles_sysctls[] = {
14+
static const struct ctl_table cachefiles_sysctls[] = {
1515
{
1616
.procname = "error_injection",
1717
.data = &cachefiles_error_injection_state,

fs/coda/sysctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
static struct ctl_table_header *fs_table_header;
1616

17-
static struct ctl_table coda_table[] = {
17+
static const struct ctl_table coda_table[] = {
1818
{
1919
.procname = "timeout",
2020
.data = &coda_timeout,

fs/coredump.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ static int proc_dostring_coredump(const struct ctl_table *table, int write,
995995
static const unsigned int core_file_note_size_min = CORE_FILE_NOTE_SIZE_DEFAULT;
996996
static const unsigned int core_file_note_size_max = CORE_FILE_NOTE_SIZE_MAX;
997997

998-
static struct ctl_table coredump_sysctls[] = {
998+
static const struct ctl_table coredump_sysctls[] = {
999999
{
10001000
.procname = "core_uses_pid",
10011001
.data = &core_uses_pid,

fs/dcache.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static int proc_nr_dentry(const struct ctl_table *table, int write, void *buffer
192192
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
193193
}
194194

195-
static struct ctl_table fs_dcache_sysctls[] = {
195+
static const struct ctl_table fs_dcache_sysctls[] = {
196196
{
197197
.procname = "dentry-state",
198198
.data = &dentry_stat,

fs/devpts/inode.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int pty_limit_min;
4545
static int pty_limit_max = INT_MAX;
4646
static atomic_t pty_count = ATOMIC_INIT(0);
4747

48-
static struct ctl_table pty_table[] = {
48+
static const struct ctl_table pty_table[] = {
4949
{
5050
.procname = "max",
5151
.maxlen = sizeof(int),

fs/eventpoll.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static void unlist_file(struct epitems_head *head)
318318
static long long_zero;
319319
static long long_max = LONG_MAX;
320320

321-
static struct ctl_table epoll_table[] = {
321+
static const struct ctl_table epoll_table[] = {
322322
{
323323
.procname = "max_user_watches",
324324
.data = &max_user_watches,

fs/exec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,7 @@ static int proc_dointvec_minmax_coredump(const struct ctl_table *table, int writ
21592159
return error;
21602160
}
21612161

2162-
static struct ctl_table fs_exec_sysctls[] = {
2162+
static const struct ctl_table fs_exec_sysctls[] = {
21632163
{
21642164
.procname = "suid_dumpable",
21652165
.data = &suid_dumpable,

fs/file_table.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int proc_nr_files(const struct ctl_table *table, int write, void *buffer,
106106
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
107107
}
108108

109-
static struct ctl_table fs_stat_sysctls[] = {
109+
static const struct ctl_table fs_stat_sysctls[] = {
110110
{
111111
.procname = "file-nr",
112112
.data = &files_stat,

fs/fuse/sysctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static struct ctl_table_header *fuse_table_header;
1313
/* Bound by fuse_init_out max_pages, which is a u16 */
1414
static unsigned int sysctl_fuse_max_pages_limit = 65535;
1515

16-
static struct ctl_table fuse_sysctl_table[] = {
16+
static const struct ctl_table fuse_sysctl_table[] = {
1717
{
1818
.procname = "max_pages_limit",
1919
.data = &fuse_max_pages_limit,

0 commit comments

Comments
 (0)