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
471 471
472extern int stack_tracer_enabled;472extern int stack_tracer_enabled;
473 473
474int stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,474int stack_trace_sysctl(const struct ctl_table *table, int write, void *buffer,
475 size_t *lenp, loff_t *ppos);475 size_t *lenp, loff_t *ppos);
476 476
477/* DO NOT MODIFY THIS VARIABLE DIRECTLY! */477/* DO NOT MODIFY THIS VARIABLE DIRECTLY! */
@@ -1175,7 +1175,7 @@ extern int tracepoint_printk; · 697 unmodified lines
1175extern void disable_trace_on_warning(void);1175extern void disable_trace_on_warning(void);
1176extern int __disable_trace_on_warning;1176extern int __disable_trace_on_warning;
1177 1177
1178int tracepoint_printk_sysctl(struct ctl_table *table, int write,1178int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
1179 void *buffer, size_t *lenp, loff_t *ppos);1179 void *buffer, size_t *lenp, loff_t *ppos);
1180 1180
1181#else /* CONFIG_TRACING */1181#else /* CONFIG_TRACING */
include/linux/mm.h+4−4
@@ -204,11 +204,11 @@ extern int sysctl_overcommit_memory; · 203 unmodified lines
204extern int sysctl_overcommit_ratio;204extern int sysctl_overcommit_ratio;
205extern unsigned long sysctl_overcommit_kbytes;205extern unsigned long sysctl_overcommit_kbytes;
206 206
207int overcommit_ratio_handler(struct ctl_table *, int, void *, size_t *,207int overcommit_ratio_handler(const struct ctl_table *, int, void *, size_t *,
208 loff_t *);208 loff_t *);
209int overcommit_kbytes_handler(struct ctl_table *, int, void *, size_t *,209int overcommit_kbytes_handler(const struct ctl_table *, int, void *, size_t *,
210 loff_t *);210 loff_t *);
211int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,211int overcommit_policy_handler(const struct ctl_table *, int, void *, size_t *,
212 loff_t *);212 loff_t *);
213 213
214#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)214#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
3854 3854
3855#ifdef CONFIG_SYSCTL3855#ifdef CONFIG_SYSCTL
3856extern int sysctl_drop_caches;3856extern int sysctl_drop_caches;
3857int drop_caches_sysctl_handler(struct ctl_table *, int, void *, size_t *,3857int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *,
3858 loff_t *);3858 loff_t *);
3859#endif3859#endif
3860 3860
include/linux/perf_event.h+3−3
@@ -1582,11 +1582,11 @@ extern int sysctl_perf_cpu_time_max_percent; · 1581 unmodified lines
1582 1582
1583extern void perf_sample_event_took(u64 sample_len_ns);1583extern void perf_sample_event_took(u64 sample_len_ns);
1584 1584
1585int perf_event_max_sample_rate_handler(struct ctl_table *table, int write,1585int perf_event_max_sample_rate_handler(const struct ctl_table *table, int write,
1586 void *buffer, size_t *lenp, loff_t *ppos);1586 void *buffer, size_t *lenp, loff_t *ppos);
1587int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,1587int perf_cpu_time_max_percent_handler(const struct ctl_table *table, int write,
1588 void *buffer, size_t *lenp, loff_t *ppos);1588 void *buffer, size_t *lenp, loff_t *ppos);
1589int perf_event_max_stack_handler(struct ctl_table *table, int write,1589int perf_event_max_stack_handler(const struct ctl_table *table, int write,
1590 void *buffer, size_t *lenp, loff_t *ppos);1590 void *buffer, size_t *lenp, loff_t *ppos);
1591 1591
1592/* Access to perf_event_open(2) syscall. */1592/* Access to perf_event_open(2) syscall. */
include/linux/security.h+1−1
@@ -228,7 +228,7 @@ struct request_sock; · 227 unmodified lines
228#define LSM_UNSAFE_NO_NEW_PRIVS 4228#define LSM_UNSAFE_NO_NEW_PRIVS 4
229 229
230#ifdef CONFIG_MMU230#ifdef CONFIG_MMU
231extern int mmap_min_addr_handler(struct ctl_table *table, int write,231extern int mmap_min_addr_handler(const struct ctl_table *table, int write,
232 void *buffer, size_t *lenp, loff_t *ppos);232 void *buffer, size_t *lenp, loff_t *ppos);
233#endif233#endif
234 234
include/linux/sysctl.h+17−17
@@ -61,31 +61,31 @@ extern const int sysctl_vals[]; · 60 unmodified lines
61 61
62extern const unsigned long sysctl_long_vals[];62extern const unsigned long sysctl_long_vals[];
63 63
64typedef int proc_handler(struct ctl_table *ctl, int write, void *buffer,64typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
65 size_t *lenp, loff_t *ppos);65 size_t *lenp, loff_t *ppos);
66 66
67int proc_dostring(struct ctl_table *, int, void *, size_t *, loff_t *);67int proc_dostring(const struct ctl_table *, int, void *, size_t *, loff_t *);
68int proc_dobool(struct ctl_table *table, int write, void *buffer,68int proc_dobool(const struct ctl_table *table, int write, void *buffer,
69 size_t *lenp, loff_t *ppos);69 size_t *lenp, loff_t *ppos);
70int proc_dointvec(struct ctl_table *, int, void *, size_t *, loff_t *);70int proc_dointvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
71int proc_douintvec(struct ctl_table *, int, void *, size_t *, loff_t *);71int proc_douintvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
72int proc_dointvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);72int proc_dointvec_minmax(const struct ctl_table *, int, void *, size_t *, loff_t *);
73int proc_douintvec_minmax(struct ctl_table *table, int write, void *buffer,73int proc_douintvec_minmax(const struct ctl_table *table, int write, void *buffer,
74 size_t *lenp, loff_t *ppos);74 size_t *lenp, loff_t *ppos);
75int proc_dou8vec_minmax(struct ctl_table *table, int write, void *buffer,75int proc_dou8vec_minmax(const struct ctl_table *table, int write, void *buffer,
76 size_t *lenp, loff_t *ppos);76 size_t *lenp, loff_t *ppos);
77int proc_dointvec_jiffies(struct ctl_table *, int, void *, size_t *, loff_t *);77int proc_dointvec_jiffies(const struct ctl_table *, int, void *, size_t *, loff_t *);
78int proc_dointvec_ms_jiffies_minmax(struct ctl_table *table, int write,78int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int write,
79 void *buffer, size_t *lenp, loff_t *ppos);79 void *buffer, size_t *lenp, loff_t *ppos);
80int proc_dointvec_userhz_jiffies(struct ctl_table *, int, void *, size_t *,80int proc_dointvec_userhz_jiffies(const struct ctl_table *, int, void *, size_t *,
81 loff_t *);81 loff_t *);
82int proc_dointvec_ms_jiffies(struct ctl_table *, int, void *, size_t *,82int proc_dointvec_ms_jiffies(const struct ctl_table *, int, void *, size_t *,
83 loff_t *);83 loff_t *);
84int proc_doulongvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);84int proc_doulongvec_minmax(const struct ctl_table *, int, void *, size_t *, loff_t *);
85int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int, void *,85int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int, void *,
86 size_t *, loff_t *);86 size_t *, loff_t *);
87int proc_do_large_bitmap(struct ctl_table *, int, void *, size_t *, loff_t *);87int proc_do_large_bitmap(const struct ctl_table *, int, void *, size_t *, loff_t *);
88int proc_do_static_key(struct ctl_table *table, int write, void *buffer,88int proc_do_static_key(const struct ctl_table *table, int write, void *buffer,
89 size_t *lenp, loff_t *ppos);89 size_t *lenp, loff_t *ppos);
90 90
91/*91/*
@@ -287,7 +287,7 @@ static inline bool sysctl_is_alias(char *param) · 195 unmodified lines
287}287}
288#endif /* CONFIG_SYSCTL */288#endif /* CONFIG_SYSCTL */
289 289
290int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,290int sysctl_max_threads(const struct ctl_table *table, int write, void *buffer,
291 size_t *lenp, loff_t *ppos);291 size_t *lenp, loff_t *ppos);
292 292
293#endif /* _LINUX_SYSCTL_H */293#endif /* _LINUX_SYSCTL_H */
include/linux/vmstat.h+2−2
@@ -17,7 +17,7 @@ extern int sysctl_stat_interval; · 16 unmodified lines
17#define DISABLE_NUMA_STAT 017#define DISABLE_NUMA_STAT 0
18extern int sysctl_vm_numa_stat;18extern int sysctl_vm_numa_stat;
19DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);19DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
20int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write,20int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
21 void *buffer, size_t *length, loff_t *ppos);21 void *buffer, size_t *length, loff_t *ppos);
22#endif22#endif
23 23
@@ -301,7 +301,7 @@ void cpu_vm_stats_fold(int cpu); · 277 unmodified lines
301void refresh_zone_stat_thresholds(void);301void refresh_zone_stat_thresholds(void);
302 302
303struct ctl_table;303struct ctl_table;
304int vmstat_refresh(struct ctl_table *, int write, void *buffer, size_t *lenp,304int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp,
305 loff_t *ppos);305 loff_t *ppos);
306 306
307void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *);307void 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
350extern unsigned int dirtytime_expire_interval;350extern unsigned int dirtytime_expire_interval;
351extern int laptop_mode;351extern int laptop_mode;
352 352
353int dirtytime_interval_handler(struct ctl_table *table, int write,353int dirtytime_interval_handler(const struct ctl_table *table, int write,
354 void *buffer, size_t *lenp, loff_t *ppos);354 void *buffer, size_t *lenp, loff_t *ppos);
355 355
356void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);356void 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
486 486
487 487
488#ifdef CONFIG_SYSCTL488#ifdef CONFIG_SYSCTL
489int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,489int ndisc_ifinfo_sysctl_change(const struct ctl_table *ctl, int write,
490 void *buffer, size_t *lenp, loff_t *ppos);490 void *buffer, size_t *lenp, loff_t *ppos);
491#endif491#endif
492 492
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
412void *neigh_seq_next(struct seq_file *, void *, loff_t *);412void *neigh_seq_next(struct seq_file *, void *, loff_t *);
413void neigh_seq_stop(struct seq_file *, void *);413void neigh_seq_stop(struct seq_file *, void *);
414 414
415int neigh_proc_dointvec(struct ctl_table *ctl, int write,415int neigh_proc_dointvec(const struct ctl_table *ctl, int write,
416 void *buffer, size_t *lenp, loff_t *ppos);416 void *buffer, size_t *lenp, loff_t *ppos);
417int neigh_proc_dointvec_jiffies(struct ctl_table *ctl, int write,417int neigh_proc_dointvec_jiffies(const struct ctl_table *ctl, int write,
418 void *buffer,418 void *buffer,
419 size_t *lenp, loff_t *ppos);419 size_t *lenp, loff_t *ppos);
420int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write,420int neigh_proc_dointvec_ms_jiffies(const struct ctl_table *ctl, int write,
421 void *buffer, size_t *lenp, loff_t *ppos);421 void *buffer, size_t *lenp, loff_t *ppos);
422 422
423int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,423int 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
2#include <linux/types.h>2#include <linux/types.h>
3 3
4#ifdef CONFIG_SYSCTL4#ifdef CONFIG_SYSCTL
5int nf_hooks_lwtunnel_sysctl_handler(struct ctl_table *table, int write,5int nf_hooks_lwtunnel_sysctl_handler(const struct ctl_table *table, int write,
6 void *buffer, size_t *lenp, loff_t *ppos);6 void *buffer, size_t *lenp, loff_t *ppos);
7#endif7#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