提交 28edde6a 编写于 作者: L Long Li 提交者: Zheng Zengkai

proc: avoid integer type confusion in get_proc_long

stable inclusion
from stable-v5.10.157
commit 4aa32aaef6c1b5e39ae2508ec596bd7b67871043
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I65TQE
CVE: CVE-2022-4378

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4aa32aaef6c1b5e39ae2508ec596bd7b67871043

--------------------------------

commit e6cfaf34 upstream.

proc_get_long() is passed a size_t, but then assigns it to an 'int'
variable for the length.  Let's not do that, even if our IO paths are
limited to MAX_RW_COUNT (exactly because of these kinds of type errors).

So do the proper test in the rigth type.
Reported-by: NKyle Zeng <zengyhkyle@gmail.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NLong Li <leo.lilong@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 9ef2cc25
......@@ -471,13 +471,12 @@ static int proc_get_long(char **buf, size_t *size,
unsigned long *val, bool *neg,
const char *perm_tr, unsigned perm_tr_len, char *tr)
{
int len;
char *p, tmp[TMPBUFLEN];
ssize_t len = *size;
if (!*size)
if (len <= 0)
return -EINVAL;
len = *size;
if (len > TMPBUFLEN - 1)
len = TMPBUFLEN - 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册