Skip to content

Commit 32fe915

Browse files
t-8chJoelgranados
authored andcommitted
sysctl: constify ctl_table arguments of utility function
In a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helper. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent 4154342 commit 32fe915

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

include/linux/sysctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
237237

238238
void do_sysctl_args(void);
239239
bool sysctl_is_alias(char *param);
240-
int do_proc_douintvec(struct ctl_table *table, int write,
240+
int do_proc_douintvec(const struct ctl_table *table, int write,
241241
void *buffer, size_t *lenp, loff_t *ppos,
242242
int (*conv)(unsigned long *lvalp,
243243
unsigned int *valp,

kernel/sysctl.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static int _proc_do_string(char *data, int maxlen, int write,
205205
return 0;
206206
}
207207

208-
static void warn_sysctl_write(struct ctl_table *table)
208+
static void warn_sysctl_write(const struct ctl_table *table)
209209
{
210210
pr_warn_once("%s wrote to %s when file position was not 0!\n"
211211
"This will not be supported in the future. To silence this\n"
@@ -223,7 +223,7 @@ static void warn_sysctl_write(struct ctl_table *table)
223223
* handlers can ignore the return value.
224224
*/
225225
static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
226-
struct ctl_table *table)
226+
const struct ctl_table *table)
227227
{
228228
if (!*ppos)
229229
return false;
@@ -468,7 +468,7 @@ static int do_proc_douintvec_conv(unsigned long *lvalp,
468468

469469
static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
470470

471-
static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
471+
static int __do_proc_dointvec(void *tbl_data, const struct ctl_table *table,
472472
int write, void *buffer,
473473
size_t *lenp, loff_t *ppos,
474474
int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
@@ -541,7 +541,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
541541
return err;
542542
}
543543

544-
static int do_proc_dointvec(struct ctl_table *table, int write,
544+
static int do_proc_dointvec(const struct ctl_table *table, int write,
545545
void *buffer, size_t *lenp, loff_t *ppos,
546546
int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
547547
int write, void *data),
@@ -552,7 +552,7 @@ static int do_proc_dointvec(struct ctl_table *table, int write,
552552
}
553553

554554
static int do_proc_douintvec_w(unsigned int *tbl_data,
555-
struct ctl_table *table,
555+
const struct ctl_table *table,
556556
void *buffer,
557557
size_t *lenp, loff_t *ppos,
558558
int (*conv)(unsigned long *lvalp,
@@ -639,7 +639,7 @@ static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
639639
return err;
640640
}
641641

642-
static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
642+
static int __do_proc_douintvec(void *tbl_data, const struct ctl_table *table,
643643
int write, void *buffer,
644644
size_t *lenp, loff_t *ppos,
645645
int (*conv)(unsigned long *lvalp,
@@ -675,7 +675,7 @@ static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
675675
return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
676676
}
677677

678-
int do_proc_douintvec(struct ctl_table *table, int write,
678+
int do_proc_douintvec(const struct ctl_table *table, int write,
679679
void *buffer, size_t *lenp, loff_t *ppos,
680680
int (*conv)(unsigned long *lvalp,
681681
unsigned int *valp,
@@ -1017,8 +1017,9 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
10171017
}
10181018
#endif
10191019

1020-
static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1021-
int write, void *buffer, size_t *lenp, loff_t *ppos,
1020+
static int __do_proc_doulongvec_minmax(void *data,
1021+
const struct ctl_table *table, int write,
1022+
void *buffer, size_t *lenp, loff_t *ppos,
10221023
unsigned long convmul, unsigned long convdiv)
10231024
{
10241025
unsigned long *i, *min, *max;
@@ -1090,7 +1091,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
10901091
return err;
10911092
}
10921093

1093-
static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1094+
static int do_proc_doulongvec_minmax(const struct ctl_table *table, int write,
10941095
void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
10951096
unsigned long convdiv)
10961097
{

0 commit comments

Comments
 (0)