diff options
author | Christian Brauner <[email protected]> | 2019-05-14 15:44:55 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2019-05-14 19:52:51 -0700 |
commit | e260ad01f0aa9e96b5386d5cd7184afd949dc457 (patch) | |
tree | b1d538e7bfb4b9e3344d6e5a2912163e408d53b8 | |
parent | 475dae385497dde3f25271ce77b526a1e54a472a (diff) |
sysctl: return -EINVAL if val violates minmax
Currently when userspace gives us a values that overflow e.g. file-max
and other callers of __do_proc_doulongvec_minmax() we simply ignore the
new value and leave the current value untouched.
This can be problematic as it gives the illusion that the limit has
indeed be bumped when in fact it failed. This commit makes sure to
return EINVAL when an overflow is detected. Please note that this is a
userspace facing change.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Christian Brauner <[email protected]>
Acked-by: Luis Chamberlain <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Dominik Brodowski <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Joe Lawrence <[email protected]>
Cc: Waiman Long <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | kernel/sysctl.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d82f9161adb8..f7bd1aead3bf 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2886,8 +2886,10 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int if (neg) continue; val = convmul * val / convdiv; - if ((min && val < *min) || (max && val > *max)) - continue; + if ((min && val < *min) || (max && val > *max)) { + err = -EINVAL; + break; + } *i = val; } else { val = convdiv * (*i) / convmul; |