mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
networking: Update to register_net_sysctl_sz
Move from register_net_sysctl to register_net_sysctl_sz for all the
networking related files. Do this while making sure to mirror the NULL
assignments with a table_size of zero for the unprivileged users.
We need to move to the new function in preparation for when we change
SIZE_MAX to ARRAY_SIZE() in the register_net_sysctl macro. Failing to do
so would erroneously allow ARRAY_SIZE() to be called on a pointer. We
hold off the SIZE_MAX to ARRAY_SIZE change until we have migrated all
the relevant net sysctl registering functions to register_net_sysctl_sz
in subsequent commits.
An additional size function was added to the following files in order to
calculate the size of an array that is defined in another file:
include/net/ipv6.h
net/ipv6/icmp.c
net/ipv6/route.c
net/ipv6/sysctl_net_ipv6.c
Signed-off-by: Joel Granados <j.granados@samsung.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
committed by
Luis Chamberlain
parent
385a5dc9e5
commit
c899710fe7
@@ -360,6 +360,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
|
||||
struct ctl_table_header *hdr;
|
||||
struct netns_ieee802154_lowpan *ieee802154_lowpan =
|
||||
net_ieee802154_lowpan(net);
|
||||
size_t table_size = ARRAY_SIZE(lowpan_frags_ns_ctl_table);
|
||||
|
||||
table = lowpan_frags_ns_ctl_table;
|
||||
if (!net_eq(net, &init_net)) {
|
||||
@@ -369,8 +370,10 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
|
||||
goto err_alloc;
|
||||
|
||||
/* Don't export sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns)
|
||||
if (net->user_ns != &init_user_ns) {
|
||||
table[0].procname = NULL;
|
||||
table_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
table[0].data = &ieee802154_lowpan->fqdir->high_thresh;
|
||||
@@ -379,7 +382,8 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
|
||||
table[1].extra2 = &ieee802154_lowpan->fqdir->high_thresh;
|
||||
table[2].data = &ieee802154_lowpan->fqdir->timeout;
|
||||
|
||||
hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table);
|
||||
hdr = register_net_sysctl_sz(net, "net/ieee802154/6lowpan", table,
|
||||
table_size);
|
||||
if (hdr == NULL)
|
||||
goto err_reg;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user