Skip to content

Commit 93bda33

Browse files
committed
Merge branch 'net-constify-ctl_table-arguments-of-utility-functions'
Thomas Weißschuh says: ==================== net: constify ctl_table arguments of utility functions The sysctl core is preparing to only expose instances of struct ctl_table as "const". This will also affect the ctl_table argument of sysctl handlers. As the function prototype of all sysctl handlers throughout the tree needs to stay consistent that change will be done in one commit. To reduce the size of that final commit, switch utility functions which are not bound by "typedef proc_handler" to "const struct ctl_table". No functional change. This patch(set) is meant to be applied through your subsystem tree. Or at your preference through the sysctl tree. Motivation ========== Moving structures containing function pointers into unmodifiable .rodata prevents attackers or bugs from corrupting and diverting those pointers. Also the "struct ctl_table" exposed by the sysctl core were never meant to be mutated by users. For this goal changes to both the sysctl core and "const" qualifiers for various sysctl APIs are necessary. ==================== Link: https://lore.kernel.org/r/20240527-sysctl-const-handler-net-v1-0-16523767d0b2@weissschuh.net Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 982300c + 0a9f788 commit 93bda33

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

net/core/neighbour.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,7 @@ static void neigh_copy_dflt_parms(struct net *net, struct neigh_parms *p,
35783578
rcu_read_unlock();
35793579
}
35803580

3581-
static void neigh_proc_update(struct ctl_table *ctl, int write)
3581+
static void neigh_proc_update(const struct ctl_table *ctl, int write)
35823582
{
35833583
struct net_device *dev = ctl->extra1;
35843584
struct neigh_parms *p = ctl->extra2;

net/ipv4/sysctl_net_ipv4.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ static int ipv4_privileged_ports(struct ctl_table *table, int write,
130130
return ret;
131131
}
132132

133-
static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low, kgid_t *high)
133+
static void inet_get_ping_group_range_table(const struct ctl_table *table,
134+
kgid_t *low, kgid_t *high)
134135
{
135136
kgid_t *data = table->data;
136137
struct net *net =
@@ -145,7 +146,8 @@ static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low
145146
}
146147

147148
/* Update system visible IP port range */
148-
static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t high)
149+
static void set_ping_group_range(const struct ctl_table *table,
150+
kgid_t low, kgid_t high)
149151
{
150152
kgid_t *data = table->data;
151153
struct net *net =

net/ipv6/addrconf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ static void addrconf_forward_change(struct net *net, __s32 newf)
863863
}
864864
}
865865

866-
static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)
866+
static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, int newf)
867867
{
868868
struct net *net;
869869
int old;
@@ -931,7 +931,7 @@ static void addrconf_linkdown_change(struct net *net, __s32 newf)
931931
}
932932
}
933933

934-
static int addrconf_fixup_linkdown(struct ctl_table *table, int *p, int newf)
934+
static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int newf)
935935
{
936936
struct net *net;
937937
int old;
@@ -6378,7 +6378,7 @@ static void addrconf_disable_change(struct net *net, __s32 newf)
63786378
}
63796379
}
63806380

6381-
static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
6381+
static int addrconf_disable_ipv6(const struct ctl_table *table, int *p, int newf)
63826382
{
63836383
struct net *net = (struct net *)table->extra2;
63846384
int old;
@@ -6669,7 +6669,7 @@ void addrconf_disable_policy_idev(struct inet6_dev *idev, int val)
66696669
}
66706670

66716671
static
6672-
int addrconf_disable_policy(struct ctl_table *ctl, int *valp, int val)
6672+
int addrconf_disable_policy(const struct ctl_table *ctl, int *valp, int val)
66736673
{
66746674
struct net *net = (struct net *)ctl->extra2;
66756675
struct inet6_dev *idev;

net/ipv6/ndisc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ static struct notifier_block ndisc_netdev_notifier = {
19361936
};
19371937

19381938
#ifdef CONFIG_SYSCTL
1939-
static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
1939+
static void ndisc_warn_deprecated_sysctl(const struct ctl_table *ctl,
19401940
const char *func, const char *dev_name)
19411941
{
19421942
static char warncomm[TASK_COMM_LEN];

net/netfilter/ipvs/ip_vs_ctl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,8 @@ proc_do_sync_ports(struct ctl_table *table, int write,
19241924
return rc;
19251925
}
19261926

1927-
static int ipvs_proc_est_cpumask_set(struct ctl_table *table, void *buffer)
1927+
static int ipvs_proc_est_cpumask_set(const struct ctl_table *table,
1928+
void *buffer)
19281929
{
19291930
struct netns_ipvs *ipvs = table->extra2;
19301931
cpumask_var_t *valp = table->data;
@@ -1962,8 +1963,8 @@ static int ipvs_proc_est_cpumask_set(struct ctl_table *table, void *buffer)
19621963
return ret;
19631964
}
19641965

1965-
static int ipvs_proc_est_cpumask_get(struct ctl_table *table, void *buffer,
1966-
size_t size)
1966+
static int ipvs_proc_est_cpumask_get(const struct ctl_table *table,
1967+
void *buffer, size_t size)
19671968
{
19681969
struct netns_ipvs *ipvs = table->extra2;
19691970
cpumask_var_t *valp = table->data;

0 commit comments

Comments
 (0)