Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp5490rwi; Wed, 2 Nov 2022 08:44:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74sB0jK+13tdnnq+uKIxN9xf1lUfNUHGywBBhZzsl59Bwffretux8ihekHRk+DoSrOlw7c X-Received: by 2002:a17:902:d183:b0:186:8d50:75bb with SMTP id m3-20020a170902d18300b001868d5075bbmr25466662plb.159.1667403893112; Wed, 02 Nov 2022 08:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667403893; cv=none; d=google.com; s=arc-20160816; b=Mj/hXeUFC1CRh+5oeVEmMIypqFyeami1uOrApksxit0tIklPdnKDvy6XKs3CzvNB4k MRN3n8lctUvDy+lyxYeJJPYl5k2GtaNcWGP9hs72ba8A6w0eKC/BsjsyJe+Ytwi8dsQo Xcw5I3Zfg4ZN3QHNvfvvNO1qOT3BLhkVUP9aFxjqHR7GFR847CpujhMphBt7hWXVYfDf k7ieso12e36WGhF8t1scXxL42PXDEas/lrEaNhGxFrlKuVqGmkHmHeXoOpE2GYUmN8mT f2uar04MGnpWzpBRApj/qlHKur11fLT0fUVysOQpTnDlAWB9HJkb/mpUa87hENpO5RmP uxjw== 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=Y9Q0JUaa9L0FDTRBbRHtk7pORF5FI4qgSR7kELJhqR0=; b=rSEMCig0FfyS9qU//zmH1vo0J81tUuK/9EgmohwEjOnZAZdxhBlx4MdI3X7DN/LXBB fqmhMc+qXeGNGlNWNq7I/Osf+kyeB61dGV3hGLOmbcxBsfCm6ndIky/5PzyFPZl93/a4 3B34LsiO/KWuchNkFI9YUAzkmJnMXBRDndxIv3InQb8frSb9o+iKEhoxyTLWHEU6T2+z 1OKJTmvw/SBQBDBfYcrjvuy15iLX5ggj4M41/NqP+yOUuiHPmELesAh0QFBfrw6/AcyT quaOuu2DQ2mKvShb4htJAk2j+WzEEnDZSrUSOVmDwVbTfWR79/6PzrPE+QlR4Hxs7FFq HNKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YeDR6B6k; 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 23-20020a630317000000b0046f3dfb8821si15588982pgd.276.2022.11.02.08.44.35; Wed, 02 Nov 2022 08:44: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=YeDR6B6k; 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 S230364AbiKBO2g (ORCPT + 98 others); Wed, 2 Nov 2022 10:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbiKBO2c (ORCPT ); Wed, 2 Nov 2022 10:28:32 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6BF286D9 for ; Wed, 2 Nov 2022 07:28:28 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id v7so5006149wmn.0 for ; Wed, 02 Nov 2022 07:28:28 -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=Y9Q0JUaa9L0FDTRBbRHtk7pORF5FI4qgSR7kELJhqR0=; b=YeDR6B6k0057Cx5aXSoaJU/L1oqbxiIWfIcytTEuQKn8ua9kXxpp/FBg8c7GMpufTd 7GALet6uXxPZ7paxcBnR+iC6vKKCugT4P2jfcLM19gmosJHckL/BSvjORqaJlS1swxJw At0smbGcTxf0q6b64htT/WPu0/IcglEsTqXEaM9nHkaskjy6WqbBd5G6wAHVM6cVmxUt hPgjRCyhzqcQm6jC9EyVofwjWgK7ZrG9je7krios4rICKAYjT5+7XEYOxbanY+Ae8d2T TikB5IvjXbNL/1KsddzudxD5sOHytl2Ub7SfQEiIJ8AX1bicM2pZhC0MlnhxQc9bP+8w pzoA== 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=Y9Q0JUaa9L0FDTRBbRHtk7pORF5FI4qgSR7kELJhqR0=; b=VkzCL2+mfiBMBNm7VnprtCzpIkXbV4RRetM/HjEpLSg2duzOusFkGgsavtVm9NWr9p 2z4P7/ItWM3yu1i5woDvGYQao2URO10//sr5jK6aY49DyCF5HjjxtSDf6DCw30gM68oG HEZdDyBt9XHBp4eiqgXevGsCyDVXACYryfIE2Mlu8jE+u/VZ3mn8vq1jCoraI0uY8BDG wMj+B6zlcmvgKN40XR7tatU0NT6l6DiZjCHQkNipHwn8uD6ojYut8nAc0b68pFSFVEBp mY/OJZsQIqsy0qAUY31sBXP+/LZLHANHMC34c97bWpU6KAyJUsMlMSdtIlz9kz/76heM rpUA== X-Gm-Message-State: ACrzQf0h9MVwALqgqN5r55oeSboGSWinBAJWDfP1GfjuNsVz56p4qP1M LZGhukDj8e7UQCzzYGh3jHYK5Hs3z9eUZCR7GHL0AQ== X-Received: by 2002:a05:600c:1609:b0:3cf:4dc4:5a99 with SMTP id m9-20020a05600c160900b003cf4dc45a99mr16005402wmn.67.1667399307208; Wed, 02 Nov 2022 07:28:27 -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:27:50 +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 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_S= IZE) is done after the copy when > > __HAVE_ARCH_COPY_USER_HIGHPAGE isn't defined. Do we need to do somethin= g 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, after= I copied > copy_user_highpage() to create copy_mc_user_highpage(). I'm not familiar = with > kmsan either. Adding Alexander to this thread since they added that code. > 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 > > Thanks for the review. > > -Tony --=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