提交 d4efd873 编写于 作者: C Christian Brauner 提交者: Xie XiuQi

sysctl: return -EINVAL if val violates minmax

[ Upstream commit e260ad01 ]

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/20190210203943.8227-4-christian@brauner.ioSigned-off-by: NChristian Brauner <christian@brauner.io>
Acked-by: NLuis Chamberlain <mcgrof@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 67993031
...@@ -2863,8 +2863,10 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int ...@@ -2863,8 +2863,10 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
if (neg) if (neg)
continue; continue;
val = convmul * val / convdiv; val = convmul * val / convdiv;
if ((min && val < *min) || (max && val > *max)) if ((min && val < *min) || (max && val > *max)) {
continue; err = -EINVAL;
break;
}
*i = val; *i = val;
} else { } else {
val = convdiv * (*i) / convmul; val = convdiv * (*i) / convmul;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册