On Mon, Oct 17, 2022 at 08:10:59PM -0400, Sasha Levin wrote: > From: Alexander Potapenko <glider@xxxxxxxxxx> > > [ 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/20220915150417.722975-28-glider@xxxxxxxxxx > Signed-off-by: Alexander Potapenko <glider@xxxxxxxxxx> > Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> > Cc: Alexei Starovoitov <ast@xxxxxxxxxx> > Cc: Andrey Konovalov <andreyknvl@xxxxxxxxx> > Cc: Andrey Konovalov <andreyknvl@xxxxxxxxxx> > Cc: Andy Lutomirski <luto@xxxxxxxxxx> > Cc: Arnd Bergmann <arnd@xxxxxxxx> > Cc: Borislav Petkov <bp@xxxxxxxxx> > Cc: Christoph Hellwig <hch@xxxxxx> > Cc: Christoph Lameter <cl@xxxxxxxxx> > Cc: David Rientjes <rientjes@xxxxxxxxxx> > Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> > Cc: Eric Biggers <ebiggers@xxxxxxxxxx> > Cc: Eric Biggers <ebiggers@xxxxxxxxxx> > Cc: Eric Dumazet <edumazet@xxxxxxxxxx> > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> > Cc: Ilya Leoshkevich <iii@xxxxxxxxxxxxx> > Cc: Ingo Molnar <mingo@xxxxxxxxxx> > Cc: Jens Axboe <axboe@xxxxxxxxx> > Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> > Cc: Kees Cook <keescook@xxxxxxxxxxxx> > Cc: Marco Elver <elver@xxxxxxxxxx> > Cc: Mark Rutland <mark.rutland@xxxxxxx> > Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> > Cc: Michael S. Tsirkin <mst@xxxxxxxxxx> > Cc: Pekka Enberg <penberg@xxxxxxxxxx> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> > Cc: Petr Mladek <pmladek@xxxxxxxx> > Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> > Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx> > Cc: Vegard Nossum <vegard.nossum@xxxxxxxxxx> > Cc: Vlastimil Babka <vbabka@xxxxxxx> > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> > --- > 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