Skip to content

sysctl: encode the min/max values directly in the table entry

Wen Yang lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest posting 2/25 patches 1 replyIn review
  2. v4 posting 1/25 patches 2 repliesSuperseded
  3. v35 patches 3 repliesSuperseded

Patches in v4 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5sysctl: add helper functions to extract table->extra1/extra2fs/proc/proc_sysctl.c include/linux/sysctl.h kernel/sysctl.c+63 -220 replies
2/5sysctl: support encoding values directly in the table entryfs/proc/proc_sysctl.c include/linux/sysctl.h+26 -60 replies
3/5sysctl: add kunit test code to check the min/max encoding of sysctl table entrieskernel/sysctl-test.c+581 -00 replies
4/5sysctl: delete mmap_rnd_bits_{min/max} and mmap_rnd_compat_bits_{min/max} to save 16 bytesinclude/linux/mm.h kernel/sysctl.c mm/mmap.c+6 -140 replies
5/5sysctl: delete six_hundred_forty_kb to save 4 byteskernel/sysctl.c+3 -101 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [RESEND PATCH v4 0/5] sysctl: encode the min/max values directly in the table entry

Many modules use these additional static/global variables (such as two_five_five, n_65535, ue_int_max, etc.) in the boundary checking of sysctl, and they are read-only and never changed.

Eric points out: "by turning .extra1 and .extra2 into longs instead of keeping them as pointers and needing constants to be pointed at somewhere .. The only people I can see who find a significant benefit by consolidating all of the constants into one place are people who know how to stomp kernel memory."

This patch series achieves direct encoding values in table entries and still maintains compatibility with existing extra1/extra2 pointers. Afterwards, we can remove these unnecessary static variables progressively and also gradually kill the shared const array.

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Wen Yang (5):
sysctl: add helper functions to extract table->extra1/extra2
sysctl: support encoding values directly in the table entry
sysctl: add kunit test code to check the min/max encoding of sysctl
table entries
sysctl: delete mmap_rnd_bits_{min/max} and
mmap_rnd_compat_bits_{min/max} to save 16 bytes
sysctl: delete six_hundred_forty_kb to save 4 bytes

 fs/proc/proc_sysctl.c  |  29 +-
 include/linux/mm.h     |   4 -
 include/linux/sysctl.h |  64 ++++-
 kernel/sysctl-test.c   | 581 +++++++++++++++++++++++++++++++++++++++++
 kernel/sysctl.c        |  45 ++--
 mm/mmap.c              |   4 -
 6 files changed, 677 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1