Skip to content

Commit 85fd573

Browse files
author
Baoquan He
committed
proc/vmcore: fix signedness bug in read_from_oldmem()
JIRA: https://issues.redhat.com/browse/RHEL-32199 Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 641db40 Author: Dan Carpenter <dan.carpenter@linaro.org> Date: Tue Jul 25 20:03:16 2023 +0300 proc/vmcore: fix signedness bug in read_from_oldmem() 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: 5d8de29 ("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: Baoquan He <bhe@redhat.com>
1 parent 78ef223 commit 85fd573

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/proc/vmcore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ ssize_t read_from_oldmem(struct iov_iter *iter, size_t count,
133133
u64 *ppos, bool encrypted)
134134
{
135135
unsigned long pfn, offset;
136-
size_t nr_bytes;
136+
ssize_t nr_bytes;
137137
ssize_t read = 0, tmp;
138138
int idx;
139139

0 commit comments

Comments
 (0)