lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202205101453.145A1C4F@keescook>
Date:   Tue, 10 May 2022 14:54:47 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Yuanzheng Song <songyuanzheng@...wei.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, Matthew Wilcox <willy@...radead.org>
Subject: Re: [PATCH] mm: usercopy: move the virt_addr_valid() below the
 is_vmalloc_addr()

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@...wei.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@...wei.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ