Skip to content

sysctl: fix range-checking in do_proc_dointvec_minmax_conv()

Zev Weiss linux-fsdevel linux-kselftest lkml stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 2 repliesIn review
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Rearranged selftest to also test negative values and provide more info in comments
- Added intermediate patch as a minimal fix for -stable without the refactoring

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3test_sysctl: add tests for >32-bit values written to 32-bit integerstools/testing/selftests/sysctl/sysctl.sh+55 -00 replies
2/3kernel/sysctl.c: add missing range check in do_proc_dointvec_minmax_convkernel/sysctl.c+10 -10 replies
3/3kernel/sysctl.c: define minmax conv functions in terms of non-minmax versionskernel/sysctl.c+27 -320 replies
3/3kernel/sysctl.c: define minmax conv functions in terms of non-minmax versionskernel/sysctl.c+27 -320 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH v2 0/3] sysctl: fix range-checking in do_proc_dointvec_minmax_conv()

Hello,

After being left with an unusable system after a typo executing something like 'echo $((1<<24)) > /proc/sys/vm/max_map_count', I found that do_proc_dointvec_minmax_conv() was missing a check to ensure that the converted value actually fits in an int.

The first of the following patches enhances the sysctl selftest such that it detects this problem; the second provides a minimal fix (suitable for -stable) such that the selftest passes. The third patch then performs a more thorough refactoring to eliminate the code duplication that led to the bug in the first place (maintaining the passing status of the selftest).

Changes in v2:
- Rearranged selftest to also test negative values and provide more info in comments
- Added intermediate patch as a minimal fix for -stable without the refactoring

Thanks,
Zev Weiss