History

sysctl: treewide: constify the ctl_table argument of proc_handlers

const qualify the struct ctl_table argument in the proc_handler function signatures. This is a prerequisite to moving the static ctl_table structs into .rodata data which will ensure that proc_handler function pointers cannot be modified. This patch has been generated by the following coccinelle script: ``` virtual patch @r1@ identifier ctl, write, buffer, lenp, ppos; identifier func !~ "appldata_(timer|interval)_handler|sched_(rt|rr)_handler|rds_tcp_skbuf_handler|proc_sctp_do_(hmac_alg|rto_min|rto_max|udp_port|alpha_beta|auth|probe_interval)"; @@ int func( - struct ctl_table *ctl + const struct ctl_table *ctl ,int write, void *buffer, size_t *lenp, loff_t *ppos); @r2@ identifier func, ctl, write, buffer, lenp, ppos; @@ int func( - struct ctl_table *ctl + const struct ctl_table *ctl ,int write, void *buffer, size_t *lenp, loff_t *ppos) { ... } @r3@ identifier func; @@ int func( - struct ctl_table * + const struct ctl_table * ,int , void *, size_t *, loff_t *); @r4@ identifier func, ctl; @@ int func( - struct ctl_table *ctl + const struct ctl_table *ctl ,int , void *, size_t *, loff_t *); @r5@ identifier func, write, buffer, lenp, ppos; @@ int func( - struct ctl_table * + const struct ctl_table * ,int write, void *buffer, size_t *lenp, loff_t *ppos); ``` * Code formatting was adjusted in xfs_sysctl.c to comply with code conventions. The xfs_stats_clear_proc_handler, xfs_panic_mask_proc_handler and xfs_deprecated_dointvec_minmax where adjusted. * The ctl_table argument in proc_watchdog_common was const qualified. This is called from a proc_handler itself and is calling back into another proc_handler, making it necessary to change it as part of the proc_handler migration.

Joel Granados committed 2 years ago

Commit 78eb4ea1 parent 7a3fad393 files · +258 −258Browse files

Showing the changes to include (10 of 93 files). Show all

Unified · Split

10 files
  1. include/linux/ftrace.h +2 −2
  2. include/linux/mm.h +4 −4
  3. include/linux/perf_event.h +3 −3
  4. include/linux/security.h +1 −1
  5. include/linux/sysctl.h +17 −17
  6. include/linux/vmstat.h +2 −2
  7. include/linux/writeback.h +1 −1
  8. include/net/ndisc.h +1 −1
  9. include/net/neighbour.h +3 −3
  10. include/net/netfilter/nf_hooks_lwtunnel.h +1 −1
include/linux/ftrace.h+2−2
@@ -471,7 +471,7 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, · 470 unmodified lines
471471
472472 extern int stack_tracer_enabled;
473473
474−int stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
474+int stack_trace_sysctl(const struct ctl_table *table, int write, void *buffer,
475475 size_t *lenp, loff_t *ppos);
476476
477477 /* DO NOT MODIFY THIS VARIABLE DIRECTLY! */
@@ -1175,7 +1175,7 @@ extern int tracepoint_printk; · 697 unmodified lines
11751175 extern void disable_trace_on_warning(void);
11761176 extern int __disable_trace_on_warning;
11771177
1178−int tracepoint_printk_sysctl(struct ctl_table *table, int write,
1178+int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
11791179 void *buffer, size_t *lenp, loff_t *ppos);
11801180
11811181 #else /* CONFIG_TRACING */
include/linux/mm.h+4−4
@@ -204,11 +204,11 @@ extern int sysctl_overcommit_memory; · 203 unmodified lines
204204 extern int sysctl_overcommit_ratio;
205205 extern unsigned long sysctl_overcommit_kbytes;
206206
207−int overcommit_ratio_handler(struct ctl_table *, int, void *, size_t *,
207+int overcommit_ratio_handler(const struct ctl_table *, int, void *, size_t *,
208208 loff_t *);
209−int overcommit_kbytes_handler(struct ctl_table *, int, void *, size_t *,
209+int overcommit_kbytes_handler(const struct ctl_table *, int, void *, size_t *,
210210 loff_t *);
211−int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
211+int overcommit_policy_handler(const struct ctl_table *, int, void *, size_t *,
212212 loff_t *);
213213
214214 #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
@@ -3854,7 +3854,7 @@ extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); · 3639 unmodified lines
38543854
38553855 #ifdef CONFIG_SYSCTL
38563856 extern int sysctl_drop_caches;
3857−int drop_caches_sysctl_handler(struct ctl_table *, int, void *, size_t *,
3857+int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *,
38583858 loff_t *);
38593859 #endif
38603860
include/linux/perf_event.h+3−3
@@ -1582,11 +1582,11 @@ extern int sysctl_perf_cpu_time_max_percent; · 1581 unmodified lines
15821582
15831583 extern void perf_sample_event_took(u64 sample_len_ns);
15841584
1585−int perf_event_max_sample_rate_handler(struct ctl_table *table, int write,
1585+int perf_event_max_sample_rate_handler(const struct ctl_table *table, int write,
15861586 void *buffer, size_t *lenp, loff_t *ppos);
1587−int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
1587+int perf_cpu_time_max_percent_handler(const struct ctl_table *table, int write,
15881588 void *buffer, size_t *lenp, loff_t *ppos);
1589−int perf_event_max_stack_handler(struct ctl_table *table, int write,
1589+int perf_event_max_stack_handler(const struct ctl_table *table, int write,
15901590 void *buffer, size_t *lenp, loff_t *ppos);
15911591
15921592 /* Access to perf_event_open(2) syscall. */
include/linux/security.h+1−1
@@ -228,7 +228,7 @@ struct request_sock; · 227 unmodified lines
228228 #define LSM_UNSAFE_NO_NEW_PRIVS 4
229229
230230 #ifdef CONFIG_MMU
231−extern int mmap_min_addr_handler(struct ctl_table *table, int write,
231+extern int mmap_min_addr_handler(const struct ctl_table *table, int write,
232232 void *buffer, size_t *lenp, loff_t *ppos);
233233 #endif
234234
include/linux/sysctl.h+17−17
@@ -61,31 +61,31 @@ extern const int sysctl_vals[]; · 60 unmodified lines
6161
6262 extern const unsigned long sysctl_long_vals[];
6363
64−typedef int proc_handler(struct ctl_table *ctl, int write, void *buffer,
64+typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
6565 size_t *lenp, loff_t *ppos);
6666
67−int proc_dostring(struct ctl_table *, int, void *, size_t *, loff_t *);
68−int proc_dobool(struct ctl_table *table, int write, void *buffer,
67+int proc_dostring(const struct ctl_table *, int, void *, size_t *, loff_t *);
68+int proc_dobool(const struct ctl_table *table, int write, void *buffer,
6969 size_t *lenp, loff_t *ppos);
70−int proc_dointvec(struct ctl_table *, int, void *, size_t *, loff_t *);
71−int proc_douintvec(struct ctl_table *, int, void *, size_t *, loff_t *);
72−int proc_dointvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);
73−int proc_douintvec_minmax(struct ctl_table *table, int write, void *buffer,
70+int proc_dointvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
71+int proc_douintvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
72+int proc_dointvec_minmax(const struct ctl_table *, int, void *, size_t *, loff_t *);
73+int proc_douintvec_minmax(const struct ctl_table *table, int write, void *buffer,
7474 size_t *lenp, loff_t *ppos);
75−int proc_dou8vec_minmax(struct ctl_table *table, int write, void *buffer,
75+int proc_dou8vec_minmax(const struct ctl_table *table, int write, void *buffer,
7676 size_t *lenp, loff_t *ppos);
77−int proc_dointvec_jiffies(struct ctl_table *, int, void *, size_t *, loff_t *);
78−int proc_dointvec_ms_jiffies_minmax(struct ctl_table *table, int write,
77+int proc_dointvec_jiffies(const struct ctl_table *, int, void *, size_t *, loff_t *);
78+int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int write,
7979 void *buffer, size_t *lenp, loff_t *ppos);
80−int proc_dointvec_userhz_jiffies(struct ctl_table *, int, void *, size_t *,
80+int proc_dointvec_userhz_jiffies(const struct ctl_table *, int, void *, size_t *,
8181 loff_t *);
82−int proc_dointvec_ms_jiffies(struct ctl_table *, int, void *, size_t *,
82+int proc_dointvec_ms_jiffies(const struct ctl_table *, int, void *, size_t *,
8383 loff_t *);
84−int proc_doulongvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);
85−int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int, void *,
84+int proc_doulongvec_minmax(const struct ctl_table *, int, void *, size_t *, loff_t *);
85+int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int, void *,
8686 size_t *, loff_t *);
87−int proc_do_large_bitmap(struct ctl_table *, int, void *, size_t *, loff_t *);
88−int proc_do_static_key(struct ctl_table *table, int write, void *buffer,
87+int proc_do_large_bitmap(const struct ctl_table *, int, void *, size_t *, loff_t *);
88+int proc_do_static_key(const struct ctl_table *table, int write, void *buffer,
8989 size_t *lenp, loff_t *ppos);
9090
9191 /*
@@ -287,7 +287,7 @@ static inline bool sysctl_is_alias(char *param) · 195 unmodified lines
287287 }
288288 #endif /* CONFIG_SYSCTL */
289289
290−int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,
290+int sysctl_max_threads(const struct ctl_table *table, int write, void *buffer,
291291 size_t *lenp, loff_t *ppos);
292292
293293 #endif /* _LINUX_SYSCTL_H */
include/linux/vmstat.h+2−2
@@ -17,7 +17,7 @@ extern int sysctl_stat_interval; · 16 unmodified lines
1717 #define DISABLE_NUMA_STAT 0
1818 extern int sysctl_vm_numa_stat;
1919 DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
20−int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write,
20+int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
2121 void *buffer, size_t *length, loff_t *ppos);
2222 #endif
2323
@@ -301,7 +301,7 @@ void cpu_vm_stats_fold(int cpu); · 277 unmodified lines
301301 void refresh_zone_stat_thresholds(void);
302302
303303 struct ctl_table;
304−int vmstat_refresh(struct ctl_table *, int write, void *buffer, size_t *lenp,
304+int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp,
305305 loff_t *ppos);
306306
307307 void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *);
include/linux/writeback.h+1−1
@@ -350,7 +350,7 @@ extern unsigned int dirty_expire_interval; · 349 unmodified lines
350350 extern unsigned int dirtytime_expire_interval;
351351 extern int laptop_mode;
352352
353−int dirtytime_interval_handler(struct ctl_table *table, int write,
353+int dirtytime_interval_handler(const struct ctl_table *table, int write,
354354 void *buffer, size_t *lenp, loff_t *ppos);
355355
356356 void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
include/net/ndisc.h+1−1
@@ -486,7 +486,7 @@ void igmp6_event_report(struct sk_buff *skb); · 485 unmodified lines
486486
487487
488488 #ifdef CONFIG_SYSCTL
489−int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
489+int ndisc_ifinfo_sysctl_change(const struct ctl_table *ctl, int write,
490490 void *buffer, size_t *lenp, loff_t *ppos);
491491 #endif
492492
include/net/neighbour.h+3−3
@@ -412,12 +412,12 @@ void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *, · 411 unmodified lines
412412 void *neigh_seq_next(struct seq_file *, void *, loff_t *);
413413 void neigh_seq_stop(struct seq_file *, void *);
414414
415−int neigh_proc_dointvec(struct ctl_table *ctl, int write,
415+int neigh_proc_dointvec(const struct ctl_table *ctl, int write,
416416 void *buffer, size_t *lenp, loff_t *ppos);
417−int neigh_proc_dointvec_jiffies(struct ctl_table *ctl, int write,
417+int neigh_proc_dointvec_jiffies(const struct ctl_table *ctl, int write,
418418 void *buffer,
419419 size_t *lenp, loff_t *ppos);
420−int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write,
420+int neigh_proc_dointvec_ms_jiffies(const struct ctl_table *ctl, int write,
421421 void *buffer, size_t *lenp, loff_t *ppos);
422422
423423 int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
include/net/netfilter/nf_hooks_lwtunnel.h+1−1
@@ -2,6 +2,6 @@ · 1 unmodified line
22 #include <linux/types.h>
33
44 #ifdef CONFIG_SYSCTL
5−int nf_hooks_lwtunnel_sysctl_handler(struct ctl_table *table, int write,
5+int nf_hooks_lwtunnel_sysctl_handler(const struct ctl_table *table, int write,
66 void *buffer, size_t *lenp, loff_t *ppos);
77 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t