mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-22 09:45:08 -04:00
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.
Co-developed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Co-developed-by: Joel Granados <j.granados@samsung.com>
Signed-off-by: Joel Granados <j.granados@samsung.com>
This commit is contained in:
@@ -471,7 +471,7 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs,
|
||||
|
||||
extern int stack_tracer_enabled;
|
||||
|
||||
int stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
|
||||
int stack_trace_sysctl(const struct ctl_table *table, int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
|
||||
/* DO NOT MODIFY THIS VARIABLE DIRECTLY! */
|
||||
@@ -1175,7 +1175,7 @@ extern int tracepoint_printk;
|
||||
extern void disable_trace_on_warning(void);
|
||||
extern int __disable_trace_on_warning;
|
||||
|
||||
int tracepoint_printk_sysctl(struct ctl_table *table, int write,
|
||||
int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
|
||||
#else /* CONFIG_TRACING */
|
||||
|
||||
@@ -204,11 +204,11 @@ extern int sysctl_overcommit_memory;
|
||||
extern int sysctl_overcommit_ratio;
|
||||
extern unsigned long sysctl_overcommit_kbytes;
|
||||
|
||||
int overcommit_ratio_handler(struct ctl_table *, int, void *, size_t *,
|
||||
int overcommit_ratio_handler(const struct ctl_table *, int, void *, size_t *,
|
||||
loff_t *);
|
||||
int overcommit_kbytes_handler(struct ctl_table *, int, void *, size_t *,
|
||||
int overcommit_kbytes_handler(const struct ctl_table *, int, void *, size_t *,
|
||||
loff_t *);
|
||||
int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
|
||||
int overcommit_policy_handler(const struct ctl_table *, int, void *, size_t *,
|
||||
loff_t *);
|
||||
|
||||
#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);
|
||||
|
||||
#ifdef CONFIG_SYSCTL
|
||||
extern int sysctl_drop_caches;
|
||||
int drop_caches_sysctl_handler(struct ctl_table *, int, void *, size_t *,
|
||||
int drop_caches_sysctl_handler(const struct ctl_table *, int, void *, size_t *,
|
||||
loff_t *);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1582,11 +1582,11 @@ extern int sysctl_perf_cpu_time_max_percent;
|
||||
|
||||
extern void perf_sample_event_took(u64 sample_len_ns);
|
||||
|
||||
int perf_event_max_sample_rate_handler(struct ctl_table *table, int write,
|
||||
int perf_event_max_sample_rate_handler(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
|
||||
int perf_cpu_time_max_percent_handler(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
int perf_event_max_stack_handler(struct ctl_table *table, int write,
|
||||
int perf_event_max_stack_handler(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
|
||||
/* Access to perf_event_open(2) syscall. */
|
||||
|
||||
@@ -228,7 +228,7 @@ struct request_sock;
|
||||
#define LSM_UNSAFE_NO_NEW_PRIVS 4
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
extern int mmap_min_addr_handler(struct ctl_table *table, int write,
|
||||
extern int mmap_min_addr_handler(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -61,31 +61,31 @@ extern const int sysctl_vals[];
|
||||
|
||||
extern const unsigned long sysctl_long_vals[];
|
||||
|
||||
typedef int proc_handler(struct ctl_table *ctl, int write, void *buffer,
|
||||
typedef int proc_handler(const struct ctl_table *ctl, int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
|
||||
int proc_dostring(struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_dobool(struct ctl_table *table, int write, void *buffer,
|
||||
int proc_dostring(const struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_dobool(const struct ctl_table *table, int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
int proc_dointvec(struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_douintvec(struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_dointvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_douintvec_minmax(struct ctl_table *table, int write, void *buffer,
|
||||
int proc_dointvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_douintvec(const struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_dointvec_minmax(const struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_douintvec_minmax(const struct ctl_table *table, int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
int proc_dou8vec_minmax(struct ctl_table *table, int write, void *buffer,
|
||||
int proc_dou8vec_minmax(const struct ctl_table *table, int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
int proc_dointvec_jiffies(struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_dointvec_ms_jiffies_minmax(struct ctl_table *table, int write,
|
||||
int proc_dointvec_jiffies(const struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
int proc_dointvec_userhz_jiffies(struct ctl_table *, int, void *, size_t *,
|
||||
int proc_dointvec_userhz_jiffies(const struct ctl_table *, int, void *, size_t *,
|
||||
loff_t *);
|
||||
int proc_dointvec_ms_jiffies(struct ctl_table *, int, void *, size_t *,
|
||||
int proc_dointvec_ms_jiffies(const struct ctl_table *, int, void *, size_t *,
|
||||
loff_t *);
|
||||
int proc_doulongvec_minmax(struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int, void *,
|
||||
int proc_doulongvec_minmax(const struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int, void *,
|
||||
size_t *, loff_t *);
|
||||
int proc_do_large_bitmap(struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_do_static_key(struct ctl_table *table, int write, void *buffer,
|
||||
int proc_do_large_bitmap(const struct ctl_table *, int, void *, size_t *, loff_t *);
|
||||
int proc_do_static_key(const struct ctl_table *table, int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
|
||||
/*
|
||||
@@ -287,7 +287,7 @@ static inline bool sysctl_is_alias(char *param)
|
||||
}
|
||||
#endif /* CONFIG_SYSCTL */
|
||||
|
||||
int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,
|
||||
int sysctl_max_threads(const struct ctl_table *table, int write, void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
|
||||
#endif /* _LINUX_SYSCTL_H */
|
||||
|
||||
@@ -17,7 +17,7 @@ extern int sysctl_stat_interval;
|
||||
#define DISABLE_NUMA_STAT 0
|
||||
extern int sysctl_vm_numa_stat;
|
||||
DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
|
||||
int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write,
|
||||
int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *length, loff_t *ppos);
|
||||
#endif
|
||||
|
||||
@@ -301,7 +301,7 @@ void cpu_vm_stats_fold(int cpu);
|
||||
void refresh_zone_stat_thresholds(void);
|
||||
|
||||
struct ctl_table;
|
||||
int vmstat_refresh(struct ctl_table *, int write, void *buffer, size_t *lenp,
|
||||
int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp,
|
||||
loff_t *ppos);
|
||||
|
||||
void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *);
|
||||
|
||||
@@ -350,7 +350,7 @@ extern unsigned int dirty_expire_interval;
|
||||
extern unsigned int dirtytime_expire_interval;
|
||||
extern int laptop_mode;
|
||||
|
||||
int dirtytime_interval_handler(struct ctl_table *table, int write,
|
||||
int dirtytime_interval_handler(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
|
||||
void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
|
||||
|
||||
@@ -486,7 +486,7 @@ void igmp6_event_report(struct sk_buff *skb);
|
||||
|
||||
|
||||
#ifdef CONFIG_SYSCTL
|
||||
int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
|
||||
int ndisc_ifinfo_sysctl_change(const struct ctl_table *ctl, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -412,12 +412,12 @@ void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *,
|
||||
void *neigh_seq_next(struct seq_file *, void *, loff_t *);
|
||||
void neigh_seq_stop(struct seq_file *, void *);
|
||||
|
||||
int neigh_proc_dointvec(struct ctl_table *ctl, int write,
|
||||
int neigh_proc_dointvec(const struct ctl_table *ctl, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
int neigh_proc_dointvec_jiffies(struct ctl_table *ctl, int write,
|
||||
int neigh_proc_dointvec_jiffies(const struct ctl_table *ctl, int write,
|
||||
void *buffer,
|
||||
size_t *lenp, loff_t *ppos);
|
||||
int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write,
|
||||
int neigh_proc_dointvec_ms_jiffies(const struct ctl_table *ctl, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
|
||||
int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
#include <linux/types.h>
|
||||
|
||||
#ifdef CONFIG_SYSCTL
|
||||
int nf_hooks_lwtunnel_sysctl_handler(struct ctl_table *table, int write,
|
||||
int nf_hooks_lwtunnel_sysctl_handler(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user