Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1599020rwl; Wed, 29 Mar 2023 21:41:23 -0700 (PDT) X-Google-Smtp-Source: AKy350bdvknY4T23EutgmB4wxHN7CL7M495MYMuvQpTB18t0MA1gh3oBSep8kYXzifoufQTfbUSV X-Received: by 2002:a05:6a00:194e:b0:62a:5ae:3012 with SMTP id s14-20020a056a00194e00b0062a05ae3012mr1033906pfk.1.1680151283620; Wed, 29 Mar 2023 21:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680151283; cv=none; d=google.com; s=arc-20160816; b=hzNDrG8nNKsdWGGXEsa9WHkuGDJ8HQenZt2RxFaR6YZn6MUeUgJzW5mT71l3E2C2ZA ZZpKp7yhgnjzvygExJE7pgbAd0tL0wGZj3rEj06HsRcaBp6ssZinoXKhyzs8DUiayXtJ zx8tY4P0qkprTAI+n1btxAyom3HZ2E919vYKnZVPkmA09pyW6BDO+tjI+xoDAmHJRFgV pNkhaKE/aVoPbiHi9Yd2AvRuNl3KIgvWNEhywlsgnTzaUas8fPSIB9ewZTVY4N0MTQLu PyWCUBm3K4x60Fvz8Sj3nbQybwP9OOYIzSK427BqXYcvco1WGGtK+LGLdJsYZl0BQIhA Jzyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=7v9P1XQ2IsfaOpFQO1XMCg59C4NbmctoVAztoQeGuiI=; b=ETa7r7e1VzyUOJk5BFSU31kaJ13QRLOueutf8trjkO6IaUkmEWwkbb8GEQq3eIjrPt 5L2x5JRfGu8KOs0hFbG3LqYSdwSI/xK/jkxOKc906e50TLeejlYclrf/z7U5uq9K1aXa NbuKyfaT99EXPfWmvivYeBspYkiJmYgjrLtRU6jz+QlULk0t3744L+z8HvkkhbRsWlsT 1FXn/404CI5DVc2fL+Wtrev/4mjKXiVi/Kc+ElV2K59xvVH/Q2mXyXZzulK4lpjHFn0u G5zzDW3k7VbU3AwZNA//YRH6ojZz0kWgCX8G8jZdGzM37Gdqdw0K8eN9/q7KB5fPwWE2 PsXQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a15-20020a056a000c8f00b00625c6092a12si34774858pfv.215.2023.03.29.21.41.11; Wed, 29 Mar 2023 21:41:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229788AbjC3EdB (ORCPT + 99 others); Thu, 30 Mar 2023 00:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjC3Ec7 (ORCPT ); Thu, 30 Mar 2023 00:32:59 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B840B10F2; Wed, 29 Mar 2023 21:32:57 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxJIT4ECVklDcUAA--.31182S3; Thu, 30 Mar 2023 12:32:56 +0800 (CST) Received: from [10.130.0.102] (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxLuT1ECVkA_oQAA--.48468S3; Thu, 30 Mar 2023 12:32:55 +0800 (CST) Subject: Re: [PATCH] LoongArch: Add kernel address sanitizer support To: Andrey Konovalov Cc: Jonathan Corbet , Huacai Chen , Andrew Morton , Alexander Potapenko , Dmitry Vyukov , Vincenzo Frascino , WANG Xuerui , Jiaxun Yang , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-mm@kvack.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Andrey Ryabinin References: <20230328111714.2056-1-zhangqing@loongson.cn> From: Qing Zhang Message-ID: <2360000f-7292-9da8-d6b5-94b125c5f2b0@loongson.cn> Date: Thu, 30 Mar 2023 12:32:53 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8CxLuT1ECVkA_oQAA--.48468S3 X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoWrKF4xGryxJF48Aw18Ww4UJwb_yoW8Jr4rpa 40kF95trsYyFn2vwn2kw1rtryjyF1fury3WFn8Kw1Fya4Y9Fy8KF1rGa4rCFykXrWxGw1Y vwnFyasxJr4UAaDanT9S1TB71UUUUbUqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bqkYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E 87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0V AS07AlzVAYIcxG8wCY1x0262kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCF s4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI 8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41l IxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIx AIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jz5lbUUUUU= X-Spam-Status: No, score=-0.0 required=5.0 tests=NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS autolearn=unavailable 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 2023/3/30 上午10:55, Andrey Konovalov wrote: > On Thu, Mar 30, 2023 at 4:06 AM Qing Zhang wrote: >> >>> But I don't think you need this check here at all: addr_has_metadata >>> already checks that shadow exists. >>> >> On LongArch, there's a lot of holes between different segments, so kasan >> shadow area is some different type of memory that we concatenate, we >> can't use if (unlikely((void *)addr < >> kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) to determine the >> validity, and in arch/loongarch/include/asm/kasan.h I construct invalid >> NULL. > > I get that, but you already added a special case for > __HAVE_ARCH_SHADOW_MAP to addr_has_metadata, so you can just call it? > ok, all the changes are going to be in v2. Thanks, -Qing >> This is because in pagetable_init on loongarch/mips, we populate pmd/pud >> with invalid_pmd_table/invalid_pud_table, > > I see. Please add this into the patch description for v2. > >> So pmd_init/pud_init(p) is required, perhaps we define them as __weak in >> mm/kasan/init.c, like mm/sparse-vmemmap.c. > > Yes, this makes sense to do, so that KASAN doesn't depend on > definitions from sparse-vmemmap.c. > > Thank you! >