diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2023-07-25 20:03:16 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-08-03 10:26:09 +0200 |
commit | 6efc575dd2a64375a459fb07a19e3377f5d488a6 (patch) | |
tree | 335df6f8a1a238ebb598a20f8986a9df57c160e2 | |
parent | e7b25896f447578260eba01fa78339781a733e6f (diff) | |
download | linux-stable-6efc575dd2a64375a459fb07a19e3377f5d488a6.tar.gz linux-stable-6efc575dd2a64375a459fb07a19e3377f5d488a6.tar.bz2 linux-stable-6efc575dd2a64375a459fb07a19e3377f5d488a6.zip |
proc/vmcore: fix signedness bug in read_from_oldmem()
commit 641db40f3afe7998011bfabc726dba3e698f8196 upstream.
The bug is the error handling:
if (tmp < nr_bytes) {
"tmp" can hold negative error codes but because "nr_bytes" is type size_t
the negative error codes are treated as very high positive values
(success). Fix this by changing "nr_bytes" to type ssize_t. The
"nr_bytes" variable is used to store values between 1 and PAGE_SIZE and
they can fit in ssize_t without any issue.
Link: https://lkml.kernel.org/r/b55f7eed-1c65-4adc-95d1-6c7c65a54a6e@moroto.mountain
Fixes: 5d8de293c224 ("vmcore: convert copy_oldmem_page() to take an iov_iter")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/proc/vmcore.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 03f5963914a1..a0e1463c3fc4 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -132,7 +132,7 @@ ssize_t read_from_oldmem(struct iov_iter *iter, size_t count, u64 *ppos, bool encrypted) { unsigned long pfn, offset; - size_t nr_bytes; + ssize_t nr_bytes; ssize_t read = 0, tmp; int idx; |