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

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

 



Hi Hauke & Thomas,

On Tue, Jun 11, 2019 at 10:19:47AM +0200, Thomas Bogendoerfer wrote:
> On Tue, Jun 11, 2019 at 01:41:21AM +0200, Hauke Mehrtens wrote:
> > On 5/28/19 7:05 PM, Paul Burton wrote:
> > > 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

D'oh..! Right you are...

Returning false all the time is enough to silence the hardened usercopy
warnings but clearly not the right behaviour.

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

Yes, this is equivalent to using uninitialized_var() but I'm surprised
the code got discarded entirely...

Thanks,
    Paul




[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