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 <song@kernel.org> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> # for kernel/trace/ Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> # SCSI Reviewed-by: Darrick J. Wong <djwong@kernel.org> # xfs Acked-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Corey Minyard <cminyard@mvista.com> Acked-by: Wei Liu <wei.liu@kernel.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Bill O'Donnell <bodonnel@redhat.com> Acked-by: Baoquan He <bhe@redhat.com> Acked-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Acked-by: Anna Schumaker <anna.schumaker@oracle.com> Signed-off-by: Joel Granados <joel.granados@kernel.org>
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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,

0 commit comments

Comments
 (0)