Skip to content
  • Alexey Dobriyan's avatar
    [PATCH] sysctl_{,ms_}jiffies: fix oldlen semantics · 3ee75ac3
    Alexey Dobriyan authored
    
    
    currently it's
    1) if *oldlenp == 0,
    	don't writeback anything
    
    2) if *oldlenp >= table->maxlen,
    	don't writeback more than table->maxlen bytes and rewrite *oldlenp
    	don't look at underlying type granularity
    
    3) if 0 < *oldlenp < table->maxlen,
    		*cough*
    	string sysctls don't writeback more than *oldlenp bytes.
    	OK, that's because sizeof(char) == 1
    
    	int sysctls writeback anything in (0, table->maxlen] range
    	Though accept integers divisible by sizeof(int) for writing.
    
    sysctl_jiffies and sysctl_ms_jiffies don't writeback anything but
    sizeof(int), which violates 1) and 2).
    
    So, make sysctl_jiffies and sysctl_ms_jiffies accept
    a) *oldlenp == 0, not doing writeback
    b) *oldlenp >= sizeof(int), writing one integer.
    
    -EINVAL still returned for *oldlenp == 1, 2, 3.
    
    Signed-off-by: default avatarAlexey Dobriyan <adobriyan@openvz.org>
    Cc: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    3ee75ac3