Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2200553rwa; Mon, 22 Aug 2022 04:06:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4HDSO7TCL0KYt5Ah2LLYwrqzEIh6T3qUIErftBAV8nwlO/jwf3A0g07h1x3lmVuN7lzSLH X-Received: by 2002:a63:5d4e:0:b0:41d:2966:74e7 with SMTP id o14-20020a635d4e000000b0041d296674e7mr16178804pgm.526.1661166377974; Mon, 22 Aug 2022 04:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661166377; cv=none; d=google.com; s=arc-20160816; b=GeZ4d+H0IGykrny5/O9Fulw4VvBikHBZtUcDeMMLolcMRQsLXCo/iU53q+Q2lL5zct B6Z+SAdWkAJC45BGU01SOmBkWTqJRpz2qN+omaGApXfi8toX4VjIqoTpLQi9EWrNIwqe aknAJSRAiGV6swV7XZZjPZDQgapqVbyusThXftMcR0LoH7C7VpyqDlx4b0yFTHtlZ1tJ OCIE5u50uYp4fpx0k07kOs9xJlHWBp3dAcy9CegY4siCjFoiwfiu0uFDLio2UQh5VerK dLMyYtVFw215tN1UCellfJOMaLU6XfRagZtcQoNQas3V4ZtdJA7bexIi1zGgA3PcBN5i vevA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=7sUWj0QoiwczPOrvqaGIflyD1LOaHPYP2EjnSJtpq/w=; b=Xa0aUxTLtrJAQAx5Q5k7rs9/6nx73b3sKWoeWTwWEGJ1oKQmP1ZMjeR+KqmfnwxakG GCOx0LSPwsYI5jQq1nTHlxHaB0xbLbsSAWD5Jk0VxrlFjQaZgOhU0i0vTeSfd/4DXYhA rY8yYn9AGMuRVtNyJGqnZu6FaMihN/bpAZG132A55paxeEBrIiKRpCaNq2UQlW0fyRyM bF9OOBD2tuXi8sILzPJ4P99R/suB9tgK6S9kBdblonl1d/wJpejpbYySc0ybMKJpaDvf DF7Qnx306iStNfjzrFubgLvj7S7NsuHWaMRJ9TAs1CkL4q+lnXoP9cOmCVPijQf69l06 Hc/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Jwax0idh; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a637251000000b0040cc39c0357si11856626pgn.125.2022.08.22.04.06.06; Mon, 22 Aug 2022 04:06:17 -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=@linux.dev header.s=key1 header.b=Jwax0idh; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234347AbiHVKYB (ORCPT + 99 others); Mon, 22 Aug 2022 06:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233315AbiHVKX6 (ORCPT ); Mon, 22 Aug 2022 06:23:58 -0400 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ED661A04E for ; Mon, 22 Aug 2022 03:23:56 -0700 (PDT) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1661163834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7sUWj0QoiwczPOrvqaGIflyD1LOaHPYP2EjnSJtpq/w=; b=Jwax0idhozUqW6l7DlaZf1w5Na9Q73xbYWIimnaE5rzOPSXVAI/cq6JQxPDfpadg0q4x3F RraeEczejdbaLmzxMh2/vHJoYdlLD7tr16JodQeXu7xX/NpAtXkq68oBCn1gujZmlsRoW5 knxHLGSyF/q7EGJIAmhTs6B286U3N8o= MIME-Version: 1.0 Subject: Re: [PATCH 4/6] mm: hugetlb_vmemmap: add missing smp_wmb() before set_pte_at() X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Mon, 22 Aug 2022 18:23:27 +0800 Cc: Andrew Morton , Mike Kravetz , Muchun Song , Linux MM , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220816130553.31406-1-linmiaohe@huawei.com> <20220816130553.31406-5-linmiaohe@huawei.com> To: Miaohe Lin X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Aug 22, 2022, at 16:45, Miaohe Lin wrote: >=20 > On 2022/8/20 16:12, Muchun Song wrote: >>=20 >>=20 >>> On Aug 16, 2022, at 21:05, Miaohe Lin wrote: >>>=20 >>> The memory barrier smp_wmb() is needed to make sure that preceding = stores >>> to the page contents become visible before the below set_pte_at() = write. >>=20 >> I found another place where is a similar case. See = kasan_populate_vmalloc_pte() in >> mm/kasan/shadow.c.=20 >=20 > Thanks for your report. >=20 >>=20 >> Should we fix it as well? >=20 > I'm not familiar with kasan yet, but I think memory barrier is needed = here or memory corrupt > can't be detected until the contents are visible. smp_mb__after_atomic = before set_pte_at should > be enough? What's your opinion? I didn=E2=80=99t see any atomic operation between set_pte_at() and = memset(), I don=E2=80=99t think smp_mb__after_atomic() is feasible if we really need to insert a = barrier. I suggest you to send a RFC patch to KASAN maintainers, they are more familiar = with this than us. Thanks. >=20 > Thanks, > Miaohe Lin >=20 >=20