Re: [PATCH] x86/speculation/l1tf: fix overflow on l1tf_pfn_limit() on 32bit

From: Andi Kleen
Date: Mon Aug 20 2018 - 10:20:33 EST


On Mon, Aug 20, 2018 at 11:58:35AM +0200, Vlastimil Babka wrote:
> On 32bit PAE kernels on 64bit hardware with enough physical bits,
> l1tf_pfn_limit() will overflow unsigned long. This in turn affects
> max_swapfile_size() and can lead to swapon returning -EINVAL. This has been
> observed in a 32bit guest with 42 bits physical address size, where
> max_swapfile_size() overflows exactly to 1 << 32, thus zero, and produces the
> following warning to dmesg:
>
> [ 6.396845] Truncating oversized swap area, only using 0k out of 2047996k
>
> Fix this by using unsigned long long instead.

Looks good.

Acked-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>

BTW our much worse problems right now are crash reports on several
stable kernels, especially with large pages

I'll dig into this more today, but if you have any hints from testing/fixing
your own backports please share them.

-Andi