summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-12-05 11:33:40 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 11:18:32 +0100
commitfe84d7f0cb66d150de094fba461f0cb5d5b12c85 (patch)
tree9ae0a417076f7fc2bc6e733729c0d8520530728a /kernel
parent5c55961166d44d9fc603f52fd05615a96ca093c8 (diff)
downloadlinux-stable-fe84d7f0cb66d150de094fba461f0cb5d5b12c85.tar.gz
linux-stable-fe84d7f0cb66d150de094fba461f0cb5d5b12c85.tar.bz2
linux-stable-fe84d7f0cb66d150de094fba461f0cb5d5b12c85.zip
proc: avoid integer type confusion in get_proc_long
commit e6cfaf34be9fcd1a8285a294e18986bfc41a409c 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: Kyle Zeng <zengyhkyle@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sysctl.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 93a7bd4185d0..bf99cdd1609c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2156,13 +2156,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;