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 085FBC433F5 for ; Thu, 25 Nov 2021 01:09:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68D6F6B0074; Wed, 24 Nov 2021 20:09:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63CBF6B0075; Wed, 24 Nov 2021 20:09:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5043A6B007B; Wed, 24 Nov 2021 20:09:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 4126E6B0074 for ; Wed, 24 Nov 2021 20:09:16 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 117CF8CA5E for ; Thu, 25 Nov 2021 01:09:06 +0000 (UTC) X-FDA: 78845668650.24.246E973 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf14.hostedemail.com (Postfix) with ESMTP id 3DC1E60019B2 for ; Thu, 25 Nov 2021 01:09:04 +0000 (UTC) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4J007m3PLPz1DJWs; Thu, 25 Nov 2021 09:06:28 +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; Thu, 25 Nov 2021 09:09:01 +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; Thu, 25 Nov 2021 09:09:00 +0800 Message-ID: <356d857b-1813-6132-d4ae-5bb41190a1a7@huawei.com> Date: Thu, 25 Nov 2021 09:08:59 +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 v3] mm: Defer kmemleak object creation of module_alloc() Content-Language: en-US To: Andrew Morton CC: Andrey Ryabinin , Dmitry Vyukov , , , , , , Catalin Marinas , Will Deacon , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Alexander Potapenko , Yongqiang Liu References: <20211124142034.192078-1-wangkefeng.wang@huawei.com> <20211124135014.665649a0bcb872367b248cef@linux-foundation.org> From: Kefeng Wang In-Reply-To: <20211124135014.665649a0bcb872367b248cef@linux-foundation.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggeme701-chm.china.huawei.com (10.1.199.97) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 3DC1E60019B2 X-Stat-Signature: 7azp1qfamyh6agq3xq9n4wcgisbwwuag Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Rspamd-Server: rspam02 X-HE-Tag: 1637802544-663740 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/11/25 5:50, Andrew Morton wrote: > On Wed, 24 Nov 2021 22:20:34 +0800 Kefeng Wang wrote: > >> Yongqiang reports a kmemleak panic when module insmod/rmmod >> with KASAN enabled(without KASAN_VMALLOC) on x86[1]. >> >> When the module area allocates memory, it's kmemleak_object >> is created successfully, but the KASAN shadow memory of module >> allocation is not ready, so when kmemleak scan the module's >> pointer, it will panic due to no shadow memory with KASAN check. >> >> module_alloc >> __vmalloc_node_range >> kmemleak_vmalloc >> kmemleak_scan >> update_checksum >> kasan_module_alloc >> kmemleak_ignore >> >> Note, there is no problem if KASAN_VMALLOC enabled, the modules >> area entire shadow memory is preallocated. Thus, the bug only >> exits on ARCH which supports dynamic allocation of module area >> per module load, for now, only x86/arm64/s390 are involved. >> >> Add a VM_DEFER_KMEMLEAK flags, defer vmalloc'ed object register >> of kmemleak in module_alloc() to fix this issue. >> > I guess this is worth backporting into -stable kernels? If so, what > would be a suitable Fixes: target? I suspect it goes back to the > initial KASAN merge date? The kasan_module_alloc() was introduced from v4.0, s390: v4.20 793213a82de4 s390/kasan: dynamic shadow mem allocation for modules arm64: v4.4 39d114ddc682 arm64: add KASAN support x86: v4.0 bebf56a1b176 kasan: enable instrumentation of global variables > .