Skip to content

Commit 78eb4ea

Browse files
committed
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 <[email protected]> Signed-off-by: Thomas Weißschuh <[email protected]> Co-developed-by: Joel Granados <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent 7a3fad3 commit 78eb4ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+258
-258
lines changed

arch/arm64/kernel/armv8_deprecated.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static int update_insn_emulation_mode(struct insn_emulation *insn,
507507
return ret;
508508
}
509509

510-
static int emulation_proc_handler(struct ctl_table *table, int write,
510+
static int emulation_proc_handler(const struct ctl_table *table, int write,
511511
void *buffer, size_t *lenp,
512512
loff_t *ppos)
513513
{

arch/arm64/kernel/fpsimd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static unsigned int find_supported_vector_length(enum vec_type type,
535535

536536
#if defined(CONFIG_ARM64_SVE) && defined(CONFIG_SYSCTL)
537537

538-
static int vec_proc_do_default_vl(struct ctl_table *table, int write,
538+
static int vec_proc_do_default_vl(const struct ctl_table *table, int write,
539539
void *buffer, size_t *lenp, loff_t *ppos)
540540
{
541541
struct vl_info *info = table->extra1;

arch/s390/appldata/appldata_base.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
* /proc entries (sysctl)
4747
*/
4848
static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH] = "appldata";
49-
static int appldata_timer_handler(struct ctl_table *ctl, int write,
49+
static int appldata_timer_handler(const struct ctl_table *ctl, int write,
5050
void *buffer, size_t *lenp, loff_t *ppos);
51-
static int appldata_interval_handler(struct ctl_table *ctl, int write,
51+
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;
@@ -199,7 +199,7 @@ static void __appldata_vtimer_setup(int cmd)
199199
* Start/Stop timer, show status of timer (0 = not active, 1 = active)
200200
*/
201201
static int
202-
appldata_timer_handler(struct ctl_table *ctl, int write,
202+
appldata_timer_handler(const struct ctl_table *ctl, int write,
203203
void *buffer, size_t *lenp, loff_t *ppos)
204204
{
205205
int timer_active = appldata_timer_active;
@@ -232,7 +232,7 @@ appldata_timer_handler(struct ctl_table *ctl, int write,
232232
* current timer interval.
233233
*/
234234
static int
235-
appldata_interval_handler(struct ctl_table *ctl, int write,
235+
appldata_interval_handler(const struct ctl_table *ctl, int write,
236236
void *buffer, size_t *lenp, loff_t *ppos)
237237
{
238238
int interval = appldata_interval;
@@ -262,7 +262,7 @@ appldata_interval_handler(struct ctl_table *ctl, int write,
262262
* monitoring (0 = not in process, 1 = in process)
263263
*/
264264
static int
265-
appldata_generic_handler(struct ctl_table *ctl, int write,
265+
appldata_generic_handler(const struct ctl_table *ctl, int write,
266266
void *buffer, size_t *lenp, loff_t *ppos)
267267
{
268268
struct appldata_ops *ops = NULL, *tmp_ops;

arch/s390/kernel/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ static int debug_active = 1;
954954
* always allow read, allow write only if debug_stoppable is set or
955955
* if debug_active is already off
956956
*/
957-
static int s390dbf_procactive(struct ctl_table *table, int write,
957+
static int s390dbf_procactive(const struct ctl_table *table, int write,
958958
void *buffer, size_t *lenp, loff_t *ppos)
959959
{
960960
if (!write || debug_stoppable || !debug_active)

arch/s390/kernel/topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static int __init topology_setup(char *str)
594594
}
595595
early_param("topology", topology_setup);
596596

597-
static int topology_ctl_handler(struct ctl_table *ctl, int write,
597+
static int topology_ctl_handler(const struct ctl_table *ctl, int write,
598598
void *buffer, size_t *lenp, loff_t *ppos)
599599
{
600600
int enabled = topology_is_enabled();

arch/s390/mm/cmm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int cmm_skip_blanks(char *cp, char **endp)
243243
return str != cp;
244244
}
245245

246-
static int cmm_pages_handler(struct ctl_table *ctl, int write,
246+
static int cmm_pages_handler(const struct ctl_table *ctl, int write,
247247
void *buffer, size_t *lenp, loff_t *ppos)
248248
{
249249
long nr = cmm_get_pages();
@@ -262,7 +262,7 @@ static int cmm_pages_handler(struct ctl_table *ctl, int write,
262262
return 0;
263263
}
264264

265-
static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
265+
static int cmm_timed_pages_handler(const struct ctl_table *ctl, int write,
266266
void *buffer, size_t *lenp,
267267
loff_t *ppos)
268268
{
@@ -282,7 +282,7 @@ static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
282282
return 0;
283283
}
284284

285-
static int cmm_timeout_handler(struct ctl_table *ctl, int write,
285+
static int cmm_timeout_handler(const struct ctl_table *ctl, int write,
286286
void *buffer, size_t *lenp, loff_t *ppos)
287287
{
288288
char buf[64], *p;

arch/x86/kernel/itmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static bool __read_mostly sched_itmt_capable;
3838
*/
3939
unsigned int __read_mostly sysctl_sched_itmt_enabled;
4040

41-
static int sched_itmt_update_handler(struct ctl_table *table, int write,
41+
static int sched_itmt_update_handler(const struct ctl_table *table, int write,
4242
void *buffer, size_t *lenp, loff_t *ppos)
4343
{
4444
unsigned int old_sysctl;

drivers/cdrom/cdrom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,7 +3473,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
34733473
return 0;
34743474
}
34753475

3476-
static int cdrom_sysctl_info(struct ctl_table *ctl, int write,
3476+
static int cdrom_sysctl_info(const struct ctl_table *ctl, int write,
34773477
void *buffer, size_t *lenp, loff_t *ppos)
34783478
{
34793479
int pos;
@@ -3586,7 +3586,7 @@ static void cdrom_update_settings(void)
35863586
mutex_unlock(&cdrom_mutex);
35873587
}
35883588

3589-
static int cdrom_sysctl_handler(struct ctl_table *ctl, int write,
3589+
static int cdrom_sysctl_handler(const struct ctl_table *ctl, int write,
35903590
void *buffer, size_t *lenp, loff_t *ppos)
35913591
{
35923592
int ret;

drivers/char/random.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ static u8 sysctl_bootid[UUID_SIZE];
16201620
* UUID. The difference is in whether table->data is NULL; if it is,
16211621
* then a new UUID is generated and returned to the user.
16221622
*/
1623-
static int proc_do_uuid(struct ctl_table *table, int write, void *buf,
1623+
static int proc_do_uuid(const struct ctl_table *table, int write, void *buf,
16241624
size_t *lenp, loff_t *ppos)
16251625
{
16261626
u8 tmp_uuid[UUID_SIZE], *uuid;
@@ -1651,7 +1651,7 @@ static int proc_do_uuid(struct ctl_table *table, int write, void *buf,
16511651
}
16521652

16531653
/* The same as proc_dointvec, but writes don't change anything. */
1654-
static int proc_do_rointvec(struct ctl_table *table, int write, void *buf,
1654+
static int proc_do_rointvec(const struct ctl_table *table, int write, void *buf,
16551655
size_t *lenp, loff_t *ppos)
16561656
{
16571657
return write ? 0 : proc_dointvec(table, 0, buf, lenp, ppos);

drivers/macintosh/mac_hid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void mac_hid_stop_emulation(void)
183183
mac_hid_destroy_emumouse();
184184
}
185185

186-
static int mac_hid_toggle_emumouse(struct ctl_table *table, int write,
186+
static int mac_hid_toggle_emumouse(const struct ctl_table *table, int write,
187187
void *buffer, size_t *lenp, loff_t *ppos)
188188
{
189189
int *valp = table->data;

0 commit comments

Comments
 (0)