2022-10-18 00:47:11

by Eric Biggers

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 5.4 10/13] kmsan: disable physical page merging in biovec

On Mon, Oct 17, 2022 at 08:10:59PM -0400, Sasha Levin wrote:
> From: Alexander Potapenko <[email protected]>
>
> [ Upstream commit f630a5d0ca59a6e73b61e3f82c371dc230da99ff ]
>
> KMSAN metadata for adjacent physical pages may not be adjacent, therefore
> accessing such pages together may lead to metadata corruption. We disable
> merging pages in biovec to prevent such corruptions.
>
> Link: https://lkml.kernel.org/r/[email protected]
> Signed-off-by: Alexander Potapenko <[email protected]>
> Cc: Alexander Viro <[email protected]>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Andrey Konovalov <[email protected]>
> Cc: Andrey Konovalov <[email protected]>
> Cc: Andy Lutomirski <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: Christoph Hellwig <[email protected]>
> Cc: Christoph Lameter <[email protected]>
> Cc: David Rientjes <[email protected]>
> Cc: Dmitry Vyukov <[email protected]>
> Cc: Eric Biggers <[email protected]>
> Cc: Eric Biggers <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Herbert Xu <[email protected]>
> Cc: Ilya Leoshkevich <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Joonsoo Kim <[email protected]>
> Cc: Kees Cook <[email protected]>
> Cc: Marco Elver <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Cc: Matthew Wilcox <[email protected]>
> Cc: Michael S. Tsirkin <[email protected]>
> Cc: Pekka Enberg <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Petr Mladek <[email protected]>
> Cc: Stephen Rothwell <[email protected]>
> Cc: Steven Rostedt <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Vegard Nossum <[email protected]>
> Cc: Vlastimil Babka <[email protected]>
> Signed-off-by: Andrew Morton <[email protected]>
> Signed-off-by: Sasha Levin <[email protected]>
> ---
> block/blk.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/block/blk.h b/block/blk.h
> index ee3d5664d962..3358ef4244fe 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -79,6 +79,13 @@ static inline bool biovec_phys_mergeable(struct request_queue *q,
> phys_addr_t addr1 = page_to_phys(vec1->bv_page) + vec1->bv_offset;
> phys_addr_t addr2 = page_to_phys(vec2->bv_page) + vec2->bv_offset;
>
> + /*
> + * Merging adjacent physical pages may not work correctly under KMSAN
> + * if their metadata pages aren't adjacent. Just disable merging.
> + */
> + if (IS_ENABLED(CONFIG_KMSAN))
> + return false;
> +
> if (addr1 + vec1->bv_len != addr2)
> return false;
> if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2->bv_page))

So KMSAN is being backported to 5.4?

- Eric


2022-10-18 09:54:41

by Vlastimil Babka

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 5.4 10/13] kmsan: disable physical page merging in biovec

On 10/18/22 02:22, Eric Biggers wrote:
> On Mon, Oct 17, 2022 at 08:10:59PM -0400, Sasha Levin wrote:
>> From: Alexander Potapenko <[email protected]>
>>
>> [ Upstream commit f630a5d0ca59a6e73b61e3f82c371dc230da99ff ]
>>
>> KMSAN metadata for adjacent physical pages may not be adjacent, therefore
>> accessing such pages together may lead to metadata corruption. We disable
>> merging pages in biovec to prevent such corruptions.
>>
>> Link: https://lkml.kernel.org/r/[email protected]
>> Signed-off-by: Alexander Potapenko <[email protected]>
>> Cc: Alexander Viro <[email protected]>
>> Cc: Alexei Starovoitov <[email protected]>
>> Cc: Andrey Konovalov <[email protected]>
>> Cc: Andrey Konovalov <[email protected]>
>> Cc: Andy Lutomirski <[email protected]>
>> Cc: Arnd Bergmann <[email protected]>
>> Cc: Borislav Petkov <[email protected]>
>> Cc: Christoph Hellwig <[email protected]>
>> Cc: Christoph Lameter <[email protected]>
>> Cc: David Rientjes <[email protected]>
>> Cc: Dmitry Vyukov <[email protected]>
>> Cc: Eric Biggers <[email protected]>
>> Cc: Eric Biggers <[email protected]>
>> Cc: Eric Dumazet <[email protected]>
>> Cc: Greg Kroah-Hartman <[email protected]>
>> Cc: Herbert Xu <[email protected]>
>> Cc: Ilya Leoshkevich <[email protected]>
>> Cc: Ingo Molnar <[email protected]>
>> Cc: Jens Axboe <[email protected]>
>> Cc: Joonsoo Kim <[email protected]>
>> Cc: Kees Cook <[email protected]>
>> Cc: Marco Elver <[email protected]>
>> Cc: Mark Rutland <[email protected]>
>> Cc: Matthew Wilcox <[email protected]>
>> Cc: Michael S. Tsirkin <[email protected]>
>> Cc: Pekka Enberg <[email protected]>
>> Cc: Peter Zijlstra <[email protected]>
>> Cc: Petr Mladek <[email protected]>
>> Cc: Stephen Rothwell <[email protected]>
>> Cc: Steven Rostedt <[email protected]>
>> Cc: Thomas Gleixner <[email protected]>
>> Cc: Vasily Gorbik <[email protected]>
>> Cc: Vegard Nossum <[email protected]>
>> Cc: Vlastimil Babka <[email protected]>
>> Signed-off-by: Andrew Morton <[email protected]>
>> Signed-off-by: Sasha Levin <[email protected]>
>> ---
>> block/blk.h | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/block/blk.h b/block/blk.h
>> index ee3d5664d962..3358ef4244fe 100644
>> --- a/block/blk.h
>> +++ b/block/blk.h
>> @@ -79,6 +79,13 @@ static inline bool biovec_phys_mergeable(struct request_queue *q,
>> phys_addr_t addr1 = page_to_phys(vec1->bv_page) + vec1->bv_offset;
>> phys_addr_t addr2 = page_to_phys(vec2->bv_page) + vec2->bv_offset;
>>
>> + /*
>> + * Merging adjacent physical pages may not work correctly under KMSAN
>> + * if their metadata pages aren't adjacent. Just disable merging.
>> + */
>> + if (IS_ENABLED(CONFIG_KMSAN))
>> + return false;
>> +
>> if (addr1 + vec1->bv_len != addr2)
>> return false;
>> if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2->bv_page))
>
> So KMSAN is being backported to 5.4?

No, AUTOSEL is drunk and should drop the random kmsan patches for random
stable versions.

> - Eric