1
0
Fork 0
alistair23-linux/drivers
Matteo Croce eec4844fae proc/sysctl: add shared variables for range check
In the sysctl code the proc_dointvec_minmax() function is often used to
validate the user supplied value between an allowed range.  This
function uses the extra1 and extra2 members from struct ctl_table as
minimum and maximum allowed value.

On sysctl handler declaration, in every source file there are some
readonly variables containing just an integer which address is assigned
to the extra1 and extra2 members, so the sysctl range is enforced.

The special values 0, 1 and INT_MAX are very often used as range
boundary, leading duplication of variables like zero=0, one=1,
int_max=INT_MAX in different source files:

    $ git grep -E '\.extra[12].*&(zero|one|int_max)' |wc -l
    248

Add a const int array containing the most commonly used values, some
macros to refer more easily to the correct array member, and use them
instead of creating a local one for every object file.

This is the bloat-o-meter output comparing the old and new binary
compiled with the default Fedora config:

    # scripts/bloat-o-meter -d vmlinux.o.old vmlinux.o
    add/remove: 2/2 grow/shrink: 0/2 up/down: 24/-188 (-164)
    Data                                         old     new   delta
    sysctl_vals                                    -      12     +12
    __kstrtab_sysctl_vals                          -      12     +12
    max                                           14      10      -4
    int_max                                       16       -     -16
    one                                           68       -     -68
    zero                                         128      28    -100
    Total: Before=20583249, After=20583085, chg -0.00%

[mcroce@redhat.com: tipc: remove two unused variables]
  Link: http://lkml.kernel.org/r/20190530091952.4108-1-mcroce@redhat.com
[akpm@linux-foundation.org: fix net/ipv6/sysctl_net_ipv6.c]
[arnd@arndb.de: proc/sysctl: make firmware loader table conditional]
  Link: http://lkml.kernel.org/r/20190617130014.1713870-1-arnd@arndb.de
[akpm@linux-foundation.org: fix fs/eventpoll.c]
Link: http://lkml.kernel.org/r/20190430180111.10688-1-mcroce@redhat.com
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-18 17:08:07 -07:00
..
accessibility
acpi mm/memory_hotplug: rename walk_memory_range() and pass start+size instead of pfns 2019-07-18 17:08:06 -07:00
amba Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
android
ata for-5.3/libata-20190708 2019-07-09 10:59:26 -07:00
atm
auxdisplay It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
base proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
bcma
block Merge branch 'floppy' 2019-07-18 08:43:20 -07:00
bluetooth Bluetooth: btusb: Add protocol support for MediaTek MT7663U USB devices 2019-07-06 21:44:25 +02:00
bus
cdrom
char docs: admin-guide: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
clk This round of clk driver and framework updates is heavy on the driver update 2019-07-17 10:07:48 -07:00
clocksource clocksource/drivers/npcm: Fix misuse of GENMASK macro 2019-07-10 11:05:26 +02:00
connector
counter Staging / IIO driver update for 5.3-rc1 2019-07-11 15:36:02 -07:00
cpufreq Merge branch 'pm-cpufreq' 2019-07-18 09:49:30 +02:00
cpuidle Merge branch 'pm-cpufreq' 2019-07-18 09:49:30 +02:00
crypto docs: arm: convert docs to ReST and rename to *.rst 2019-07-15 09:20:24 -03:00
dax device-dax: "Hotremove" persistent memory that is used like normal RAM 2019-07-16 19:23:24 -07:00
dca
devfreq
dio
dma dmaengine updates for v5.3-rc1 2019-07-17 09:55:43 -07:00
dma-buf docs conversion for v5.3-rc1 2019-07-16 12:21:41 -07:00
edac
eisa
extcon
firewire
firmware This round of clk driver and framework updates is heavy on the driver update 2019-07-17 10:07:48 -07:00
fpga mm: add account_locked_vm utility function 2019-07-16 19:23:25 -07:00
fsi
gnss
gpio GPIO fixes for the v5.3 merge window: 2019-07-17 13:05:21 -07:00
gpu proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
hid stream_open related bits for Linux 5.3 2019-07-14 17:08:08 -07:00
hsi
hv proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
hwmon Char / Misc driver patches for 5.3-rc1 2019-07-11 15:34:05 -07:00
hwspinlock hwspinlock: add the 'in_atomic' API 2019-06-29 21:08:14 -07:00
hwtracing coresight: Make the coresight_device_fwnode_match declaration's fwnode parameter const 2019-07-12 14:42:05 -07:00
i2c Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
i3c * Drop support for 10-bit I2C addresses 2019-07-09 09:04:31 -07:00
ide It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
idle
iio Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
infiniband 5.3 Merge window RDMA pull request 2019-07-15 20:38:15 -07:00
input docs: arm: convert docs to ReST and rename to *.rst 2019-07-15 09:20:24 -03:00
interconnect
iommu virtio, vhost: fixes, features, performance 2019-07-17 11:26:09 -07:00
ipack TTY / Serial driver updates for 5.3-rc1 2019-07-11 15:38:21 -07:00
irqchip irqchip/gic-v3-its: Fix misuse of GENMASK macro 2019-07-10 11:04:17 +02:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
leds LED updates for 5.3-rc1 2019-07-09 08:59:39 -07:00
lightnvm
macintosh powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
mailbox - stm32: race fix by adding a spinlock 2019-07-14 16:36:51 -07:00
mcb
md docs conversion for v5.3-rc1 2019-07-16 12:21:41 -07:00
media Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
memory The main MIPS changes for a pretty light v5.3 cycle, including: 2019-07-17 09:42:03 -07:00
memstick MMC core: 2019-07-11 18:11:21 -07:00
message SCSI misc on 20190709 2019-07-11 15:14:01 -07:00
mfd - Core Frameworks 2019-07-15 20:18:40 -07:00
misc dmaengine updates for v5.3-rc1 2019-07-17 09:55:43 -07:00
mmc MMC core: 2019-07-11 18:11:21 -07:00
mtd docs: mtd: move it to the driver-api book 2019-07-15 09:20:28 -03:00
mux
net The main MIPS changes for a pretty light v5.3 cycle, including: 2019-07-17 09:42:03 -07:00
nfc nfc: st-nci: remove redundant assignment to variable r 2019-07-02 12:00:50 -07:00
ntb
nubus
nvdimm libnvdimm/pfn: stop padding pmem namespaces to section alignment 2019-07-18 17:08:07 -07:00
nvme for-linus-20190715 2019-07-15 21:20:52 -07:00
nvmem Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
of virtio, vhost: fixes, features, performance 2019-07-17 11:26:09 -07:00
opp pci-v5.3-changes 2019-07-15 20:44:49 -07:00
oprofile
parisc
parport It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
pci virtio, vhost: fixes, features, performance 2019-07-17 11:26:09 -07:00
pcmcia It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
perf docs: perf: move to the admin-guide 2019-07-15 09:20:27 -03:00
phy phy: for 5.3 2019-07-01 15:04:59 +02:00
pinctrl This is the bulk of pin control changes for the v5.3 kernel 2019-07-13 15:02:27 -07:00
platform platform/x86: asus: Rename "fan mode" to "fan boost mode" 2019-07-17 19:07:58 +03:00
pnp docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
power power supply and reset changes for the v5.3 series 2019-07-15 21:06:15 -07:00
powercap powercap/rapl: Add Ice Lake NNPI support to RAPL driver 2019-07-11 15:08:58 +02:00
pps drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl 2019-07-16 19:23:24 -07:00
ps3
ptp
pwm pwm: Changes for v5.3-rc1 2019-07-09 08:57:45 -07:00
rapidio Merge branch 'akpm' (patches from Andrew) 2019-07-17 08:58:04 -07:00
ras
regulator - Core Frameworks 2019-07-15 20:18:40 -07:00
remoteproc remoteproc updates for v5.3 2019-07-17 11:44:41 -07:00
reset
rpmsg
rtc RTC for 5.3 2019-07-17 10:03:50 -07:00
s390 s390 updates for the 5.3 merge window #2 2019-07-12 15:39:22 -07:00
sbus
scsi virtio, vhost: fixes, features, performance 2019-07-17 11:26:09 -07:00
sfi
sh
siox
slimbus
sn
soc remoteproc updates for v5.3 2019-07-17 11:44:41 -07:00
soundwire soundwire updates for v5.3-rc1 2019-07-05 08:15:08 +02:00
spi Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
spmi
ssb
staging docs conversion for v5.3-rc1 2019-07-16 12:21:41 -07:00
target SCSI misc on 20190709 2019-07-11 15:14:01 -07:00
tc
tee
thermal More power management updates for 5.3-rc1 2019-07-18 09:32:28 -07:00
thunderbolt Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
tty proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
uio
usb Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
uwb
vfio VFIO updates for v5.3-rc1 2019-07-17 11:23:13 -07:00
vhost virtio, vhost: fixes, features, performance 2019-07-17 11:26:09 -07:00
video - New Functionality 2019-07-16 09:25:04 -07:00
virt
virtio virtio-mmio: add error check for platform_get_irq 2019-07-11 16:22:29 -04:00
visorbus
vlynq
vme
w1 docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
watchdog Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
xen proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
zorro
Kconfig
Makefile