Re: [PATCH 1/2] MIPS: Bounds check virt_addr_valid

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

 



On Tue, Jun 11, 2019 at 01:41:21AM +0200, Hauke Mehrtens wrote:
> On 5/28/19 7:05 PM, Paul Burton wrote:
> > ---
> > 
> >  arch/mips/mm/mmap.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
> > index 2f616ebeb7e0..7755a1fad05a 100644
> > --- a/arch/mips/mm/mmap.c
> > +++ b/arch/mips/mm/mmap.c
> > @@ -203,6 +203,11 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
> >  
> >  int __virt_addr_valid(const volatile void *kaddr)
> >  {
> > +	unsigned long vaddr = (unsigned long)vaddr;

the second vaddr should be better kaddr

> > +
> > +	if ((vaddr < PAGE_OFFSET) || (vaddr >= MAP_BASE))
> > +		return 0;
> > +
> >  	return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
> >  }
> >  EXPORT_SYMBOL_GPL(__virt_addr_valid);
> > 
> 
> Someone complained that this compiled to a constant "return 0" for him:
> https://bugs.openwrt.org/index.php?do=details&task_id=2305#comment6554
> 
> I just checked this on a unmodified 5.2-rc4 with the xway_defconfig and
> I get this:
> 
> 0001915c <__virt_addr_valid>:
>    1915c:       03e00008        jr      ra
>    19160:       00001025        move    v0,zero
> 
> Is this intended?

I don't think so. Interesting what the compiler decides to do here.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux