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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z-xT2Td5_8XbSO1t@gmail.com>
Date: Tue, 1 Apr 2025 23:00:09 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Mateusz Guzik <mjguzik@...il.com>
Cc: mingo@...hat.com, x86@...nel.org, linux-kernel@...r.kernel.org,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Uros Bizjak <ubizjak@...il.com>, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] x86: predict __access_ok() returning true


* Mateusz Guzik <mjguzik@...il.com> wrote:

> On Tue, Apr 1, 2025 at 10:43 PM Ingo Molnar <mingo@...nel.org> wrote:
> >
> >
> > * Ingo Molnar <mingo@...nel.org> wrote:
> >
> > > It's also the right place to have the hint: that user addresses are
> > > valid is the common case we optimize for.
> > >
> > > Thanks,
> > >
> > >       Ingo
> > >
> > >  arch/x86/include/asm/uaccess_64.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
> > > index c52f0133425b..4c13883371aa 100644
> > > --- a/arch/x86/include/asm/uaccess_64.h
> > > +++ b/arch/x86/include/asm/uaccess_64.h
> > > @@ -54,7 +54,7 @@ static inline unsigned long __untagged_addr_remote(struct mm_struct *mm,
> > >  #endif
> > >
> > >  #define valid_user_address(x) \
> > > -     ((__force unsigned long)(x) <= runtime_const_ptr(USER_PTR_MAX))
> > > +     likely((__force unsigned long)(x) <= runtime_const_ptr(USER_PTR_MAX))
> >
> > Should we go this way, this is the safe macro variant:
> >
> >    #define valid_user_address(x) \
> >         (likely((__force unsigned long)(x) <= runtime_const_ptr(USER_PTR_MAX)))
> >
> 
> Note the are 2 tests and the other one does not get covered by *this* likely:
> valid_user_address(sum) && sum >= (__force unsigned long)ptr;
> 
> as in sum >= ptr is left be.
> 
> However, I confirmed that with your patch the issue also goes away so
> I guess it is fine.
> 
> I think it would be the safest to likely within valid_user_address()
> like in your patch, and likely on the entire expression like in mine.
> 
> That said, there will be no hard feelz if you just commit your patch
> and drop mine.

Feel free to turn it into a Co-developed-by patch:

  From: Mateusz Guzik <mjguzik@...il.com>
  ...

  Co-developed-by: Ingo Molnar <mingo@...nel.org>
  Signed-off-by: Ingo Molnar <mingo@...nel.org>
  Signed-off-by: Mateusz Guzik <mjguzik@...il.com>

Because all I did was to transform your fix into something a bit more 
maintainable. I didn't even test it.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ