Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp4207764rwi; Wed, 2 Nov 2022 08:03:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XNamSsVFXShheQdVv0h9DuVe2Ym3hewVsF/7wc3ofSoXbHin+xg2ZjdDB54IUgVH5u1Pp X-Received: by 2002:a17:902:7c12:b0:186:8111:ade2 with SMTP id x18-20020a1709027c1200b001868111ade2mr25102307pll.111.1667401433590; Wed, 02 Nov 2022 08:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667401433; cv=none; d=google.com; s=arc-20160816; b=Nz1GIQiEMycmhzQYWNpeKRmK04uyMZ9e8BGmQqD7s3NFPtNtNhwIQgYatGtOm+Tn7x hil7CPZUXgiDjnnA+q6HpJa9+Q4ecAH/jKPA01zIMzIoH2f9HvKRG/RNi+d09Rnji1qM 4hPgtKpxxeuqHn6vmpZXTvc+nASmDG8OHKVfSHf6p4OqdIr+V6fMfaHie1oP7i2giayV 277XyGGZwAU3HOpuXTGmftsxJbs4gfwv5TGqPgzCt1AJDWct4LCcBjF4zvvrX65beLEB cX/i4VzayQmZkXb/ddVqvIV46xMK4+1XaqxyJWvqd3MJR7DP5YuewzwCnA021Et7AJ5/ juUA== 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=fvcd8aKkXATuRfEipojhsSmbkitfupBiLaEwnV78heo=; b=cLGiY+BgdLQhAkQTDFkr5JGyH8HiTex29WSt/+gJW2xJP/cM4BcLCja6idBlTzQFGM Ri8Bbn1BQnInH+4sR3HdaiLhhLNipuJFnlsdJ+dK/0eW516lU+ng1vfwLsQRAKPh9FCK UxrcU+4MmuRI7NfR3NFh0NE5uQFGIJrm1T0ymhFQ4sWjOnaQkA75a6R6JWX6eo04dnG2 fJfKBT3j2KR5wv3AoY7ZeVByP1tUwnt7BHz3zVWJlZpIOW+JOs5nE8+MXF3GA0nlWFGi k9XLElTgImZgP2LGPMo1BM0zOX0QH7a1F98fnr0omymbzFpUzSCVP49zIKetbdjWq6c4 2fLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jrxAY3Mg; 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 mh3-20020a17090b4ac300b0021414ac5caasi2877914pjb.124.2022.11.02.08.03.33; Wed, 02 Nov 2022 08:03:53 -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=jrxAY3Mg; 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 S229487AbiKBOb4 (ORCPT + 98 others); Wed, 2 Nov 2022 10:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbiKBObh (ORCPT ); Wed, 2 Nov 2022 10:31:37 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4787C2B19C for ; Wed, 2 Nov 2022 07:31:20 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id cl5so13187954wrb.9 for ; Wed, 02 Nov 2022 07:31:20 -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 :message-id:reply-to; bh=fvcd8aKkXATuRfEipojhsSmbkitfupBiLaEwnV78heo=; b=jrxAY3MgHeVIzcyiNPKtsXJk9dLguqghP/Fjfj+2bzpqzI8Prp73eTJhQjhB0ZFgnj ENkFqMekQANYww6qdtbL9fPFhaXN8sqUohuYgloCXlrnxY94ynjMY7v/GtVWYSyGfDDn qS2raTJYrrg6bpoLfy+Mm9I3Pe7Z+XR4H1igv3t80BCiwD8ZbSNUjfSDpImNN6LQYZW5 LA65QwR/6sBqIRaw62mH++XBTgi2BkxGzlprT7asQsa4ZCGo77VPfN1/LUROW6AFRuu7 koDCbwNY6WxkZbgrjHZwxSYViQQf0rwbw2gTK4aFN2KmlXQkad5K9XYDq5DY6UeMFUvb VBxg== 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:message-id:reply-to; bh=fvcd8aKkXATuRfEipojhsSmbkitfupBiLaEwnV78heo=; b=I9lXvbChMtAXNB8ICzbInaKpQA/kQyTAqLmEwwBFIrmcIBNbLykwEz09csgo91/D7O ZD3y9tWtOsQCjOieFxUd0Iue0lHdgmdEffdmQVmRL5UsRkPpssTvhF11m1MGiKlA4dik DMqNml1n+Opg74j7yOaD5ybqPfh5Qb8DQ6aDkMJQdr0iGJyfjoiN59ET2x/0HiGAEy3R AA6OGtQ5I6chc4GgwRLPhrCpPBqHVktfpEqGK85DKip++M+oYGg/Dxpu47j0kdI+qd40 ws/wX5AkPZ4H7oMplchHDQPlnIfyC6AzSLC2xraB9MzlxGVNkiqjCZ0koPmeleGkYMek TZUw== X-Gm-Message-State: ACrzQf3i7vM3X6vH4RkcfSKUuaML+Kdx58tckiIz/8mnaZPOHM9VcEmW ubj+63D2iRvV/vqyzfBxzODaH76jDD7BFZeppdrjNQ== X-Received: by 2002:a5d:4ac8:0:b0:236:781a:8d2d with SMTP id y8-20020a5d4ac8000000b00236781a8d2dmr15833263wrs.715.1667399478686; Wed, 02 Nov 2022 07:31:18 -0700 (PDT) MIME-Version: 1.0 References: <20221019170835.155381-1-tony.luck@intel.com> <20221021200120.175753-1-tony.luck@intel.com> <20221021200120.175753-2-tony.luck@intel.com> In-Reply-To: From: Alexander Potapenko Date: Wed, 2 Nov 2022 15:30:42 +0100 Message-ID: Subject: Re: [PATCH v3 1/2] mm, hwpoison: Try to recover from copy-on write faults To: "Luck, Tony" Cc: Miaohe Lin , Matthew Wilcox , Shuai Xue , "Williams, Dan J" , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , Naoya Horiguchi , Andrew Morton 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 Wed, Nov 2, 2022 at 3:27 PM Alexander Potapenko wrot= e: > > On Fri, Oct 28, 2022 at 6:14 PM Luck, Tony wrote: > > > > >> + vfrom =3D kmap_local_page(from); > > >> + vto =3D kmap_local_page(to); > > >> + ret =3D copy_mc_to_kernel(vto, vfrom, PAGE_SIZE); > > > > > > In copy_user_highpage(), kmsan_unpoison_memory(page_address(to), PAGE= _SIZE) is done after the copy when > > > __HAVE_ARCH_COPY_USER_HIGHPAGE isn't defined. Do we need to do someth= ing similar here? But I'm not familiar > > > with kmsan, so I can easy be wrong. > > > > It looks like that kmsan_unpoison_memory() call was added recently, aft= er I copied > > copy_user_highpage() to create copy_mc_user_highpage(). I'm not familia= r with > > kmsan either. Adding Alexander to this thread since they added that cod= e. > > > > Given that copy_mc_user_highpage() replaces one of the calls to > copy_user_highpage(), it sure makes sense to call > kmsan_unpoison_memory() here. > > KMSAN tracks the status (initialized/uninitialized) of the kernel > memory. Newly allocated memory is marked uninitialized, copying memory > preserves its status, and writing constants to that memory makes it > initialized. > Userspace memory does not have its status tracked by KMSAN, so when > values are copied from the userspace, KMSAN does nothing with their > status. > That's why every (successful) copy_from_user event should be followed > by kmsan_unpoison_memory(), which marks the corresponding kernel > buffer initialized - otherwise the status of that buffer may get > stale. > > > > Anyway, this patch looks good to me. Thanks. > > > > > > Reviewed-by: Miaohe Lin Reviewed-by: Alexander Potapenko > > > > Thanks for the review. > > > > -Tony > > > > -- > 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 --=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