Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1888962rwn; Fri, 16 Sep 2022 02:20:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fnXtczCHuHd3/o5QlG95JEOuRtFV40Ah34pdmF+Z75zkZ+14++U0MBmpKIZqRVRDvY8ap X-Received: by 2002:a17:907:94d0:b0:77e:c2e5:a35e with SMTP id dn16-20020a17090794d000b0077ec2e5a35emr2965468ejc.648.1663320055010; Fri, 16 Sep 2022 02:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663320055; cv=none; d=google.com; s=arc-20160816; b=t4Zvc/zpqpJ3SBoSeTEBAoOVQgrNuyAT6NBGxuXYy3r8HudLUO+iUmW0Pt0XfPFAoS et2yzl/ZnNLlAY7Ce4KxVHYuukb8LS/xKRydSHSSjscqjNVN6erfthWYRO+8yrBKLfDd XBbc74ZingFIH6UTDc8gwkDzeKdTdRzx3uzjVpL+2tVcWdLvhXz8SlUwLOoRqxhM9uHj 4EMUPGwe2TUX0dzAfNgo7af1bej/zg5+ajc8xKL9DvmYkfPBCvnCz6k2tPah00CtYm96 c7vf1yAz46Pk+6U5mlqEpHPnx+MzYxu6+tyB21BAhExv6PV3NVBtHtP6oghg6oaw3aAj eNnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=St+IQCWJacJKbPUwjmk2zZiPvZUfUUJhCu0g3DwZrPg=; b=Y+os4bCRS0199ScwyjhNk53SWpgG1V4+oj8gTDSqVu/yJeMV7+uy0e4knIjl6ltP+H xbnbwNg9XYn+xsRDOuFVyZcr69L1tN/SVfvGYH+L2sX1DA1vXB05DoNonODXfCMS0Zbu zrW1Z9RLE3w2kCz2CmwHLoFck45KwvCps6Dt4INGE9OQucBvXK7j/lfHVwJdhM2sXMKm brMVEFZX3tE9Pe9WE2+7WQVMU7eMZKdCjSmVLiIgGgo9X2HOoq8pziNTah7w6dMWTlCN sYVs4gCxseJXNA+bOzZr3Sqc99m4kTtKzmpA+Wnhv6lvmoE/rnC8ozjObyrQcU67UdeG eneQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Tq8+3NsA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm22-20020a170907949600b0073d5b737a78si15630302ejc.752.2022.09.16.02.20.29; Fri, 16 Sep 2022 02:20:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Tq8+3NsA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbiIPJNY (ORCPT + 99 others); Fri, 16 Sep 2022 05:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231132AbiIPJNW (ORCPT ); Fri, 16 Sep 2022 05:13:22 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ECAE6FA33 for ; Fri, 16 Sep 2022 02:13:21 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-346cd4c3d7aso251871177b3.8 for ; Fri, 16 Sep 2022 02:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=St+IQCWJacJKbPUwjmk2zZiPvZUfUUJhCu0g3DwZrPg=; b=Tq8+3NsAcC3hZkWZbN2XInttxNbHcPBxQHaxd6kqBbQ+vcToc+f9RVGIsc931BWVYv 4QDsKLv0z+ustpPusPz/B9AlixdY/+20yLQ3Nb+Fa7rupRd0naGOVpYYufmEQtlM5DII sx51DqRcgBgYykDI/ks3MxB7qjaAYnoqogbo/7wSk2d8PHFC9DklV/sGJpb1YdiGvdgE cPjNWVgiTi2YeBUpLJNpIVMferIDI3FBXMUngw00uukIFnVZglD7gSlfWfoPoLRHl1sl niGM24A+pcobtBMSFxFNvKxFgeoq4A8ILvrdqwFIbIlpjTDArgzldYkHsYo+IATVq7eN 72WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=St+IQCWJacJKbPUwjmk2zZiPvZUfUUJhCu0g3DwZrPg=; b=rkxjndP0hjMCjDCipUFuCkTJJ9cEggSA5CT/HlkTnTtBSFPVXde6pjOVDrpGejlC09 p9zddxHkKOeTIkaOrJ9TAZiIcfM5R3cNd3xLyfpGHu3LU0Mp14tJozwXGkx7OBg5WVnx TJx2gxAk0DVjjH0KtozykVThC/lg6NxxaTEuwaWCMwjVXIo/K4tcZlo3fEtEM2aTDOrf CQF3j7vHML0YP4y6ET+M9rjhNwMVjN4wQBSTVRa1Lkp6jPCftLwDQ2P1kx+kyJqJj7PP bUKE17bdMGKYkwCp/eZppGqmcWTVAwAzObUAwb7zKc66rP0m2LL8B8PBYJ/3lfnZ+e16 XKSQ== X-Gm-Message-State: ACrzQf1P5Sp5KndF0UTKC/5SVuA0RbZ2zEBbZbdOEU8KFgYSY/I+qu2U YMRSEW+skC4wjbQCH6tbvqhelTtXQLTpKsSOewXsUg== X-Received: by 2002:a81:1409:0:b0:349:e8bb:1fdb with SMTP id 9-20020a811409000000b00349e8bb1fdbmr3573010ywu.299.1663319600558; Fri, 16 Sep 2022 02:13:20 -0700 (PDT) MIME-Version: 1.0 References: <20220915150417.722975-1-glider@google.com> <20220915150417.722975-28-glider@google.com> <20220915135838.8ad6df0363ccbd671d9641a1@linux-foundation.org> In-Reply-To: <20220915135838.8ad6df0363ccbd671d9641a1@linux-foundation.org> From: Alexander Potapenko Date: Fri, 16 Sep 2022 11:12:44 +0200 Message-ID: Subject: Re: [PATCH v7 27/43] kmsan: disable physical page merging in biovec To: Andrew Morton Cc: Alexander Viro , Alexei Starovoitov , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Biggers , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Stephen Rothwell , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev , Linux Memory Management List , Linux-Arch , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 15, 2022 at 10:58 PM Andrew Morton wrote: > > On Thu, 15 Sep 2022 17:04:01 +0200 Alexander Potapenko wrote: > > > 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. > > > > ... > > > > --- a/block/blk.h > > +++ b/block/blk.h > > @@ -88,6 +88,13 @@ static inline bool biovec_phys_mergeable(struct requ= est_queue *q, > > phys_addr_t addr1 =3D page_to_phys(vec1->bv_page) + vec1->bv_offs= et; > > phys_addr_t addr2 =3D page_to_phys(vec2->bv_page) + vec2->bv_offs= et; > > > > + /* > > + * Merging adjacent physical pages may not work correctly under K= MSAN > > + * if their metadata pages aren't adjacent. Just disable merging. > > + */ > > + if (IS_ENABLED(CONFIG_KMSAN)) > > + return false; > > + > > if (addr1 + vec1->bv_len !=3D addr2) > > return false; > > if (xen_domain() && !xen_biovec_phys_mergeable(vec1, vec2->bv_pag= e)) > > What are the runtime effects of this? In other words, how much > slowdown is this likely to cause in a reasonable worst-case? To be honest, I have no idea. KMSAN already introduces a lot of runtime overhead to every memory access, it's unlikely that disabling some filesystem optimization will add anything on top of that. Anyway, KMSAN is a debugging tool that is not supposed to be used in production (there's a big boot-time warning about that now :) ) --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Liana Sebastian Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg