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] [day] [month] [year] [list]
Message-ID: <CA+=Fv5TwwXiAdqUuUOPnwHTWz15Bj2UsGP=7+SQRM0MDXKnopg@mail.gmail.com>
Date: Mon, 17 Feb 2025 11:54:05 +0100
From: Magnus Lindholm <linmag7@...il.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: richard.henderson@...aro.org, mattst88@...il.com, 
	glaubitz@...sik.fu-berlin.de, ink@...een.parts, kees@...nel.org, 
	arnd@...db.de, linux-kernel@...r.kernel.org, linux-alpha@...r.kernel.org
Subject: Re: [PATCH 1/1] alpha: Fix pte_swp_exclusive on alpha

Hi,

Making pte_swp_exclusive return bool is a neat solution! As Al pointed out,
it will better reflect how pte_swp_exclusive is actually used in the code.
I assume we would want this for all architectures implementing
pte_swp_exclusive? This implies that this change will have a wider
impact and not be an alpha specific fix.
I can prepare and post a v2 of this patch using this approach.

Magnus

On Sun, Feb 16, 2025 at 6:17 PM Al Viro <viro@...iv.linux.org.uk> wrote:
>
> On Sun, Feb 16, 2025 at 06:04:53PM +0100, Magnus Lindholm wrote:
> > Function pte_swp_exclusive() checks if _PAGE_SWP_EXCLUSIVE bit is set in
> > PTE but returns lower 32-bits only. Shift bits right by 32 to return upper
> > 32-bits of PTE which contain the _PAGE_SWP_EXCLUSIVE bit. On alpha this is
> > bit 39 but on most other architectures this bit already resides somewhere
> > in the first 32-bits and hence a shift is not necessary on those archs.
>
> Just make it return bool and be done with that - all users are either
> if (pte_swp_exclusive(...)) or if (!pte_swp_exclusive(...)) or assignments
> to bool variable.
>
> No need to shift anything - compiler probably will figure out that
>         if ((int)((x & (1UL<<39)>>32)))
> is equivalent to
>         if (x & (1UL<<39))
> but why bother with such convolutions in the first place?
>
> Seriously, just make it
>
> bool pte_swp_exclusive(pte_t pte)
> {
>         return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
> }
>
> and that's it - conversion from arithmetical types to bool will do the right thing.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ