Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2792208rda; Wed, 25 Oct 2023 12:23:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7cK0TVR3NlOme2rDHIYZTZUNwy4hg/3Fu/xxxXcR/CNA+tCOiQbFHnZht9jEtCxppbOq1 X-Received: by 2002:a9d:6398:0:b0:6c6:42ca:ed52 with SMTP id w24-20020a9d6398000000b006c642caed52mr15881908otk.30.1698261800449; Wed, 25 Oct 2023 12:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698261800; cv=none; d=google.com; s=arc-20160816; b=Jx8vG+0yAUHa8sMwQTh103k9aqDwRXLj5eGz5tHGabPAy7sE7dz+DjdMibaWUfDmHJ KHdEPQ73ljUgGglHuYIw/NhZyjVk2rMRfUMBFZftmBNUBNCbMAVzq/da6dCeJtLrKj7a oC2YlS8nmG6gMJFxzPOtcLcCfQCsWViJFHhRezUCd+qUqKqIRVfCPERjjSU6D/fYDNOQ Fqs3oE62U2jcBDTYVONbfWIXREY0xVEoJ/5PF2RVgSVy7/EYfLehI1rMhRYxdAhlDZ0/ wJL3MvlQFDikVI2THg3NH/ZMf63uOaNlue6aU7ZTrEkqZKk5bzNLjbrIZ+LfVThBKIXg Xwew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=m31BwFRcj7ARX8+GTG5pwS7sZOyZiRPn3jP/pVTMYz0=; fh=bXbkd7/+5kCLj5YiCl0KGrLGKDjHOrZ79PVvPym773w=; b=b+mDiF7D/uFieyRkCa2IXNtvqZKgELjGNmU365d4aK2KIgapzOVfGUaqPPy/nlLAIW urXdW2WyPXIsf1Rd1yfpT30bCSXdxjPjkNUVLYSqHlPU6s3880/L+uBSlICjgkcA55Da W6oSaEzbNErfE+sU5pSRR0D2as2FaYlsbM2WcDBaRX55cnFx4NYJOEFUiKcM6Ayt6Vzn 5D+IrkLyTqkqbQ5NYrYQ5UcSqjy37FuuNLgVLrWeIBmw6EuJA3mhB6prnRP5Ict4VGzu GsF4TGC4XR213z53KPxOannCDSKWumycPeXbwHbgeoT047QEEXq8luIsfy8JruDgWlDC WqKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ahuPfTwq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id h185-20020a8153c2000000b005a20efa02dbsi11445536ywb.455.2023.10.25.12.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 12:23:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ahuPfTwq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CA4D6802A366; Wed, 25 Oct 2023 12:23:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229576AbjJYTXH (ORCPT + 99 others); Wed, 25 Oct 2023 15:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjJYTXG (ORCPT ); Wed, 25 Oct 2023 15:23:06 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 063AA13A for ; Wed, 25 Oct 2023 12:23:05 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bdf4752c3cso213985ad.2 for ; Wed, 25 Oct 2023 12:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698261784; x=1698866584; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=m31BwFRcj7ARX8+GTG5pwS7sZOyZiRPn3jP/pVTMYz0=; b=ahuPfTwqVORFjm/TB3m4v69p5BB83Y2ZeIJaTziuCKOsehESlAF/vvLE12r1ly2xEN nxQNEX6tde6GLWmwYtBYGc8bFzU6Hu1Vqlaf33ccrGj1wBQeTCyMayNQgkAYreBX1udh l4a+bmNwhieaE+XofASqbK/kBHMQMmz47l+PeEp+DftYKpwCM2o0pzvtGdJUAncFXPP3 9ERw6EBbeJgvhioc6swNKiHz5riheXQGX41Dy0gVKsubLj07FIeZIIQOkqTPCAp6MXVV iNy4EThOKFHMeGGRbGNF/KZOymBEYUo3JUVHU/cC1dQ8jGH9bE9ivNT2uxMXi9npeqV+ Hx4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698261784; x=1698866584; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m31BwFRcj7ARX8+GTG5pwS7sZOyZiRPn3jP/pVTMYz0=; b=Y4fjG1YmxRaFRXFbUGHiG0w0CB9hL+zBhF/69aadjvzW6F8cVYyYOX4SfByY1awQqJ snGbLa9gYH9MFY4lpm3XZKlBvHWkcGPTQrepoLI5D0mXwsZHo8/28NvrqOVaTQ2TJqRp XBPVdaKKp98onRzvN2gLL7R5J4gOxGCJW0Xl5xTNvMlIfGniWLD3+fApd0XjF6RlY44f 1IM5Z8tcNlvqN9c+vHN7ICWJ5QmTvWm/ssSDgv9kqg4crNTnyyuQwnFsrps6+8mJp8bE 0Wssjj1Io2lHn1GKCwWUGcjEDdBVJhMVDXGd3OuplRYmvIhzMMjav2hlsQHpFC9/f0jU 2i+g== X-Gm-Message-State: AOJu0YyasC+ndjdIB+XPI0GNs8ABXP0tqBQHNxqADV6RuEvTTFmuS66q I8a3Ll44d8DcLm/2l3OFv+ly2AyXwpwUBl8U7rE= X-Received: by 2002:a17:90b:1b49:b0:27d:4513:9c99 with SMTP id nv9-20020a17090b1b4900b0027d45139c99mr14243752pjb.17.1698261784445; Wed, 25 Oct 2023 12:23:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Wed, 25 Oct 2023 21:22:53 +0200 Message-ID: Subject: Re: [RFC] mm/kasan: Add Allocation, Free, Error timestamps to KASAN report To: Juntong Deng 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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 12:23:18 -0700 (PDT) On Tue, Oct 17, 2023 at 9:40=E2=80=AFPM 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.