Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2132634rdh; Sun, 29 Oct 2023 02:06:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/j04KcJENx9OAHkfIn8tb7uUjD6QE1SdTzEfNpaobP0Kpl8F+XOnIWC3Z3nkiqPy+HHi2 X-Received: by 2002:a17:902:e74e:b0:1cb:fcfb:61af with SMTP id p14-20020a170902e74e00b001cbfcfb61afmr12503671plf.30.1698570385403; Sun, 29 Oct 2023 02:06:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698570385; cv=pass; d=google.com; s=arc-20160816; b=O0Ohm6syIxgKG10p2WuTJ8JQNCyyxDsTDRdak44YC7cdVvWwMyafTp3++gAwhiOmLg lJoulTRicEfPOsIUU95vh4+TyuRlPQ2ZUGDGuCXQYlikwp9nkMWRSK2P74XwZRL/Dqe3 IlDLVx6Ec0HHopsRtN8AkDer9iV5hESbeOi53ThywzuwrrYBF850AcLnNekAegY1PKqQ 52vsr4x0AVg3bsEg2PWtqjMu0Fp/zwbbZwzBtaIuAHdfwmNjMYrDcL9Y4YZlOi0VtvbM pnI8Ui/qh1PQGUpSNxFreEgYsNLJ23GH5Dzpx8BAAGQ8PWCsv+LEksEMVi7PNXrfcv8W Rw0A== 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:subject:user-agent:date :message-id:dkim-signature; bh=BcwMR/IiMmMF1IndFxlrpqJNTzSSs2/w/qmy+PcxA3o=; fh=22ucgggqjLa4fRcph1tw6FvM//txr3YHf3uIC6vaA78=; b=DxUxUt7BYUZJ/y22d5H11SkDIiS7Ost7YRayi8Of88SxeakgaiKLNoO/LDekz86ICJ ks7Qxwlcz0LMBWFJ4t294Qqgj44Ytvlh/TpcxapvB8yD4UfPQteS9zNR8JZAKArtBGrb Sj8w1fRx5trRcHkJ9q3WbWCNpkjqVfTwfeyKu8ljkEb2rcz/me6Qdr3zcr4sec+bajv0 A+5oj18YSE73EEA7e25Y/k+jkPIxGwPZKKN3rZW8GV1MYu+b6SRFW2+jZ7hJ/0tbiVMC n++zR1VSaS/hcAy3sZ9JwxgPSJgNnlBBAKhZ9M+fsFU45wrs6Eg1G/osVjXVXVohLJf7 J4Rw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Y6x7U5dJ; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c18-20020a170903235200b001b973681493si2080597plh.16.2023.10.29.02.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 02:06:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Y6x7U5dJ; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E266B805935E; Sun, 29 Oct 2023 02:06:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229679AbjJ2JGA (ORCPT + 99 others); Sun, 29 Oct 2023 05:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjJ2JF7 (ORCPT ); Sun, 29 Oct 2023 05:05:59 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2036.outbound.protection.outlook.com [40.92.59.36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77213CF for ; Sun, 29 Oct 2023 02:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTsRuNwZWOw9s/zmBwyVsdN7ICK0E5YNWi/TQgmgvsKI6RgPc1yngVCqULzDbnJ4B019xPGyrRhGEmTh5YX2pJXY4fXGkkVflsb9gXbfPD8z1ipuYQniG1E1mH2TUsa/TRVGUp0E9cgK2AVc+VP675N3tJOyCAJJXUkoklp06rSnZqHXNNNfPNLfz8/Ia5zy9QsqoAubq/FvAHh0pJNmejPGRMUgb8g2UTc0ToZSzdmaSF2EoRC/IJdDaHIcUYEWiM+vkEfClSC+69DId8DN8zF+Zduc50hDNCZfF+oHHx8ipRj/NZDVV297yAn22s9FY/9PjnY22jYNl0bP4CWi7Q== 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=BcwMR/IiMmMF1IndFxlrpqJNTzSSs2/w/qmy+PcxA3o=; b=COUz0dhvyYJ/5dim8K8HgeLiJoTM8VVn/5t5na1RT35gtRuhsYLd3YucEN/4Rs8P8YYV3h896EtdE7+tuZ/nS5v9xm8NcX/EQJUBLBc4zSNUjUtjSdqZdgYtlEfYwfQe+iyHLLaX8gt/Y6DnhscpsNFArM52Pp5y0NYJNSy7BYMsItWRu7p2ft3xigu53pGoOXYkJQOeU5d6k9DmymuMiOnIByZeRIyz7LGb5NXdm7elQMJQrlKNyn2VBVnDk9UcB3MomH4cAnjroTnQfE0/VzLVpD08s2ouzD3QLtBLTVi0ewp5cBvSVDaTxGg+1h3pw7AiQdiO8g2Pil+J5cM4Mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BcwMR/IiMmMF1IndFxlrpqJNTzSSs2/w/qmy+PcxA3o=; b=Y6x7U5dJf1g8DPwt9h2ZpacBizQNc0GUPDCpzq16vgBXULOFVCV74UMlv3q+iJObdkBIGv1byhx5WKo0PD/MrK7A1yM7I0Dtydzrlf/qP2NWb7uqGvdVlFVKuBun0FPEEXIN8jgqBnIgKfLJcJNuxwprmuNF1+LResOH+AbyHL6B10v8ZD2kHQcSbXB3U55iYp/cjxvpBc0xgbs3wHQ0wmCI8GHBvdXLbYkPHfyVVRPK2t8YCkQZkHf+yKl32GSzTBbFob5VSmIffYh8+8zNcil27EIrR2yFtRMolhIXfS/81A53k6+0ZOk28QVrjOjztmLYPhIiWHuQFlY4Wdqtsw== Received: from VI1P193MB0752.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:32::19) by AS8P193MB2301.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:446::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26; Sun, 29 Oct 2023 09:05:54 +0000 Received: from VI1P193MB0752.EURP193.PROD.OUTLOOK.COM ([fe80::2db3:2c11:bb43:c6e]) by VI1P193MB0752.EURP193.PROD.OUTLOOK.COM ([fe80::2db3:2c11:bb43:c6e%5]) with mapi id 15.20.6933.025; Sun, 29 Oct 2023 09:05:54 +0000 Message-ID: Date: Sun, 29 Oct 2023 17:05:54 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [RFC] mm/kasan: Add Allocation, Free, Error timestamps to KASAN report To: Andrey Konovalov Cc: ryabinin.a.a@gmail.com, glider@google.com, dvyukov@google.com, vincenzo.frascino@arm.com, akpm@linux-foundation.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, "linux-kernel@vger.kernel.org" , "linux-kernel-mentees@lists.linuxfoundation.org" References: From: Juntong Deng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TMN: [X5MALjLVTbXzlHngHlRqibWkaWE/JXzO] X-ClientProxiedBy: LO2P265CA0140.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::32) To VI1P193MB0752.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:32::19) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0752:EE_|AS8P193MB2301:EE_ X-MS-Office365-Filtering-Correlation-Id: f9e62cf3-f40d-4a8c-1997-08dbd85e4166 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uR4YyAFowSATC08xdLw6JLLMjjBxztUZ4zgUEcgVueiKgEafB+LzlhlIwGW8rhWQMlyatYtmNdSzMsJZwk6VkgrXePDuhFo6mA2g7RtAZeFN3Iv6Wj5Jen4htN/nQjc6gKwmR+b5xt1aQMEr4qPElidviKWho4Q4n0I/2CwfFJr1U+QPVl5jmWJG73rcZJnKjq4GGI6a2FvbKkEAVvhw7ziO0TilLdVGItvYaWA+NkWkLTRWBbVmIJfUPgvS+PHpVtGj583Nc4Z+4j4nULhE0WvlD8O6azFcGXVoYesfCR/wybB+VwtLffdRSAeBGAqqj70VHlq9hT3cLFCe4gRBL9qMu2A0Xw+407gOr0c+ABRmEEmN/QqJOepfA9zP5vPRLqmqsliTUuBPWYDkK0xuTHWr0RX9C5+k/b+iDkLsxYJMAbMWxXOGL43Mgtw8zU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XJk?= =?utf-8?Q?XyCnZoD6MmDboJxROAGwAZwvdvlEctRhI7szVah+gSN0=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9e62cf3-f40d-4a8c-1997-08dbd85e4166 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0752.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 09:05:54.2744 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2301 X-Spam-Status: No, score=1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FORGED_MUA_MOZILLA,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 29 Oct 2023 02:06:23 -0700 (PDT) On 2023/10/26 3:22, Andrey Konovalov wrote: > On Tue, Oct 17, 2023 at 9:40 PM Juntong Deng wrote: >> >> The idea came from the bug I was fixing recently, >> 'KASAN: slab-use-after-free Read in tls_encrypt_done'. >> >> This bug is caused by subtle race condition, where the data structure >> is freed early on another CPU, resulting in use-after-free. >> >> Like this bug, some of the use-after-free bugs are caused by race >> condition, but it is not easy to quickly conclude that the cause of the >> use-after-free is race condition if only looking at the stack trace. >> >> I did not think this use-after-free was caused by race condition at the >> beginning, it took me some time to read the source code carefully and >> think about it to determine that it was caused by race condition. >> >> By adding timestamps for Allocation, Free, and Error to the KASAN >> report, it will be much easier to determine if use-after-free is >> caused by race condition. > > An alternative would be to add the CPU number to the alloc/free stack > traces. Something like: > > Allocated by task 42 on CPU 2: > (stack trace) > > The bad access stack trace already prints the CPU number. Yes, that is a great idea and the CPU number would help a lot. But I think the CPU number cannot completely replace the free timestamp, because some freeing really should be done at another CPU. We need the free timestamp to help us distinguish whether it was freed a long time ago or whether it was caused to be freed during the current operation. I think both the CPU number and the timestamp should be displayed, more information would help us find the real cause of the error faster. Should I implement these features?