From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Kees Cook <keescook@chromium.org>,
Laura Abbott <labbott@redhat.com>,
"Mark Rutland" <mark.rutland@arm.com>, <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
<linux-kernel@vger.kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
"Paul Mackerras" <paulus@samba.org>,
<linuxppc-dev@lists.ozlabs.org>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>,
Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH v2 2/2] mm: usercopy: Warn vmalloc/module address in check_heap_object()
Date: Sat, 25 Dec 2021 20:06:21 +0800 [thread overview]
Message-ID: <20211225120621.13908-3-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20211225120621.13908-1-wangkefeng.wang@huawei.com>
virt_addr_valid() could be insufficient to validate the virt addr
on some architecture, which could lead to potential BUG which has
been found on arm64/powerpc64.
Let's add WARN_ON to check if the virt addr is passed virt_addr_valid()
but is a vmalloc/module address.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/usercopy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/usercopy.c b/mm/usercopy.c
index b3de3c4eefba..ce83e0b137dd 100644
--- a/mm/usercopy.c
+++ b/mm/usercopy.c
@@ -228,6 +228,8 @@ static inline void check_heap_object(const void *ptr, unsigned long n,
if (!virt_addr_valid(ptr))
return;
+ WARN_ON_ONCE(is_vmalloc_or_module_addr(ptr));
+
/*
* When CONFIG_HIGHMEM=y, kmap_to_page() will give either the
* highmem page or fallback to virt_to_page(). The following
--
2.26.2
next prev parent reply other threads:[~2021-12-25 11:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-25 12:06 [PATCH v2 0/2] mm: Fix kernel BUG in __check_heap_object() on PowerPC64 Kefeng Wang
2021-12-25 12:06 ` [PATCH v2 1/2] powerpc: Fix virt_addr_valid() check Kefeng Wang
2022-01-08 11:58 ` Kefeng Wang
2022-01-11 4:37 ` Nicholas Piggin
2022-01-11 6:04 ` Christophe Leroy
2022-01-19 1:15 ` Kefeng Wang
2022-01-20 7:31 ` Christophe Leroy
2022-01-20 11:09 ` Kefeng Wang
2022-01-10 8:01 ` Christophe Leroy
2021-12-25 12:06 ` Kefeng Wang [this message]
2021-12-26 17:33 ` [PATCH v2 2/2] mm: usercopy: Warn vmalloc/module address in check_heap_object() Christophe Leroy
2021-12-28 4:51 ` Kefeng Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211225120621.13908-3-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=keescook@chromium.org \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).