From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Kefeng Wang <wangkefeng.wang@huawei.com>,
Kees Cook <keescook@chromium.org>,
Laura Abbott <labbott@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.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" <linuxppc-dev@lists.ozlabs.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH v2 2/2] mm: usercopy: Warn vmalloc/module address in check_heap_object()
Date: Sun, 26 Dec 2021 17:33:43 +0000 [thread overview]
Message-ID: <fadd9754-ab85-63ec-4d6a-c6490adb5d94@csgroup.eu> (raw)
In-Reply-To: <20211225120621.13908-3-wangkefeng.wang@huawei.com>
Le 25/12/2021 à 13:06, Kefeng Wang a écrit :
> 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.
I think that's the responsibility of the architecture and doesn't
deserve a WARN_ON() in generic code.
The generic code cannot check all what architectures do wrong.
Eventually you can do some testing at startup, maybe with
CONFIG_DEBUG_VM_PGTABLE, but I don't think we should have such
verification in functions like check_heap_object()
>
> 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
next prev parent reply other threads:[~2021-12-26 17:33 UTC|newest]
Thread overview: 11+ 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
[not found] ` <1641871726.fshx7g5r92.astroid@bobo.none>
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 ` [PATCH v2 2/2] mm: usercopy: Warn vmalloc/module address in check_heap_object() Kefeng Wang
2021-12-26 17:33 ` Christophe Leroy [this message]
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=fadd9754-ab85-63ec-4d6a-c6490adb5d94@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--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 \
--cc=wangkefeng.wang@huawei.com \
/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