Re: [PATCH v2 1/3] x86/mm: Fix potential overflow in user_pcid_flush_mask
From: Dave Hansen
Date: Fri Jun 06 2025 - 14:50:36 EST
On 6/6/25 10:10, Rik van Riel wrote:
> +/*
> + * With page table isolation, the user_pcid_flush_mask is used to indicate
> + * that the TLB for a process needs to be flushed when switching to user
> + * space. Broadcast TLB flushing uses more PCIDs, and a larger bitmap.
> + */
> +#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
> +# ifdef CONFIG_BROADCAST_TLB_FLUSH
> +# define CR3_AVAIL_PCID_LONGS ((1 << CR3_AVAIL_PCID_BITS) / BITS_PER_LONG)
> +# else
> +# define CR3_AVAIL_PCID_LONGS 1
> +# endif
> +#else
> +# define CR3_AVAIL_PCID_LONGS 0
> +#endif
Just so nobody goes and applies this...
I don't like how this looks. I'd much rather have the code be
concentrating on *bits* of ASID space rather than longs. I'm going to
rework this a bit.