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 ED3F2C433F5 for ; Sat, 25 Dec 2021 12:00:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68F366B0073; Sat, 25 Dec 2021 07:00:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63F506B0075; Sat, 25 Dec 2021 07:00:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 508556B0078; Sat, 25 Dec 2021 07:00:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id 3CACA6B0073 for ; Sat, 25 Dec 2021 07:00:26 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D29FA181AC9CC for ; Sat, 25 Dec 2021 12:00:25 +0000 (UTC) X-FDA: 78956174010.22.7B1ABB3 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf10.hostedemail.com (Postfix) with ESMTP id D6E85C0038 for ; Sat, 25 Dec 2021 12:00:16 +0000 (UTC) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JLjCx00W9zcc1r; Sat, 25 Dec 2021 19:59:56 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 20:00:22 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 20:00:21 +0800 Message-ID: <4b4f142a-8d32-e6f5-b9ff-8905bcefb77d@huawei.com> Date: Sat, 25 Dec 2021 20:00:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] Revert "mm/usercopy: Drop extra is_vmalloc_or_module() check" Content-Language: en-US To: Nicholas Piggin , Andrew Morton , Benjamin Herrenschmidt , Christophe Leroy , Kees Cook , Laura Abbott , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linuxppc-dev@lists.ozlabs.org" , Mark Rutland , "Michael Ellerman" , Paul Mackerras References: <20211223102126.161848-1-wangkefeng.wang@huawei.com> <96fe1826-aeaf-4ea0-9f01-03d6b3933b34@huawei.com> <6e2ddc83-bec3-fdd4-4d91-3ade0de0b7c8@csgroup.eu> <1640429980.38ev9qg7xc.astroid@bobo.none> From: Kefeng Wang In-Reply-To: <1640429980.38ev9qg7xc.astroid@bobo.none> Content-Type: text/plain; charset="UTF-8"; format=flowed X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggeme714-chm.china.huawei.com (10.1.199.110) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Queue-Id: D6E85C0038 X-Stat-Signature: qyzsrfzc91jp3g781rpgd1azzdmr5opc X-Rspamd-Server: rspam04 X-HE-Tag: 1640433616-674493 Content-Transfer-Encoding: quoted-printable 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 2021/12/25 19:04, Nicholas Piggin wrote: > Excerpts from Kefeng Wang's message of December 25, 2021 12:05 pm: > ... >>> Can you try that ? >>> >>> #define virt_addr_valid(kaddr) ((kaddr & PAGE_OFFSET) =3D=3D PAGE_OFF= SET && >>> pfn_valid(virt_to_pfn(kaddr))) >> I got this commit, >> >> commit 4dd7554a6456d124c85e0a4ad156625b71390b5c >> >> Author: Nicholas Piggin >> Date:=C2=A0=C2=A0 Wed Jul 24 18:46:37 2019 +1000 >> >> =C2=A0=C2=A0=C2=A0 powerpc/64: Add VIRTUAL_BUG_ON checks for __va an= d __pa addresses >> >> =C2=A0=C2=A0=C2=A0 Ensure __va is given a physical address below PAG= E_OFFSET, and __pa is >> =C2=A0=C2=A0=C2=A0 given a virtual address above PAGE_OFFSET. >> >> It has check the PAGE_OFFSET in __pa,=C2=A0 will test it and resend th= e >> patch(with above warning changes). > What did you get with this commit? Is this what causes the crash? I mean that your patch does the check to make sure the virt addr should=20 above PAGE_OFFSET, and we can add the check in the virt_addr_valid too. > > riscv for example with flatmem also relies on pfn_valid to do the right > thing, so as far as I can see the check should exclude vmalloc addresse= s > and it's just a matter of virt_addr_valid not to give virt_to_pfn an > address < PAGE_OFFSET. > > If we take riscv's implementation > > diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm= /page.h > index 254687258f42..7713188516a6 100644 > --- a/arch/powerpc/include/asm/page.h > +++ b/arch/powerpc/include/asm/page.h > @@ -132,7 +132,10 @@ static inline bool pfn_valid(unsigned long pfn) > #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) > #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) > =20 > -#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr)) > +#define virt_addr_valid(vaddr) ({ = \ > + unsigned long _addr =3D (unsigned long)vaddr; = \ > + (unsigned long)(_addr) >=3D PAGE_OFFSET && pfn_valid(virt_to_pf= n(_addr)); \ > +}) Yes, I send a new v2=C2=A0 with this change, thanks > =20 > /* > * On Book-E parts we need __va to parse the device tree and we can't > > .