From: Kees Cook <keescook@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Yuanzheng Song <songyuanzheng@huawei.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH] mm: usercopy: move the virt_addr_valid() below the is_vmalloc_addr()
Date: Tue, 10 May 2022 14:54:47 -0700 [thread overview]
Message-ID: <202205101453.145A1C4F@keescook> (raw)
In-Reply-To: <20220509203732.951da2e00ddfa628decf24a2@linux-foundation.org>
On Mon, May 09, 2022 at 08:37:32PM -0700, Andrew Morton wrote:
> Matthew & Kees,
>
> On Thu, 5 May 2022 07:10:37 +0000 Yuanzheng Song <songyuanzheng@huawei.com> wrote:
>
> > The is_kmap_addr() and the is_vmalloc_addr() in the check_heap_object()
> > will not work, because the virt_addr_valid() will exclude the kmap and
> > vmalloc regions. So let's move the virt_addr_valid() below
> > the is_vmalloc_addr().
>
> The author,
>
> > Signed-off-by: Yuanzheng Song <songyuanzheng@huawei.com>
>
> Tells me off-list that this fix:
>
> > --- a/mm/usercopy.c
> > +++ b/mm/usercopy.c
> > @@ -163,9 +163,6 @@ static inline void check_heap_object(const void *ptr, unsigned long n,
> > {
> > struct folio *folio;
> >
> > - if (!virt_addr_valid(ptr))
> > - return;
> > -
> > if (is_kmap_addr(ptr)) {
> > unsigned long page_end = (unsigned long)ptr | (PAGE_SIZE - 1);
> >
> > @@ -190,6 +187,9 @@ static inline void check_heap_object(const void *ptr, unsigned long n,
> > return;
> > }
> >
> > + if (!virt_addr_valid(ptr))
> > + return;
> > +
> > folio = virt_to_folio(ptr);
> >
> > if (folio_test_slab(folio)) {
>
> is required to fix patches "mm/usercopy: Check kmap addresses properly"
> and "mm/usercopy: Detect vmalloc overruns".
Ah, this very well may be true! I will need to study this (or more
likely, I will build some selftests), but I suspect willy knows off the
top of his head. :)
--
Kees Cook
next prev parent reply other threads:[~2022-05-10 21:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 7:10 [PATCH] mm: usercopy: move the virt_addr_valid() below the is_vmalloc_addr() Yuanzheng Song
2022-05-10 3:37 ` Andrew Morton
2022-05-10 21:54 ` Kees Cook [this message]
2022-05-12 5:39 ` Kees Cook
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=202205101453.145A1C4F@keescook \
--to=keescook@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=songyuanzheng@huawei.com \
--cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.