Re: [PATCH 1/3] mm/usercopy: Check kmap addresses properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 05, 2021 at 10:43:13PM +0100, Matthew Wilcox wrote:
> On Tue, Oct 05, 2021 at 02:23:09PM -0700, Kees Cook wrote:
> > > +	if (is_kmap_addr(ptr)) {
> > > +		unsigned long page_end = (unsigned long)ptr | (PAGE_SIZE - 1);
> > > +
> > > +		if ((unsigned long)ptr + n - 1 > page_end)
> > > +			usercopy_abort("kmap", NULL, to_user, 0, n);
> > 
> > It's likely not worth getting an offset here, but "0" above could be
> > something like "ptr - PKMAP_ADDR(0)".
> 
> Mmm.  page_offset(ptr) should do the trick, no?

Ah yeah, that'd be good!

-Kees

> 
> > Either way:
> > 
> > Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>
> > 
> > Thanks!
> > 
> > -Kees
> > 
> > > +		return;
> > > +	}
> > > +
> > > +	page = virt_to_head_page(ptr);
> > >  
> > >  	if (PageSlab(page)) {
> > >  		/* Check slab allocator for flags and size. */
> > > -- 
> > > 2.32.0
> > > 
> > 
> > -- 
> > Kees Cook

-- 
Kees Cook




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux