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 kernel/sysctl.c (1 of 93 files). Show all

Unified · Split

kernel/sysctl.c+32−32
@@ -256,7 +256,7 @@ static bool proc_first_pos_non_zero_ignore(loff_t *ppos, · 255 unmodified lines
256256 *
257257 * Returns 0 on success.
258258 */
259−int proc_dostring(struct ctl_table *table, int write,
259+int proc_dostring(const struct ctl_table *table, int write,
260260 void *buffer, size_t *lenp, loff_t *ppos)
261261 {
262262 if (write)
@@ -702,7 +702,7 @@ int do_proc_douintvec(const struct ctl_table *table, int write, · 439 unmodified lines
702702 *
703703 * Returns 0 on success.
704704 */
705−int proc_dobool(struct ctl_table *table, int write, void *buffer,
705+int proc_dobool(const struct ctl_table *table, int write, void *buffer,
706706 size_t *lenp, loff_t *ppos)
707707 {
708708 struct ctl_table tmp;
@@ -739,7 +739,7 @@ int proc_dobool(struct ctl_table *table, int write, void *buffer, · 30 unmodified lines
739739 *
740740 * Returns 0 on success.
741741 */
742−int proc_dointvec(struct ctl_table *table, int write, void *buffer,
742+int proc_dointvec(const struct ctl_table *table, int write, void *buffer,
743743 size_t *lenp, loff_t *ppos)
744744 {
745745 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
@@ -758,7 +758,7 @@ int proc_dointvec(struct ctl_table *table, int write, void *buffer, · 12 unmodified lines
758758 *
759759 * Returns 0 on success.
760760 */
761−int proc_douintvec(struct ctl_table *table, int write, void *buffer,
761+int proc_douintvec(const struct ctl_table *table, int write, void *buffer,
762762 size_t *lenp, loff_t *ppos)
763763 {
764764 return do_proc_douintvec(table, write, buffer, lenp, ppos,
@@ -769,7 +769,7 @@ int proc_douintvec(struct ctl_table *table, int write, void *buffer, · 4 unmodified lines
769769 * Taint values can only be increased
770770 * This means we can safely use a temporary.
771771 */
772−static int proc_taint(struct ctl_table *table, int write,
772+static int proc_taint(const struct ctl_table *table, int write,
773773 void *buffer, size_t *lenp, loff_t *ppos)
774774 {
775775 struct ctl_table t;
@@ -864,7 +864,7 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, · 88 unmodified lines
864864 *
865865 * Returns 0 on success or -EINVAL on write when the range check fails.
866866 */
867−int proc_dointvec_minmax(struct ctl_table *table, int write,
867+int proc_dointvec_minmax(const struct ctl_table *table, int write,
868868 void *buffer, size_t *lenp, loff_t *ppos)
869869 {
870870 struct do_proc_dointvec_minmax_conv_param param = {
@@ -933,7 +933,7 @@ static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, · 62 unmodified lines
933933 *
934934 * Returns 0 on success or -ERANGE on write when the range check fails.
935935 */
936−int proc_douintvec_minmax(struct ctl_table *table, int write,
936+int proc_douintvec_minmax(const struct ctl_table *table, int write,
937937 void *buffer, size_t *lenp, loff_t *ppos)
938938 {
939939 struct do_proc_douintvec_minmax_conv_param param = {
@@ -961,7 +961,7 @@ int proc_douintvec_minmax(struct ctl_table *table, int write, · 21 unmodified lines
961961 *
962962 * Returns 0 on success or an error on write when the range check fails.
963963 */
964−int proc_dou8vec_minmax(struct ctl_table *table, int write,
964+int proc_dou8vec_minmax(const struct ctl_table *table, int write,
965965 void *buffer, size_t *lenp, loff_t *ppos)
966966 {
967967 struct ctl_table tmp;
@@ -998,7 +998,7 @@ int proc_dou8vec_minmax(struct ctl_table *table, int write, · 30 unmodified lines
998998 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
999999
10001000 #ifdef CONFIG_MAGIC_SYSRQ
1001−static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1001+static int sysrq_sysctl_handler(const struct ctl_table *table, int write,
10021002 void *buffer, size_t *lenp, loff_t *ppos)
10031003 {
10041004 int tmp, ret;
@@ -1115,7 +1115,7 @@ static int do_proc_doulongvec_minmax(const struct ctl_table *table, int write, · 110 unmodified lines
11151115 *
11161116 * Returns 0 on success.
11171117 */
1118−int proc_doulongvec_minmax(struct ctl_table *table, int write,
1118+int proc_doulongvec_minmax(const struct ctl_table *table, int write,
11191119 void *buffer, size_t *lenp, loff_t *ppos)
11201120 {
11211121 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
@@ -1138,7 +1138,7 @@ int proc_doulongvec_minmax(struct ctl_table *table, int write, · 16 unmodified lines
11381138 *
11391139 * Returns 0 on success.
11401140 */
1141−int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1141+int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int write,
11421142 void *buffer, size_t *lenp, loff_t *ppos)
11431143 {
11441144 return do_proc_doulongvec_minmax(table, write, buffer,
@@ -1259,14 +1259,14 @@ static int do_proc_dointvec_ms_jiffies_minmax_conv(bool *negp, unsigned long *lv · 114 unmodified lines
12591259 *
12601260 * Returns 0 on success.
12611261 */
1262−int proc_dointvec_jiffies(struct ctl_table *table, int write,
1262+int proc_dointvec_jiffies(const struct ctl_table *table, int write,
12631263 void *buffer, size_t *lenp, loff_t *ppos)
12641264 {
12651265 return do_proc_dointvec(table,write,buffer,lenp,ppos,
12661266 do_proc_dointvec_jiffies_conv,NULL);
12671267 }
12681268
1269−int proc_dointvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1269+int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int write,
12701270 void *buffer, size_t *lenp, loff_t *ppos)
12711271 {
12721272 struct do_proc_dointvec_minmax_conv_param param = {
@@ -1292,7 +1292,7 @@ int proc_dointvec_ms_jiffies_minmax(struct ctl_table *table, int write, · 19 unmodified lines
12921292 *
12931293 * Returns 0 on success.
12941294 */
1295−int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1295+int proc_dointvec_userhz_jiffies(const struct ctl_table *table, int write,
12961296 void *buffer, size_t *lenp, loff_t *ppos)
12971297 {
12981298 return do_proc_dointvec(table, write, buffer, lenp, ppos,
@@ -1315,14 +1315,14 @@ int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, · 16 unmodified lines
13151315 *
13161316 * Returns 0 on success.
13171317 */
1318−int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1318+int proc_dointvec_ms_jiffies(const struct ctl_table *table, int write, void *buffer,
13191319 size_t *lenp, loff_t *ppos)
13201320 {
13211321 return do_proc_dointvec(table, write, buffer, lenp, ppos,
13221322 do_proc_dointvec_ms_jiffies_conv, NULL);
13231323 }
13241324
1325−static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1325+static int proc_do_cad_pid(const struct ctl_table *table, int write, void *buffer,
13261326 size_t *lenp, loff_t *ppos)
13271327 {
13281328 struct pid *new_pid;
@@ -1361,7 +1361,7 @@ static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer, · 32 unmodified lines
13611361 *
13621362 * Returns 0 on success.
13631363 */
1364−int proc_do_large_bitmap(struct ctl_table *table, int write,
1364+int proc_do_large_bitmap(const struct ctl_table *table, int write,
13651365 void *buffer, size_t *lenp, loff_t *ppos)
13661366 {
13671367 int err = 0;
@@ -1493,85 +1493,85 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, · 125 unmodified lines
14931493
14941494 #else /* CONFIG_PROC_SYSCTL */
14951495
1496−int proc_dostring(struct ctl_table *table, int write,
1496+int proc_dostring(const struct ctl_table *table, int write,
14971497 void *buffer, size_t *lenp, loff_t *ppos)
14981498 {
14991499 return -ENOSYS;
15001500 }
15011501
1502−int proc_dobool(struct ctl_table *table, int write,
1502+int proc_dobool(const struct ctl_table *table, int write,
15031503 void *buffer, size_t *lenp, loff_t *ppos)
15041504 {
15051505 return -ENOSYS;
15061506 }
15071507
1508−int proc_dointvec(struct ctl_table *table, int write,
1508+int proc_dointvec(const struct ctl_table *table, int write,
15091509 void *buffer, size_t *lenp, loff_t *ppos)
15101510 {
15111511 return -ENOSYS;
15121512 }
15131513
1514−int proc_douintvec(struct ctl_table *table, int write,
1514+int proc_douintvec(const struct ctl_table *table, int write,
15151515 void *buffer, size_t *lenp, loff_t *ppos)
15161516 {
15171517 return -ENOSYS;
15181518 }
15191519
1520−int proc_dointvec_minmax(struct ctl_table *table, int write,
1520+int proc_dointvec_minmax(const struct ctl_table *table, int write,
15211521 void *buffer, size_t *lenp, loff_t *ppos)
15221522 {
15231523 return -ENOSYS;
15241524 }
15251525
1526−int proc_douintvec_minmax(struct ctl_table *table, int write,
1526+int proc_douintvec_minmax(const struct ctl_table *table, int write,
15271527 void *buffer, size_t *lenp, loff_t *ppos)
15281528 {
15291529 return -ENOSYS;
15301530 }
15311531
1532−int proc_dou8vec_minmax(struct ctl_table *table, int write,
1532+int proc_dou8vec_minmax(const struct ctl_table *table, int write,
15331533 void *buffer, size_t *lenp, loff_t *ppos)
15341534 {
15351535 return -ENOSYS;
15361536 }
15371537
1538−int proc_dointvec_jiffies(struct ctl_table *table, int write,
1538+int proc_dointvec_jiffies(const struct ctl_table *table, int write,
15391539 void *buffer, size_t *lenp, loff_t *ppos)
15401540 {
15411541 return -ENOSYS;
15421542 }
15431543
1544−int proc_dointvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1544+int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int write,
15451545 void *buffer, size_t *lenp, loff_t *ppos)
15461546 {
15471547 return -ENOSYS;
15481548 }
15491549
1550−int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1550+int proc_dointvec_userhz_jiffies(const struct ctl_table *table, int write,
15511551 void *buffer, size_t *lenp, loff_t *ppos)
15521552 {
15531553 return -ENOSYS;
15541554 }
15551555
1556−int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1556+int proc_dointvec_ms_jiffies(const struct ctl_table *table, int write,
15571557 void *buffer, size_t *lenp, loff_t *ppos)
15581558 {
15591559 return -ENOSYS;
15601560 }
15611561
1562−int proc_doulongvec_minmax(struct ctl_table *table, int write,
1562+int proc_doulongvec_minmax(const struct ctl_table *table, int write,
15631563 void *buffer, size_t *lenp, loff_t *ppos)
15641564 {
15651565 return -ENOSYS;
15661566 }
15671567
1568−int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1568+int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int write,
15691569 void *buffer, size_t *lenp, loff_t *ppos)
15701570 {
15711571 return -ENOSYS;
15721572 }
15731573
1574−int proc_do_large_bitmap(struct ctl_table *table, int write,
1574+int proc_do_large_bitmap(const struct ctl_table *table, int write,
15751575 void *buffer, size_t *lenp, loff_t *ppos)
15761576 {
15771577 return -ENOSYS;
@@ -1580,7 +1580,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, · 2 unmodified lines
15801580 #endif /* CONFIG_PROC_SYSCTL */
15811581
15821582 #if defined(CONFIG_SYSCTL)
1583−int proc_do_static_key(struct ctl_table *table, int write,
1583+int proc_do_static_key(const struct ctl_table *table, int write,
15841584 void *buffer, size_t *lenp, loff_t *ppos)
15851585 {
15861586 struct static_key *key = (struct static_key *)table->data;