Skip to content

Fix overflow issues with sysctl values in centiseconds/seconds

Bart Samwel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Represent dirty_*_centisecs as jiffies internallyinclude/linux/writeback.h kernel/sysctl.c mm/page-writeback.c+19 -190 replies
2/3Represent laptop_mode as jiffies internallykernel/sysctl.c mm/page-writeback.c+5 -50 replies
3/3Range checking in do_proc_dointvec_(userhz_)jiffies_convkernel/sysctl.c+4 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/3] Fix overflow issues with sysctl values in centiseconds/seconds

Hi Andrew,

Here's a threesome of patches to fix up some issues with the following sysctl values:

/proc/sys/vm/laptop_mode
/proc/sys/vm/dirty_writeback_centisecs
/proc/sys/vm/dirty_expire_centisecs

The issues:
1. The values are not range checked when they are set. They all have
a range smaller than the full integer range.
2. Conversion from these centisecond/second values is done on-the-fly wherever they are used. This wastes some resources.
3. The conversions are done badly. Conversion from USER_HZ to HZ is done by doing "value * USER_HZ / HZ". One day expressed in centiseconds already causes an overflow at HZ = 250. This should use clock_t_to_jiffies() instead.

The approach:
1. Represent everything in jiffies internally.
2. Do the conversion and range checking in the sysctl interface.

Cheers,
Bart