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.
Showing the changes to include (10 of 93 files). Show all
Unified · Split
| @@ -471,7 +471,7 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, · 470 unmodified lines | ||
| 471 | 471 | |
| 472 | 472 | extern int stack_tracer_enabled; |
| 473 | 473 | |
| 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, | |
| 475 | 475 | size_t *lenp, loff_t *ppos); |
| 476 | 476 | |
| 477 | 477 | /* DO NOT MODIFY THIS VARIABLE DIRECTLY! */ |
| @@ -1175,7 +1175,7 @@ extern int tracepoint_printk; · 697 unmodified lines | ||
| 1175 | 1175 | extern void disable_trace_on_warning(void); |
| 1176 | 1176 | extern int __disable_trace_on_warning; |
| 1177 | 1177 | |
| 1178 | −int tracepoint_printk_sysctl(struct ctl_table *table, int write, | |
| 1178 | +int tracepoint_printk_sysctl(const struct ctl_table *table, int write, | |
| 1179 | 1179 | void *buffer, size_t *lenp, loff_t *ppos); |
| 1180 | 1180 | |
| 1181 | 1181 | #else /* CONFIG_TRACING */ |
| @@ -204,11 +204,11 @@ extern int sysctl_overcommit_memory; · 203 unmodified lines | ||
| 204 | 204 | extern int sysctl_overcommit_ratio; |
| 205 | 205 | extern unsigned long sysctl_overcommit_kbytes; |
| 206 | 206 | |
| 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 *, | |
| 208 | 208 | 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 *, | |
| 210 | 210 | 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 *, | |
| 212 | 212 | loff_t *); |
| 213 | 213 | |
| 214 | 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 | 3855 | #ifdef CONFIG_SYSCTL |
| 3856 | 3856 | 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 *, | |
| 3858 | 3858 | loff_t *); |
| 3859 | 3859 | #endif |
| 3860 | 3860 | |
| @@ -1582,11 +1582,11 @@ extern int sysctl_perf_cpu_time_max_percent; · 1581 unmodified lines | ||
| 1582 | 1582 | |
| 1583 | 1583 | extern void perf_sample_event_took(u64 sample_len_ns); |
| 1584 | 1584 | |
| 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, | |
| 1586 | 1586 | 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, | |
| 1588 | 1588 | 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, | |
| 1590 | 1590 | void *buffer, size_t *lenp, loff_t *ppos); |
| 1591 | 1591 | |
| 1592 | 1592 | /* Access to perf_event_open(2) syscall. */ |
| @@ -228,7 +228,7 @@ struct request_sock; · 227 unmodified lines | ||
| 228 | 228 | #define LSM_UNSAFE_NO_NEW_PRIVS 4 |
| 229 | 229 | |
| 230 | 230 | #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, | |
| 232 | 232 | void *buffer, size_t *lenp, loff_t *ppos); |
| 233 | 233 | #endif |
| 234 | 234 | |
| @@ -61,31 +61,31 @@ extern const int sysctl_vals[]; · 60 unmodified lines | ||
| 61 | 61 | |
| 62 | 62 | extern const unsigned long sysctl_long_vals[]; |
| 63 | 63 | |
| 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, | |
| 65 | 65 | size_t *lenp, loff_t *ppos); |
| 66 | 66 | |
| 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, | |
| 69 | 69 | 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, | |
| 74 | 74 | 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, | |
| 76 | 76 | 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, | |
| 79 | 79 | 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 *, | |
| 81 | 81 | 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 *, | |
| 83 | 83 | 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 *, | |
| 86 | 86 | 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, | |
| 89 | 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 | 288 | #endif /* CONFIG_SYSCTL */ |
| 289 | 289 | |
| 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, | |
| 291 | 291 | size_t *lenp, loff_t *ppos); |
| 292 | 292 | |
| 293 | 293 | #endif /* _LINUX_SYSCTL_H */ |
| @@ -17,7 +17,7 @@ extern int sysctl_stat_interval; · 16 unmodified lines | ||
| 17 | 17 | #define DISABLE_NUMA_STAT 0 |
| 18 | 18 | extern int sysctl_vm_numa_stat; |
| 19 | 19 | 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, | |
| 21 | 21 | void *buffer, size_t *length, loff_t *ppos); |
| 22 | 22 | #endif |
| 23 | 23 | |
| @@ -301,7 +301,7 @@ void cpu_vm_stats_fold(int cpu); · 277 unmodified lines | ||
| 301 | 301 | void refresh_zone_stat_thresholds(void); |
| 302 | 302 | |
| 303 | 303 | 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, | |
| 305 | 305 | loff_t *ppos); |
| 306 | 306 | |
| 307 | 307 | void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *); |
| @@ -350,7 +350,7 @@ extern unsigned int dirty_expire_interval; · 349 unmodified lines | ||
| 350 | 350 | extern unsigned int dirtytime_expire_interval; |
| 351 | 351 | extern int laptop_mode; |
| 352 | 352 | |
| 353 | −int dirtytime_interval_handler(struct ctl_table *table, int write, | |
| 353 | +int dirtytime_interval_handler(const struct ctl_table *table, int write, | |
| 354 | 354 | void *buffer, size_t *lenp, loff_t *ppos); |
| 355 | 355 | |
| 356 | 356 | void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty); |
| @@ -486,7 +486,7 @@ void igmp6_event_report(struct sk_buff *skb); · 485 unmodified lines | ||
| 486 | 486 | |
| 487 | 487 | |
| 488 | 488 | #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, | |
| 490 | 490 | void *buffer, size_t *lenp, loff_t *ppos); |
| 491 | 491 | #endif |
| 492 | 492 | |
| @@ -412,12 +412,12 @@ void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *, · 411 unmodified lines | ||
| 412 | 412 | void *neigh_seq_next(struct seq_file *, void *, loff_t *); |
| 413 | 413 | void neigh_seq_stop(struct seq_file *, void *); |
| 414 | 414 | |
| 415 | −int neigh_proc_dointvec(struct ctl_table *ctl, int write, | |
| 415 | +int neigh_proc_dointvec(const struct ctl_table *ctl, int write, | |
| 416 | 416 | 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, | |
| 418 | 418 | void *buffer, |
| 419 | 419 | 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, | |
| 421 | 421 | void *buffer, size_t *lenp, loff_t *ppos); |
| 422 | 422 | |
| 423 | 423 | int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, |
| @@ -2,6 +2,6 @@ · 1 unmodified line | ||
| 2 | 2 | #include <linux/types.h> |
| 3 | 3 | |
| 4 | 4 | #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, | |
| 6 | 6 | void *buffer, size_t *lenp, loff_t *ppos); |
| 7 | 7 | #endif |