Commit e538a582 authored by Adrian Hunter's avatar Adrian Hunter Committed by Andrew Morton

proc/kcore: do not try to access unaccepted memory

Support for unaccepted memory was added recently, refer commit
dcdfdd40 ("mm: Add support for unaccepted memory"), whereby a virtual
machine may need to accept memory before it can be used.

Do not try to access unaccepted memory because it can cause the guest to
fail.

For /proc/kcore, which is read-only and does not support mmap, this means a
read of unaccepted memory will return zeros.

Link: https://lkml.kernel.org/r/20230911112114.91323-3-adrian.hunter@intel.comSigned-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 7cd34dd3
...@@ -546,7 +546,8 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter) ...@@ -546,7 +546,8 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter)
* and explicitly excluded physical ranges. * and explicitly excluded physical ranges.
*/ */
if (!page || PageOffline(page) || if (!page || PageOffline(page) ||
is_page_hwpoison(page) || !pfn_is_ram(pfn)) { is_page_hwpoison(page) || !pfn_is_ram(pfn) ||
pfn_is_unaccepted_memory(pfn)) {
if (iov_iter_zero(tsz, iter) != tsz) { if (iov_iter_zero(tsz, iter) != tsz) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment