Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp436038rwe; Thu, 1 Sep 2022 01:56:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6yXwrZqNNyW+bD2tno2j1xCMQNdGfP6PqSpEed54/4mVX4cQoDTJ4rpdoe/YucI1EjLMCh X-Received: by 2002:a17:906:99c5:b0:73d:70c5:1a4f with SMTP id s5-20020a17090699c500b0073d70c51a4fmr22049460ejn.302.1662022619706; Thu, 01 Sep 2022 01:56:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1662022619; cv=pass; d=google.com; s=arc-20160816; b=0JCtlcAgYZQaMBxD2LHmzOMwh/R9YAp5aqUqVbX92HyA6plQ/i8V+4DHgfhwI46EUF 4qMwNoECfLr4DdXJIpEmRemVQWc/oAZOSALoUhxACstjbbf0EvT7N/Z08g43bif0QijX hES3CzLKg4/5FAngrdGlH16JXmgfAnSLYf+TqS1zTnPKXAjcAc43VesipTx4l+N5bXRO 7nm6ScPLQd2Rmna2beR7NsSEoCMwfdt6GBFhFfwkzZ/7Ss3oHc27R+zaEAr8bbhpiMy+ cR0hvvqGE5ddg6+xqSCJorb+5l3fseiFgLI75Kp4/8EoRokCc564j08TLEeyoVYOL5G3 iOkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=uhokj4qEhrWR2R5XusB+WLqCDAPCr0rwwaKcebjsgOI=; b=WQkrO4Y3/FyA0/VzyOVWoRw7pNlERE/PHxoAMiM4e8D/N3NgJ2Pf5olHr0xyIF9BQ5 7Z2O3YaSQR/GNLVaGf0tkC9OlRWnU+EHAZ1V+4lVFj8fLBzz4I9JFlsIkPSa1txsNn2K 6DDCpYqnaVTai5hGPytAWvdbq7KDNPyUV61dKJqBwfENN80YhlqDGvOIjeRSK7357GqC 8fPAzmDGf7pTmmzao+XqwVney3tnHT+DMLN15bN1zYLtsXze2f139uK/9hnbkmDx7iF+ nS0uey/ePyAxwKUVT4/wyqv7YdigGECvPOS6d30YSJPABYkez61OP5rYaJ4mlqSHRUO0 L47A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b="g/oVnBqL"; arc=pass (i=1 spf=pass spfdomain=nokia.com dkim=pass dkdomain=nokia.com dmarc=pass fromdomain=nokia.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a1709067ac400b0073d6277ca42si10908936ejo.201.2022.09.01.01.56.33; Thu, 01 Sep 2022 01:56:59 -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=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b="g/oVnBqL"; arc=pass (i=1 spf=pass spfdomain=nokia.com dkim=pass dkdomain=nokia.com dmarc=pass fromdomain=nokia.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233852AbiIAImJ (ORCPT + 99 others); Thu, 1 Sep 2022 04:42:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232804AbiIAImH (ORCPT ); Thu, 1 Sep 2022 04:42:07 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80111.outbound.protection.outlook.com [40.107.8.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA334130AB9 for ; Thu, 1 Sep 2022 01:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MjoYo/+BWCxBdwgj0gFTiI3nDAMOBX5M0e4SYO+IDGFU7j2b65E5BclHabTVaHL1sRUojAzJgD1YjkuOXZu8LhiiYYKv5BZpmtHOxeFxTJYyw7suCf15MzwSXgN73v7pdT1yZf/SVETDZN0FyHH90XMv6TxjeY2TU4PIFo1F4cFmVVYJe+JOgV54T9GwJ3R/sBdZyCS5Zv0dHh2RGlo/aTVQNusJOy05h5JX3p+Q0Ip84l5Mp/ROqGU5L20MW1epCee0w7NcgwVpJVZEF3mwGi9f34RVs6bzVceehtLgJLM89egQgDWRGbkAcDWJMPhJBvM+HStQCIseBK/T+Z3Zyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uhokj4qEhrWR2R5XusB+WLqCDAPCr0rwwaKcebjsgOI=; b=k4ZvYMGlbHWf4Ta5ZTXsPmGgUVqVw/5hycOrlFznjjZ580HA0gQ4NFBTvnrhjiZq6SUmy8t3TKcphlNkaX8zjVy3O+AwBsSEzjh2TolIKwZQz1HT0zcKBhTrSA4IQGd/o6zcOP2VyVK1uoElcjf2cJKWTcZ9pJikFKWGqkV/AK3MfU9kLZYYo1sKr9VjR5jQUpDiSRFn2FFIGgTxAHX9Jx8dgYVR5KGItFfMgiQiWybusHLJQcfWjYiXXpDVyup1NKMrw+O5T8BBMKfWa2KGdqP2V3ISod+KAuTa/pPHLifDImsrLTFax2yYd8mO9fYRHLG6hqE5YaQYjWziRlj9Lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uhokj4qEhrWR2R5XusB+WLqCDAPCr0rwwaKcebjsgOI=; b=g/oVnBqLJ57T3Dx4fzXhXxaYZL/C1gRj7yeUPBPhv+74//EAUK0AtgxLw4Y8a2HfuH4XQRRIbo6CGX9H6ezBR3QLXmPnvHO5oVtxLHH2ZNsLCuyJ5h9x6rwMWb2xvWle1BR7aMgWyUmQie6QTpHuu/+z05ZQEBZVIykAd3VESVw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from AS4PR07MB8658.eurprd07.prod.outlook.com (2603:10a6:20b:4cd::12) by AM8PR07MB8230.eurprd07.prod.outlook.com (2603:10a6:20b:325::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Thu, 1 Sep 2022 08:42:03 +0000 Received: from AS4PR07MB8658.eurprd07.prod.outlook.com ([fe80::b333:1f3b:1b01:50d9]) by AS4PR07MB8658.eurprd07.prod.outlook.com ([fe80::b333:1f3b:1b01:50d9%3]) with mapi id 15.20.5612.005; Thu, 1 Sep 2022 08:42:03 +0000 Message-ID: Date: Thu, 1 Sep 2022 10:41:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] ARM: kasan: Only map modules if CONFIG_KASAN_VMALLOC=n Content-Language: en-US To: Linus Walleij Cc: kasan-dev@googlegroups.com, Lecopzer Chen , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220827213009.44316-1-alexander.sverdlin@nokia.com> From: Alexander Sverdlin In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0094.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::14) To AS4PR07MB8658.eurprd07.prod.outlook.com (2603:10a6:20b:4cd::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR07MB8658:EE_|AM8PR07MB8230:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d10f890-ae24-4c8c-9aa5-08da8bf5d7c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rKsssqzQAOqqR2HjGsp0sFVz97vPnrS11HlnjSNIHBoqNFg1s1BZundSrm5p7XYLyI1olvGA9TxKrR/azIwYL+us9jaBsjiKTQQGD/6sQDqstuLvKtl0YyHBEJcMjDl8lqw+0S1QlyyI4Jmh3WS9H+sM4R/ukUcLeMTqcVlrhT94Rs3d+N0U5wzLq+sxBKOFdJPAmx2iHb/hvJfbzgHbr+KU9JL4Y/t3K/mYKh300FQR84Xp9IHw/TyFMP+ODopDldrw01TT+1PKYj3GoDkyLg8tpMhbYlPV8CYcsGyizdBy5evmDMyl8Diz6sa/3D1TSt4I7Ybbql1Mp3aZOxqUsT+VKNH8Nk67F/BG2INyxY3XyhVlkfBjpgtwFzlCaYxnH873TZf3b4P5rrnNoeof+pA/lM49IOu+aFxIY5u6PQFLD0ECGYC+Koi7Tc9+NKfqfH4sTxNQk184t1XQbN3Dah9Q2tM/TNtrpAFZ4gH3+LgYRgvFO9/aYpxCm/FqSVYefO5vJ2sLbFcC0Vpn43cXlE3od390NaThL2b0oFGpOWpQw9imnUb8MG30UQsXYh3VmxwgR0PE96cfwiMl2vmomLrJgtxKfgo5slY4JQGg3uROgXR9Vw90m6kDY8aBt39Cmf9f7zS6WHRUUKjNF6Kk0hZjQrBUnlmbRaI9AXw89frjYBVX3lUGoiDllHkXYiCPUuOM6dn5yWsCwPg0JqFtV20jlgYdF7rqhyFyr84OH41MNyn6ePJs68ksNz6rHNe7U6qUuL/6my7GJ8thD9w2krpBCP1P/Jo7kj9wEBNMjSqXrgKjrTXKGPZr2JFH8xk1imCH3fI61pqYuYU74b6AMw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS4PR07MB8658.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(39860400002)(346002)(376002)(366004)(396003)(66946007)(82960400001)(31696002)(66476007)(4326008)(66556008)(6916009)(2906002)(38100700002)(316002)(8676002)(54906003)(7416002)(8936002)(44832011)(6506007)(186003)(478600001)(2616005)(53546011)(5660300002)(86362001)(41300700001)(26005)(6486002)(6666004)(6512007)(31686004)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Q2ZGUUpKR3BEdzZxZDNUQkk4WjZsZ21QbzlsUDZ6LzU0UnFocDVOdkdFdCtF?= =?utf-8?B?dXQ5L00yb0w2RzhuNHhjelA0dkIxWlJQUEMyUTZVMVNJK2hEb1dZZTZGZldQ?= =?utf-8?B?VnJtd1JMN1RrYjByeCszaEs5WEYvREFaajhPRS9pZ0RqZ0JJVzR6U2FkOWFL?= =?utf-8?B?dlZSalN2MTRjdjgvaFp6UzJvU1h2dVArR0JPUU5LU0hPUUhKQXI2SGpEWmFM?= =?utf-8?B?WDh4QkdHaGdvamNTOGx2NFF4M2NVbFhrenFUa05nMXVQNEN0WjhEUlNZZUlt?= =?utf-8?B?Zjc3MXVJU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W9qV2RTQ1FscGF2RE5pak5S?= =?utf-8?B?QVV0N3ZOS3EreG1EWVRZTW1sQ0FHeXhXRlk2SDdoNlkzN0YzV2tjaVZiTTFy?= =?utf-8?B?bVE9PQ==?= X-OriginatorOrg: nokia.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8230 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hello Linus, On 31/08/2022 11:30, Linus Walleij wrote: >> - create_mapping((void *)MODULES_VADDR, (void *)(PKMAP_BASE + PMD_SIZE)); >> + if (!IS_ENABLED(CONFIG_KASAN_VMALLOC) && IS_ENABLED(CONFIG_MODULES)) >> + create_mapping((void *)MODULES_VADDR, (void *)(MODULES_END)); > So the way I understand it is that modules are first and foremost loaded into > the area MODULES_VADDR .. MODULES_END, and then after that is out, > they get loaded into VMALLOC. See arch/arm/kernel/module.c, module_alloc(). yes, but both areas are managed by __vmalloc_node_range(). > If you do this, how are the addresses between MODULES_VADDR..MODULES_END > shadowed when using CONFIG_KASAN_VMALLOC? That's the thing, __vmalloc_node_range() doesn't differentiate between address ranges and tries first to recreate [already existing] shadow mapping, and then vfree() unconditionally frees the mapping and the page. vmalloc() KASAN handling is generic, module_alloc() implemented via vmalloc() is however ARM-specific. Even though we could teach vmalloc() about MODULES_VADDR and MODULES_END (and don't call kasan_ instrumentation on these), but, this is ARM-specifics that it's used for this range. >> + create_mapping((void *)PKMAP_BASE, (void *)(PKMAP_BASE + PMD_SIZE)); > (Splitting this in two steps if probably good in any case.) > > Pls keep me on CC for Kasan ARM patches, thanks! (Maybe I should add some > MAINTAINERS blurb.) -- Best regards, Alexander Sverdlin.