]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
proc/vmcore: fix signedness bug in read_from_oldmem()
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 25 Jul 2023 17:03:16 +0000 (20:03 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Aug 2023 08:24:14 +0000 (10:24 +0200)
commitaf7aa4fe94b3dc0652f7fb5369f78623e98b0310
treef70a2d37bb81aa1b236783f03fedea2f1ae81cc8
parent7f1715d827dc6d1ad48e192ee2d45eef79166d4a
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>
fs/proc/vmcore.c