From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5922DC28D13 for ; Mon, 22 Aug 2022 10:23:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2DA06B0073; Mon, 22 Aug 2022 06:23:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDD246B0074; Mon, 22 Aug 2022 06:23:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACD928D0001; Mon, 22 Aug 2022 06:23:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9FD9B6B0073 for ; Mon, 22 Aug 2022 06:23:58 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 708B1C07CF for ; Mon, 22 Aug 2022 10:23:58 +0000 (UTC) X-FDA: 79826842956.21.99268B9 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf24.hostedemail.com (Postfix) with ESMTP id 7A8E1180056 for ; Mon, 22 Aug 2022 10:23:56 +0000 (UTC) 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661163836; a=rsa-sha256; cv=none; b=K3BLwa3jBwddHGdhJ8sz0h2DdAGfnKYXFuuRkjaylFS7qbkrjEhoJxMiPzRBIX+LfcLv/x 44Wb+S/j8bzidvbOiPYt/IzYFsOXqOBZZkNLQAAM9JSmvCUHkz3Tjp2/ZxXQeEnTCCpUHT bGdRipR5kUD8ws4I55n731jn2JhdCyU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Jwax0idh; spf=pass (imf24.hostedemail.com: domain of muchun.song@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661163836; h=from:from:sender: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:dkim-signature; bh=7sUWj0QoiwczPOrvqaGIflyD1LOaHPYP2EjnSJtpq/w=; b=XZZFzK8rGEbJuxwfOz6SnPcE5hxl0pSXNh8Mb2h1ajF0bJm8unCrg8Wv829Nx3WJZteUKY 2KRSYw1sqD7Z5UkT4p0plIiHzZL2jCzXMV/u6V04lYuV0U6qqOxaU9yaGRuv2XUR2xQLgL 96XMFOvTI0X/AbrRRG2trafUJMqlOQw= X-Rspam-User: X-Stat-Signature: astxefd943w857gx138ggd3jyjpyo9ts X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7A8E1180056 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Jwax0idh; spf=pass (imf24.hostedemail.com: domain of muchun.song@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-HE-Tag: 1661163836-394147 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > 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