Skip to content

Commit 795f90c

Browse files
t-8chJoelgranados
authored andcommitted
sysctl: treewide: constify argument ctl_table_root::permissions(table)
The permissions callback should not modify the ctl_table. Enforce this expectation via the typesystem. This is a step to put "struct ctl_table" into .rodata throughout the kernel. The patch was created with the following coccinelle script: @@ identifier func, head, ctl; @@ int func( struct ctl_table_header *head, - struct ctl_table *ctl) + const struct ctl_table *ctl) { ... } (insert_entry() from fs/proc/proc_sysctl.c is a false-positive) No additional occurrences of '.permissions =' were found after a tree-wide search for places missed by the conccinelle script. Reviewed-by: Joel Granados <j.granados@samsung.com> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Joel Granados <j.granados@samsung.com>
1 parent 520713a commit 795f90c

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

include/linux/sysctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct ctl_table_root {
206206
struct ctl_table_set *(*lookup)(struct ctl_table_root *root);
207207
void (*set_ownership)(struct ctl_table_header *head,
208208
kuid_t *uid, kgid_t *gid);
209-
int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
209+
int (*permissions)(struct ctl_table_header *head, const struct ctl_table *table);
210210
};
211211

212212
#define register_sysctl(path, table) \

ipc/ipc_sysctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static void ipc_set_ownership(struct ctl_table_header *head,
204204
*gid = gid_valid(ns_root_gid) ? ns_root_gid : GLOBAL_ROOT_GID;
205205
}
206206

207-
static int ipc_permissions(struct ctl_table_header *head, struct ctl_table *table)
207+
static int ipc_permissions(struct ctl_table_header *head, const struct ctl_table *table)
208208
{
209209
int mode = table->mode;
210210

ipc/mq_sysctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void mq_set_ownership(struct ctl_table_header *head,
9090
*gid = gid_valid(ns_root_gid) ? ns_root_gid : GLOBAL_ROOT_GID;
9191
}
9292

93-
static int mq_permissions(struct ctl_table_header *head, struct ctl_table *table)
93+
static int mq_permissions(struct ctl_table_header *head, const struct ctl_table *table)
9494
{
9595
int mode = table->mode;
9696
kuid_t ns_root_uid;

kernel/ucount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int set_is_seen(struct ctl_table_set *set)
3838
}
3939

4040
static int set_permissions(struct ctl_table_header *head,
41-
struct ctl_table *table)
41+
const struct ctl_table *table)
4242
{
4343
struct user_namespace *user_ns =
4444
container_of(head->set, struct user_namespace, set);

net/sysctl_net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int is_seen(struct ctl_table_set *set)
4040

4141
/* Return standard mode bits for table entry. */
4242
static int net_ctl_permissions(struct ctl_table_header *head,
43-
struct ctl_table *table)
43+
const struct ctl_table *table)
4444
{
4545
struct net *net = container_of(head->set, struct net, sysctls);
4646

0 commit comments

Comments
 (0)