Skip to content

Commit 641db40

Browse files
Dan Carpenterakpm00
authored andcommitted
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/[email protected] Fixes: 5d8de29 ("vmcore: convert copy_oldmem_page() to take an iov_iter") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Acked-by: Baoquan He <[email protected]> Cc: Dave Young <[email protected]> Cc: Vivek Goyal <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 286812b commit 641db40

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
@@ -132,7 +132,7 @@ ssize_t read_from_oldmem(struct iov_iter *iter, size_t count,
132132
u64 *ppos, bool encrypted)
133133
{
134134
unsigned long pfn, offset;
135-
size_t nr_bytes;
135+
ssize_t nr_bytes;
136136
ssize_t read = 0, tmp;
137137
int idx;
138138

0 commit comments

Comments
 (0)