Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-sysctl-sentinel'

Joel Granados says:

====================
sysctl: Remove sentinel elements from networking

What?
These commits remove the sentinel element (last empty element) from the
sysctl arrays of all the files under the "net/" directory that register
a sysctl array. The merging of the preparation patches [4] to mainline
allows us to just remove sentinel elements without changing behavior.
This is safe because the sysctl registration code (register_sysctl() and
friends) use the array size in addition to checking for a sentinel [1].

Why?
By removing the sysctl sentinel elements we avoid kernel bloat as
ctl_table arrays get moved out of kernel/sysctl.c into their own
respective subsystems. This move was started long ago to avoid merge
conflicts; the sentinel removal bit came after Mathew Wilcox suggested
it to avoid bloating the kernel by one element as arrays moved out. This
patchset will reduce the overall build time size of the kernel and run
time memory bloat by about ~64 bytes per declared ctl_table array (more
info here [5]).

When are we done?
There are 4 patchest (25 commits [2]) that are still outstanding to
completely remove the sentinels: files under "net/" (this patchset),
files under "kernel/" dir, misc dirs (files under mm/ security/ and
others) and the final set that removes the unneeded check for ->procname
== NULL.

Testing:
* Ran sysctl selftests (./tools/testing/selftests/sysctl/sysctl.sh)
* Ran this through 0-day with no errors or warnings

Savings in vmlinux:
A total of 64 bytes per sentinel is saved after removal; I measured in
x86_64 to give an idea of the aggregated savings. The actual savings
will depend on individual kernel configuration.
* bloat-o-meter
- The "yesall" config saves 3976 bytes (bloat-o-meter output [6])
- A reduced config [3] saves 1263 bytes (bloat-o-meter output [7])

Savings in allocated memory:
None in this set but will occur when the superfluous allocations are
removed from proc_sysctl.c. I include it here for context. The
estimated savings during boot for config [3] are 6272 bytes. See [8]
for how to measure it.

Comments/feedback greatly appreciated

Changes in v6:
- Rebased onto net-next/main.
- Besides re-running my cocci scripts, I ran a new find script [9].
Found 0 hits in net/
- Moved "i" variable declaraction out of for() in sysctl_core_net_init
- Removed forgotten sentinel in mpls_table
- Removed CONFIG_AX25_DAMA_SLAVE guard from net/ax25/ax25_ds_timer.c. It
is not needed because that file is compiled only when
CONFIG_AX25_DAMA_SLAVE is set.
- When traversing smc_table, stop on ARRAY_SIZE instead of ARRAY_SIZE-1.
- Link to v5: https://lore.kernel.org/r/20240426-jag-sysctl_remset_net-v5-0-e3b12f6111a6@samsung.com

Changes in v5:
- Added net files with additional variable to my test .config so the
typo can be caught next time.
- Fixed typo tabel_size -> table_size
- Link to v4: https://lore.kernel.org/r/20240425-jag-sysctl_remset_net-v4-0-9e82f985777d@samsung.com

Changes in v4:
- Keep reverse xmas tree order when introducing new variables
- Use a table_size variable to keep the value of ARRAY_SIZE
- Separated the original "networking: Remove the now superfluous
sentinel elements from ctl_table arra" into smaller commits to ease
review
- Merged x.25 and ax.25 commits together.
- Removed any SOB from the commits that were changed
- Link to v3: https://lore.kernel.org/r/20240412-jag-sysctl_remset_net-v3-0-11187d13c211@samsung.com

Changes in v3:
- Reworkded ax.25
- Added a BUILD_BUG_ON for the ax.25 commit
- Added a CONFIG_AX25_DAMA_SLAVE guard where needed
- Link to v2: https://lore.kernel.org/r/20240328-jag-sysctl_remset_net-v2-0-52c9fad9a1af@samsung.com

Changes in v2:
- Rebased to v6.9-rc1
- Removed unneeded comment from sysctl_net_ax25.c
- Link to v1: https://lore.kernel.org/r/20240314-jag-sysctl_remset_net-v1-0-aa26b44d29d9@samsung.com
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+48 -119
+2
include/net/ax25.h
··· 139 139 AX25_VALUES_N2, /* Default N2 value */ 140 140 AX25_VALUES_PACLEN, /* AX.25 MTU */ 141 141 AX25_VALUES_PROTOCOL, /* Std AX.25, DAMA Slave, DAMA Master */ 142 + #ifdef CONFIG_AX25_DAMA_SLAVE 142 143 AX25_VALUES_DS_TIMEOUT, /* DAMA Slave timeout */ 144 + #endif 143 145 AX25_MAX_VALUES /* THIS MUST REMAIN THE LAST ENTRY OF THIS LIST */ 144 146 }; 145 147
-1
net/appletalk/sysctl_net_atalk.c
··· 40 40 .mode = 0644, 41 41 .proc_handler = proc_dointvec_jiffies, 42 42 }, 43 - { }, 44 43 }; 45 44 46 45 static struct ctl_table_header *atalk_table_header;
+3
net/ax25/ax25_dev.c
··· 78 78 ax25_dev->values[AX25_VALUES_N2] = AX25_DEF_N2; 79 79 ax25_dev->values[AX25_VALUES_PACLEN] = AX25_DEF_PACLEN; 80 80 ax25_dev->values[AX25_VALUES_PROTOCOL] = AX25_DEF_PROTOCOL; 81 + 82 + #ifdef CONFIG_AX25_DAMA_SLAVE 81 83 ax25_dev->values[AX25_VALUES_DS_TIMEOUT]= AX25_DEF_DS_TIMEOUT; 84 + #endif 82 85 83 86 #if defined(CONFIG_AX25_DAMA_SLAVE) || defined(CONFIG_AX25_DAMA_MASTER) 84 87 ax25_ds_setup_timer(ax25_dev);
+1
net/ax25/ax25_ds_timer.c
··· 55 55 ax25_dev->dama.slave_timeout = 56 56 msecs_to_jiffies(ax25_dev->values[AX25_VALUES_DS_TIMEOUT]) / 10; 57 57 mod_timer(&ax25_dev->dama.slave_timer, jiffies + HZ); 58 + return; 58 59 } 59 60 60 61 /*
+1 -2
net/ax25/sysctl_net_ax25.c
··· 141 141 .extra2 = &max_ds_timeout 142 142 }, 143 143 #endif 144 - 145 - { } /* that's all, folks! */ 146 144 }; 147 145 148 146 int ax25_register_dev_sysctl(ax25_dev *ax25_dev) ··· 153 155 if (!table) 154 156 return -ENOMEM; 155 157 158 + BUILD_BUG_ON(ARRAY_SIZE(ax25_param_table) != AX25_MAX_VALUES); 156 159 for (k = 0; k < AX25_MAX_VALUES; k++) 157 160 table[k].data = &ax25_dev->values[k]; 158 161
-1
net/bridge/br_netfilter_hooks.c
··· 1226 1226 .mode = 0644, 1227 1227 .proc_handler = brnf_sysctl_call_tables, 1228 1228 }, 1229 - { } 1230 1229 }; 1231 1230 1232 1231 static inline void br_netfilter_sysctl_default(struct brnf_net *brnf)
+1 -4
net/core/neighbour.c
··· 3733 3733 3734 3734 static struct neigh_sysctl_table { 3735 3735 struct ctl_table_header *sysctl_header; 3736 - struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1]; 3736 + struct ctl_table neigh_vars[NEIGH_VAR_MAX]; 3737 3737 } neigh_sysctl_template __read_mostly = { 3738 3738 .neigh_vars = { 3739 3739 NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(MCAST_PROBES, "mcast_solicit"), ··· 3784 3784 .extra2 = SYSCTL_INT_MAX, 3785 3785 .proc_handler = proc_dointvec_minmax, 3786 3786 }, 3787 - {}, 3788 3787 }, 3789 3788 }; 3790 3789 ··· 3811 3812 if (dev) { 3812 3813 dev_name_source = dev->name; 3813 3814 /* Terminate the table early */ 3814 - memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0, 3815 - sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL])); 3816 3815 neigh_vars_size = NEIGH_VAR_BASE_REACHABLE_TIME_MS + 1; 3817 3816 } else { 3818 3817 struct neigh_table *tbl = p->tbl;
+6 -7
net/core/sysctl_net_core.c
··· 661 661 .proc_handler = proc_dointvec_minmax, 662 662 .extra1 = SYSCTL_ZERO, 663 663 }, 664 - { } 665 664 }; 666 665 667 666 static struct ctl_table netns_core_table[] = { ··· 697 698 .extra2 = SYSCTL_ONE, 698 699 .proc_handler = proc_dou8vec_minmax, 699 700 }, 700 - { } 701 701 }; 702 702 703 703 static int __init fb_tunnels_only_for_init_net_sysctl_setup(char *str) ··· 714 716 715 717 static __net_init int sysctl_core_net_init(struct net *net) 716 718 { 717 - struct ctl_table *tbl, *tmp; 719 + size_t table_size = ARRAY_SIZE(netns_core_table); 720 + struct ctl_table *tbl; 718 721 719 722 tbl = netns_core_table; 720 723 if (!net_eq(net, &init_net)) { 724 + int i; 721 725 tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL); 722 726 if (tbl == NULL) 723 727 goto err_dup; 724 728 725 - for (tmp = tbl; tmp->procname; tmp++) 726 - tmp->data += (char *)net - (char *)&init_net; 729 + for (i = 0; i < table_size; ++i) 730 + tbl[i].data += (char *)net - (char *)&init_net; 727 731 } 728 732 729 - net->core.sysctl_hdr = register_net_sysctl_sz(net, "net/core", tbl, 730 - ARRAY_SIZE(netns_core_table)); 733 + net->core.sysctl_hdr = register_net_sysctl_sz(net, "net/core", tbl, table_size); 731 734 if (net->core.sysctl_hdr == NULL) 732 735 goto err_reg; 733 736
-2
net/dccp/sysctl.c
··· 90 90 .mode = 0644, 91 91 .proc_handler = proc_dointvec_ms_jiffies, 92 92 }, 93 - 94 - { } 95 93 }; 96 94 97 95 static struct ctl_table_header *dccp_table_header;
+1 -5
net/ieee802154/6lowpan/reassembly.c
··· 338 338 .mode = 0644, 339 339 .proc_handler = proc_dointvec_jiffies, 340 340 }, 341 - { } 342 341 }; 343 342 344 343 /* secret interval has been deprecated */ ··· 350 351 .mode = 0644, 351 352 .proc_handler = proc_dointvec_jiffies, 352 353 }, 353 - { } 354 354 }; 355 355 356 356 static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) ··· 368 370 goto err_alloc; 369 371 370 372 /* Don't export sysctls to unprivileged users */ 371 - if (net->user_ns != &init_user_ns) { 372 - table[0].procname = NULL; 373 + if (net->user_ns != &init_user_ns) 373 374 table_size = 0; 374 - } 375 375 } 376 376 377 377 table[0].data = &ieee802154_lowpan->fqdir->high_thresh;
+2 -3
net/ipv4/devinet.c
··· 2520 2520 2521 2521 static struct devinet_sysctl_table { 2522 2522 struct ctl_table_header *sysctl_header; 2523 - struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX]; 2523 + struct ctl_table devinet_vars[IPV4_DEVCONF_MAX]; 2524 2524 } devinet_sysctl = { 2525 2525 .devinet_vars = { 2526 2526 DEVINET_SYSCTL_COMPLEX_ENTRY(FORWARDING, "forwarding", ··· 2583 2583 if (!t) 2584 2584 goto out; 2585 2585 2586 - for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) { 2586 + for (i = 0; i < ARRAY_SIZE(t->devinet_vars); i++) { 2587 2587 t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf; 2588 2588 t->devinet_vars[i].extra1 = p; 2589 2589 t->devinet_vars[i].extra2 = net; ··· 2657 2657 .extra1 = &ipv4_devconf, 2658 2658 .extra2 = &init_net, 2659 2659 }, 2660 - { }, 2661 2660 }; 2662 2661 #endif 2663 2662
-2
net/ipv4/ip_fragment.c
··· 580 580 .proc_handler = proc_dointvec_minmax, 581 581 .extra1 = &dist_min, 582 582 }, 583 - { } 584 583 }; 585 584 586 585 /* secret interval has been deprecated */ ··· 592 593 .mode = 0644, 593 594 .proc_handler = proc_dointvec_jiffies, 594 595 }, 595 - { } 596 596 }; 597 597 598 598 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
+2 -6
net/ipv4/route.c
··· 3496 3496 .mode = 0644, 3497 3497 .proc_handler = proc_dointvec, 3498 3498 }, 3499 - { } 3500 3499 }; 3501 3500 3502 3501 static const char ipv4_route_flush_procname[] = "flush"; ··· 3529 3530 .mode = 0644, 3530 3531 .proc_handler = proc_dointvec, 3531 3532 }, 3532 - { }, 3533 3533 }; 3534 3534 3535 3535 static __net_init int sysctl_route_net_init(struct net *net) ··· 3546 3548 3547 3549 /* Don't export non-whitelisted sysctls to unprivileged users */ 3548 3550 if (net->user_ns != &init_user_ns) { 3549 - if (tbl[0].procname != ipv4_route_flush_procname) { 3550 - tbl[0].procname = NULL; 3551 + if (tbl[0].procname != ipv4_route_flush_procname) 3551 3552 table_size = 0; 3552 - } 3553 3553 } 3554 3554 3555 3555 /* Update the variables to point into the current struct net 3556 3556 * except for the first element flush 3557 3557 */ 3558 - for (i = 1; i < ARRAY_SIZE(ipv4_route_netns_table) - 1; i++) 3558 + for (i = 1; i < table_size; i++) 3559 3559 tbl[i].data += (void *)net - (void *)&init_net; 3560 3560 } 3561 3561 tbl[0].extra1 = net;
+3 -4
net/ipv4/sysctl_net_ipv4.c
··· 575 575 .extra1 = &sysctl_fib_sync_mem_min, 576 576 .extra2 = &sysctl_fib_sync_mem_max, 577 577 }, 578 - { } 579 578 }; 580 579 581 580 static struct ctl_table ipv4_net_table[] = { ··· 1501 1502 .proc_handler = proc_dou8vec_minmax, 1502 1503 .extra1 = SYSCTL_ONE, 1503 1504 }, 1504 - { } 1505 1505 }; 1506 1506 1507 1507 static __net_init int ipv4_sysctl_init_net(struct net *net) 1508 1508 { 1509 + size_t table_size = ARRAY_SIZE(ipv4_net_table); 1509 1510 struct ctl_table *table; 1510 1511 1511 1512 table = ipv4_net_table; ··· 1516 1517 if (!table) 1517 1518 goto err_alloc; 1518 1519 1519 - for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) { 1520 + for (i = 0; i < table_size; i++) { 1520 1521 if (table[i].data) { 1521 1522 /* Update the variables to point into 1522 1523 * the current struct net ··· 1532 1533 } 1533 1534 1534 1535 net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table, 1535 - ARRAY_SIZE(ipv4_net_table)); 1536 + table_size); 1536 1537 if (!net->ipv4.ipv4_hdr) 1537 1538 goto err_reg; 1538 1539
-1
net/ipv4/xfrm4_policy.c
··· 152 152 .mode = 0644, 153 153 .proc_handler = proc_dointvec, 154 154 }, 155 - { } 156 155 }; 157 156 158 157 static __net_init int xfrm4_net_sysctl_init(struct net *net)
+3 -5
net/ipv6/addrconf.c
··· 7184 7184 .extra1 = SYSCTL_ZERO, 7185 7185 .extra2 = SYSCTL_TWO, 7186 7186 }, 7187 - { 7188 - /* sentinel */ 7189 - } 7190 7187 }; 7191 7188 7192 7189 static int __addrconf_sysctl_register(struct net *net, char *dev_name, 7193 7190 struct inet6_dev *idev, struct ipv6_devconf *p) 7194 7191 { 7192 + size_t table_size = ARRAY_SIZE(addrconf_sysctl); 7195 7193 int i, ifindex; 7196 7194 struct ctl_table *table; 7197 7195 char path[sizeof("net/ipv6/conf/") + IFNAMSIZ]; ··· 7198 7200 if (!table) 7199 7201 goto out; 7200 7202 7201 - for (i = 0; table[i].data; i++) { 7203 + for (i = 0; i < table_size; i++) { 7202 7204 table[i].data += (char *)p - (char *)&ipv6_devconf; 7203 7205 /* If one of these is already set, then it is not safe to 7204 7206 * overwrite either of them: this makes proc_dointvec_minmax ··· 7213 7215 snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name); 7214 7216 7215 7217 p->sysctl_header = register_net_sysctl_sz(net, path, table, 7216 - ARRAY_SIZE(addrconf_sysctl)); 7218 + table_size); 7217 7219 if (!p->sysctl_header) 7218 7220 goto free; 7219 7221
-1
net/ipv6/icmp.c
··· 1206 1206 .extra1 = SYSCTL_ZERO, 1207 1207 .extra2 = SYSCTL_ONE, 1208 1208 }, 1209 - { }, 1210 1209 }; 1211 1210 1212 1211 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
-1
net/ipv6/netfilter/nf_conntrack_reasm.c
··· 62 62 .mode = 0644, 63 63 .proc_handler = proc_doulongvec_minmax, 64 64 }, 65 - { } 66 65 }; 67 66 68 67 static int nf_ct_frag6_sysctl_register(struct net *net)
-2
net/ipv6/reassembly.c
··· 436 436 .mode = 0644, 437 437 .proc_handler = proc_dointvec_jiffies, 438 438 }, 439 - { } 440 439 }; 441 440 442 441 /* secret interval has been deprecated */ ··· 448 449 .mode = 0644, 449 450 .proc_handler = proc_dointvec_jiffies, 450 451 }, 451 - { } 452 452 }; 453 453 454 454 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
-5
net/ipv6/route.c
··· 6428 6428 .extra1 = SYSCTL_ZERO, 6429 6429 .extra2 = SYSCTL_ONE, 6430 6430 }, 6431 - { } 6432 6431 }; 6433 6432 6434 6433 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) ··· 6451 6452 table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss; 6452 6453 table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; 6453 6454 table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down; 6454 - 6455 - /* Don't export sysctls to unprivileged users */ 6456 - if (net->user_ns != &init_user_ns) 6457 - table[1].procname = NULL; 6458 6455 } 6459 6456 6460 6457 return table;
+3 -5
net/ipv6/sysctl_net_ipv6.c
··· 213 213 .proc_handler = proc_doulongvec_minmax, 214 214 .extra2 = &ioam6_id_wide_max, 215 215 }, 216 - { } 217 216 }; 218 217 219 218 static struct ctl_table ipv6_rotable[] = { ··· 247 248 .proc_handler = proc_dointvec, 248 249 }, 249 250 #endif /* CONFIG_NETLABEL */ 250 - { } 251 251 }; 252 252 253 253 static int __net_init ipv6_sysctl_net_init(struct net *net) 254 254 { 255 + size_t table_size = ARRAY_SIZE(ipv6_table_template); 255 256 struct ctl_table *ipv6_table; 256 257 struct ctl_table *ipv6_route_table; 257 258 struct ctl_table *ipv6_icmp_table; ··· 263 264 if (!ipv6_table) 264 265 goto out; 265 266 /* Update the variables to point into the current struct net */ 266 - for (i = 0; i < ARRAY_SIZE(ipv6_table_template) - 1; i++) 267 + for (i = 0; i < table_size; i++) 267 268 ipv6_table[i].data += (void *)net - (void *)&init_net; 268 269 269 270 ipv6_route_table = ipv6_route_sysctl_init(net); ··· 275 276 goto out_ipv6_route_table; 276 277 277 278 net->ipv6.sysctl.hdr = register_net_sysctl_sz(net, "net/ipv6", 278 - ipv6_table, 279 - ARRAY_SIZE(ipv6_table_template)); 279 + ipv6_table, table_size); 280 280 if (!net->ipv6.sysctl.hdr) 281 281 goto out_ipv6_icmp_table; 282 282
-1
net/ipv6/xfrm6_policy.c
··· 184 184 .mode = 0644, 185 185 .proc_handler = proc_dointvec, 186 186 }, 187 - { } 188 187 }; 189 188 190 189 static int __net_init xfrm6_net_sysctl_init(struct net *net)
+2 -6
net/llc/sysctl_net_llc.c
··· 44 44 .mode = 0644, 45 45 .proc_handler = proc_dointvec_jiffies, 46 46 }, 47 - { }, 48 - }; 49 - 50 - static struct ctl_table llc_station_table[] = { 51 - { }, 52 47 }; 53 48 54 49 static struct ctl_table_header *llc2_timeout_header; ··· 51 56 52 57 int __init llc_sysctl_init(void) 53 58 { 59 + struct ctl_table empty[1] = {}; 54 60 llc2_timeout_header = register_net_sysctl(&init_net, "net/llc/llc2/timeout", llc2_timeout_table); 55 - llc_station_header = register_net_sysctl(&init_net, "net/llc/station", llc_station_table); 61 + llc_station_header = register_net_sysctl_sz(&init_net, "net/llc/station", empty, 0); 56 62 57 63 if (!llc2_timeout_header || !llc_station_header) { 58 64 llc_sysctl_exit();
+6 -7
net/mpls/af_mpls.c
··· 1377 1377 .proc_handler = mpls_conf_proc, 1378 1378 .data = MPLS_PERDEV_SYSCTL_OFFSET(input_enabled), 1379 1379 }, 1380 - { } 1381 1380 }; 1382 1381 1383 1382 static int mpls_dev_sysctl_register(struct net_device *dev, 1384 1383 struct mpls_dev *mdev) 1385 1384 { 1386 1385 char path[sizeof("net/mpls/conf/") + IFNAMSIZ]; 1386 + size_t table_size = ARRAY_SIZE(mpls_dev_table); 1387 1387 struct net *net = dev_net(dev); 1388 1388 struct ctl_table *table; 1389 1389 int i; ··· 1395 1395 /* Table data contains only offsets relative to the base of 1396 1396 * the mdev at this point, so make them absolute. 1397 1397 */ 1398 - for (i = 0; i < ARRAY_SIZE(mpls_dev_table); i++) { 1398 + for (i = 0; i < table_size; i++) { 1399 1399 table[i].data = (char *)mdev + (uintptr_t)table[i].data; 1400 1400 table[i].extra1 = mdev; 1401 1401 table[i].extra2 = net; ··· 1403 1403 1404 1404 snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name); 1405 1405 1406 - mdev->sysctl = register_net_sysctl_sz(net, path, table, 1407 - ARRAY_SIZE(mpls_dev_table)); 1406 + mdev->sysctl = register_net_sysctl_sz(net, path, table, table_size); 1408 1407 if (!mdev->sysctl) 1409 1408 goto free; 1410 1409 ··· 2652 2653 .extra1 = SYSCTL_ONE, 2653 2654 .extra2 = &ttl_max, 2654 2655 }, 2655 - { } 2656 2656 }; 2657 2657 2658 2658 static int mpls_net_init(struct net *net) 2659 2659 { 2660 + size_t table_size = ARRAY_SIZE(mpls_table); 2660 2661 struct ctl_table *table; 2661 2662 int i; 2662 2663 ··· 2672 2673 /* Table data contains only offsets relative to the base of 2673 2674 * the mdev at this point, so make them absolute. 2674 2675 */ 2675 - for (i = 0; i < ARRAY_SIZE(mpls_table) - 1; i++) 2676 + for (i = 0; i < table_size; i++) 2676 2677 table[i].data = (char *)net + (uintptr_t)table[i].data; 2677 2678 2678 2679 net->mpls.ctl = register_net_sysctl_sz(net, "net/mpls", table, 2679 - ARRAY_SIZE(mpls_table)); 2680 + table_size); 2680 2681 if (net->mpls.ctl == NULL) { 2681 2682 kfree(table); 2682 2683 return -ENOMEM;
-1
net/mptcp/ctrl.c
··· 156 156 .mode = 0644, 157 157 .proc_handler = proc_dointvec_jiffies, 158 158 }, 159 - {} 160 159 }; 161 160 162 161 static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
+1 -4
net/netfilter/ipvs/ip_vs_ctl.c
··· 2263 2263 .proc_handler = proc_dointvec, 2264 2264 }, 2265 2265 #endif 2266 - { } 2267 2266 }; 2268 2267 2269 2268 #endif ··· 4285 4286 return -ENOMEM; 4286 4287 4287 4288 /* Don't export sysctls to unprivileged users */ 4288 - if (net->user_ns != &init_user_ns) { 4289 - tbl[0].procname = NULL; 4289 + if (net->user_ns != &init_user_ns) 4290 4290 ctl_table_size = 0; 4291 - } 4292 4291 } else 4293 4292 tbl = vs_vars; 4294 4293 /* Initialize sysctl defaults */
+1 -4
net/netfilter/ipvs/ip_vs_lblc.c
··· 123 123 .mode = 0644, 124 124 .proc_handler = proc_dointvec_jiffies, 125 125 }, 126 - { } 127 126 }; 128 127 #endif 129 128 ··· 562 563 return -ENOMEM; 563 564 564 565 /* Don't export sysctls to unprivileged users */ 565 - if (net->user_ns != &init_user_ns) { 566 - ipvs->lblc_ctl_table[0].procname = NULL; 566 + if (net->user_ns != &init_user_ns) 567 567 vars_table_size = 0; 568 - } 569 568 570 569 } else 571 570 ipvs->lblc_ctl_table = vs_vars_table;
+1 -4
net/netfilter/ipvs/ip_vs_lblcr.c
··· 294 294 .mode = 0644, 295 295 .proc_handler = proc_dointvec_jiffies, 296 296 }, 297 - { } 298 297 }; 299 298 #endif 300 299 ··· 748 749 return -ENOMEM; 749 750 750 751 /* Don't export sysctls to unprivileged users */ 751 - if (net->user_ns != &init_user_ns) { 752 - ipvs->lblcr_ctl_table[0].procname = NULL; 752 + if (net->user_ns != &init_user_ns) 753 753 vars_table_size = 0; 754 - } 755 754 } else 756 755 ipvs->lblcr_ctl_table = vs_vars_table; 757 756 ipvs->sysctl_lblcr_expiration = DEFAULT_EXPIRATION;
+1 -5
net/netfilter/nf_conntrack_standalone.c
··· 616 616 NF_SYSCTL_CT_LWTUNNEL, 617 617 #endif 618 618 619 - __NF_SYSCTL_CT_LAST_SYSCTL, 619 + NF_SYSCTL_CT_LAST_SYSCTL, 620 620 }; 621 - 622 - #define NF_SYSCTL_CT_LAST_SYSCTL (__NF_SYSCTL_CT_LAST_SYSCTL + 1) 623 621 624 622 static struct ctl_table nf_ct_sysctl_table[] = { 625 623 [NF_SYSCTL_CT_MAX] = { ··· 955 957 .proc_handler = nf_hooks_lwtunnel_sysctl_handler, 956 958 }, 957 959 #endif 958 - {} 959 960 }; 960 961 961 962 static struct ctl_table nf_ct_netfilter_table[] = { ··· 965 968 .mode = 0644, 966 969 .proc_handler = proc_dointvec, 967 970 }, 968 - { } 969 971 }; 970 972 971 973 static void nf_conntrack_standalone_init_tcp_sysctl(struct net *net,
+1 -2
net/netfilter/nf_log.c
··· 395 395 396 396 #ifdef CONFIG_SYSCTL 397 397 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3]; 398 - static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1]; 398 + static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO]; 399 399 static struct ctl_table_header *nf_log_sysctl_fhdr; 400 400 401 401 static struct ctl_table nf_log_sysctl_ftable[] = { ··· 406 406 .mode = 0644, 407 407 .proc_handler = proc_dointvec, 408 408 }, 409 - { } 410 409 }; 411 410 412 411 static int nf_log_proc_dostring(struct ctl_table *table, int write,
-1
net/netrom/sysctl_net_netrom.c
··· 140 140 .extra1 = &min_reset, 141 141 .extra2 = &max_reset 142 142 }, 143 - { } 144 143 }; 145 144 146 145 int __init nr_register_sysctl(void)
-1
net/phonet/sysctl.c
··· 81 81 .mode = 0644, 82 82 .proc_handler = proc_local_port_range, 83 83 }, 84 - { } 85 84 }; 86 85 87 86 int __init phonet_sysctl_init(void)
-1
net/rds/ib_sysctl.c
··· 103 103 .mode = 0644, 104 104 .proc_handler = proc_dointvec, 105 105 }, 106 - { } 107 106 }; 108 107 109 108 void rds_ib_sysctl_exit(void)
-1
net/rds/sysctl.c
··· 89 89 .mode = 0644, 90 90 .proc_handler = proc_dointvec, 91 91 }, 92 - { } 93 92 }; 94 93 95 94 void rds_sysctl_exit(void)
-1
net/rds/tcp.c
··· 86 86 .proc_handler = rds_tcp_skbuf_handler, 87 87 .extra1 = &rds_tcp_min_rcvbuf, 88 88 }, 89 - { } 90 89 }; 91 90 92 91 u32 rds_tcp_write_seq(struct rds_tcp_connection *tc)
-1
net/rose/sysctl_net_rose.c
··· 112 112 .extra1 = &min_window, 113 113 .extra2 = &max_window 114 114 }, 115 - { } 116 115 }; 117 116 118 117 void __init rose_register_sysctl(void)
-1
net/rxrpc/sysctl.c
··· 127 127 .extra1 = (void *)SYSCTL_ONE, 128 128 .extra2 = (void *)&four, 129 129 }, 130 - { } 131 130 }; 132 131 133 132 int __init rxrpc_sysctl_init(void)
+3 -7
net/sctp/sysctl.c
··· 80 80 .mode = 0644, 81 81 .proc_handler = proc_dointvec, 82 82 }, 83 - 84 - { /* sentinel */ } 85 83 }; 86 84 87 85 /* The following index defines are used in sctp_sysctl_net_register(). ··· 382 384 .extra1 = SYSCTL_ZERO, 383 385 .extra2 = &pf_expose_max, 384 386 }, 385 - 386 - { /* sentinel */ } 387 387 }; 388 388 389 389 static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write, ··· 593 597 594 598 int sctp_sysctl_net_register(struct net *net) 595 599 { 600 + size_t table_size = ARRAY_SIZE(sctp_net_table); 596 601 struct ctl_table *table; 597 602 int i; 598 603 ··· 601 604 if (!table) 602 605 return -ENOMEM; 603 606 604 - for (i = 0; table[i].data; i++) 607 + for (i = 0; i < table_size; i++) 605 608 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; 606 609 607 610 table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max; ··· 610 613 table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans; 611 614 612 615 net->sctp.sysctl_header = register_net_sysctl_sz(net, "net/sctp", 613 - table, 614 - ARRAY_SIZE(sctp_net_table)); 616 + table, table_size); 615 617 if (net->sctp.sysctl_header == NULL) { 616 618 kfree(table); 617 619 return -ENOMEM;
+3 -3
net/smc/smc_sysctl.c
··· 90 90 .extra1 = &conns_per_lgr_min, 91 91 .extra2 = &conns_per_lgr_max, 92 92 }, 93 - { } 94 93 }; 95 94 96 95 int __net_init smc_sysctl_net_init(struct net *net) 97 96 { 97 + size_t table_size = ARRAY_SIZE(smc_table); 98 98 struct ctl_table *table; 99 99 100 100 table = smc_table; ··· 105 105 if (!table) 106 106 goto err_alloc; 107 107 108 - for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++) 108 + for (i = 0; i < table_size; i++) 109 109 table[i].data += (void *)net - (void *)&init_net; 110 110 } 111 111 112 112 net->smc.smc_hdr = register_net_sysctl_sz(net, "net/smc", table, 113 - ARRAY_SIZE(smc_table)); 113 + table_size); 114 114 if (!net->smc.smc_hdr) 115 115 goto err_reg; 116 116
-1
net/sunrpc/sysctl.c
··· 160 160 .mode = 0444, 161 161 .proc_handler = proc_do_xprt, 162 162 }, 163 - { } 164 163 }; 165 164 166 165 void
-1
net/sunrpc/xprtrdma/svc_rdma.c
··· 209 209 .extra1 = &zero, 210 210 .extra2 = &zero, 211 211 }, 212 - { }, 213 212 }; 214 213 215 214 static void svc_rdma_proc_cleanup(void)
-1
net/sunrpc/xprtrdma/transport.c
··· 137 137 .mode = 0644, 138 138 .proc_handler = proc_dointvec, 139 139 }, 140 - { }, 141 140 }; 142 141 143 142 #endif
-1
net/sunrpc/xprtsock.c
··· 160 160 .mode = 0644, 161 161 .proc_handler = proc_dointvec_jiffies, 162 162 }, 163 - { }, 164 163 }; 165 164 166 165 /*
-1
net/tipc/sysctl.c
··· 91 91 .mode = 0644, 92 92 .proc_handler = proc_doulongvec_minmax, 93 93 }, 94 - {} 95 94 }; 96 95 97 96 int tipc_register_sysctl(void)
-1
net/unix/sysctl_net_unix.c
··· 19 19 .mode = 0644, 20 20 .proc_handler = proc_dointvec 21 21 }, 22 - { } 23 22 }; 24 23 25 24 int __net_init unix_sysctl_register(struct net *net)
-1
net/x25/sysctl_net_x25.c
··· 71 71 .mode = 0644, 72 72 .proc_handler = proc_dointvec, 73 73 }, 74 - { }, 75 74 }; 76 75 77 76 int __init x25_register_sysctl(void)
+1 -4
net/xfrm/xfrm_sysctl.c
··· 38 38 .mode = 0644, 39 39 .proc_handler = proc_dointvec 40 40 }, 41 - {} 42 41 }; 43 42 44 43 int __net_init xfrm_sysctl_init(struct net *net) ··· 56 57 table[3].data = &net->xfrm.sysctl_acq_expires; 57 58 58 59 /* Don't export sysctls to unprivileged users */ 59 - if (net->user_ns != &init_user_ns) { 60 - table[0].procname = NULL; 60 + if (net->user_ns != &init_user_ns) 61 61 table_size = 0; 62 - } 63 62 64 63 net->xfrm.sysctl_hdr = register_net_sysctl_sz(net, "net/core", table, 65 64 table_size);