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 X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 674D6C54E8D for ; Tue, 12 May 2020 14:03:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2717220752 for ; Tue, 12 May 2020 14:03:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QQawiJ16" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2717220752 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BAACB9000BB; Tue, 12 May 2020 10:03:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3495900036; Tue, 12 May 2020 10:03:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FB289000BB; Tue, 12 May 2020 10:03:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id 847F3900036 for ; Tue, 12 May 2020 10:03:19 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3985E5DF9 for ; Tue, 12 May 2020 14:03:19 +0000 (UTC) X-FDA: 76808234118.29.fifth52_1cef2afafeb0e X-HE-Tag: fifth52_1cef2afafeb0e X-Filterd-Recvd-Size: 5329 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 May 2020 14:03:18 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id r3so6435741qvm.1 for ; Tue, 12 May 2020 07:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HdL0PoelnNwC+IbWuQ/qzw1k9SeDaMleYXr87Z/Ant4=; b=QQawiJ16cJoOdX0v2O/nrybNFbweTZ9aWk/wAttBFTUWRgH/uywBEmgJJ3u+gYjdHG dIPfgBZVU75hHbpayW0czEXxkxEh/A5qfr1ZsTdqgRWFiK9+8OC+AWGCyOzUQUcbVeLK tHy1StevFR2QW2LRSkYwbXwSIJz8ZyEyRyjeRFgKDl9WCS++62M7d9VDQYbZW8ZQiy4N 8cn2evMhjL/a4EoYxDJEVZ72F+pdtNbnWyP+hHtRCCHCvn4NdY1ndpZBrX98ivNdAmNm UsrZjKOhnc6ozhKsb4K5sEE3WTthuFvFkcFoU1rmmii8PPNouLKmwZGVUUkRbQwXrbSb tI1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HdL0PoelnNwC+IbWuQ/qzw1k9SeDaMleYXr87Z/Ant4=; b=d0ZOql7KYoIXpogO6k023RmImGUM/6XpP4NSmNVVI/ILzX5FJrbQHfYhTYfVeABxei 4dTMi9ZOFuHG+F+wOcYTkthygl/heehSFR6rKR9/R1qT3s0rSBMSl3qtfOPc7IQhk5AT NQjkaFG/iGSxAjGEJpGOin61XlmrJHUG7yMOAXAz+kpB7KUB9VvT5Ggc2BXKJ0LZeklh 1KYSu59mQktIGF8EVjUhtfTQmrTUe7Cq1W1FHfe2cZ04u+ga+OSpABd4eMVS7gb5Dss+ vJ/hfzE7twgwYhtjP1kavbhJ3GiUIgd8GRifS+U5F6cYCeaMSVplL/K9bIute8ZTKfZw It8A== X-Gm-Message-State: AGi0PuYXRmhcs6hrQLBloWis1I3V6uyG94ewUsO6YPmUHmXvwPe8bAmo CaNFcY8ukYdmFsqvZPJjlwKzUX/ZahRPIbAKgiOnvA== X-Google-Smtp-Source: APiQypLeYRdXP9XHSuSKifMwGDuYtaRqyPQRWpx7Vs6/N1ChFkyDoVmidHX3CJDHhIV3yP+8cu5pPFKpdHj7jZgor0Y= X-Received: by 2002:ad4:4d06:: with SMTP id l6mr21334959qvl.34.1589292197432; Tue, 12 May 2020 07:03:17 -0700 (PDT) MIME-Version: 1.0 References: <20200511023111.15310-1-walter-zh.wu@mediatek.com> <1589203771.21284.22.camel@mtksdccf07> <1589254720.19238.36.camel@mtksdccf07> In-Reply-To: <1589254720.19238.36.camel@mtksdccf07> From: Dmitry Vyukov Date: Tue, 12 May 2020 16:03:06 +0200 Message-ID: Subject: Re: [PATCH v2 1/3] rcu/kasan: record and print call_rcu() call stack To: Walter Wu Cc: Andrey Ryabinin , Alexander Potapenko , Matthias Brugger , "Paul E . McKenney" , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , Andrew Morton , kasan-dev , Linux-MM , LKML , Linux ARM Content-Type: text/plain; charset="UTF-8" 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 Tue, May 12, 2020 at 5:38 AM Walter Wu wrote: > > Are you sure it will increase object size? > > I think we overlap kasan_free_meta with the object as well. The only > > case we don't overlap kasan_free_meta with the object are > > SLAB_TYPESAFE_BY_RCU || cache->ctor. But these are rare and it should > > only affect small objects with small redzones. > > And I think now we simply have a bug for these objects, we check > > KASAN_KMALLOC_FREE and then assume object contains free stack, but for > > objects with ctor, they still contain live object data, we don't store > > free stack in them. > > Such objects can be both free and still contain user data. > > > > Overlay kasan_free_meta. I see. but overlay it only when the object was > freed. kasan_free_meta will be used until free object. > 1). When put object into quarantine, it need kasan_free_meta. > 2). When the object exit from quarantine, it need kasan_free_meta > > If we choose to overlay kasan_free_meta, then the free stack will be > stored very late. It may has no free stack in report. Sorry, I don't understand what you mean. Why will it be stored too late? In __kasan_slab_free() putting into quarantine and recording free stack are literally adjacent lines of code: static bool __kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip, bool quarantine) { ... kasan_set_free_info(cache, object, tag); quarantine_put(get_free_info(cache, object), cache); Just to make sure, what I meant is that we add free_track to kasan_free_meta: struct kasan_free_meta { struct qlist_node quarantine_link; + struct kasan_track free_track; }; And I think its life-time and everything should be exactly what we need. Also it should help to fix the problem with ctors: kasan_free_meta is already allocated on the side for such objects, and that's exactly what we need for objects with ctor's.