Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2742541ybk; Tue, 12 May 2020 07:06:54 -0700 (PDT) X-Google-Smtp-Source: APiQypK0XcUADFM7uuqqpR0MvKwRi8BjuU0OztnopbnqzyyP58JjRYzFb87eLrSczAXWiadulrt9 X-Received: by 2002:a50:e002:: with SMTP id e2mr18711447edl.179.1589292414109; Tue, 12 May 2020 07:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589292414; cv=none; d=google.com; s=arc-20160816; b=0zYjTwEfZjnY/FTGNsRsR/r0DS0n1dzlWzgseFXBQ1AU1CKOucLeruED9KjrRe1Hxc /19KmUxt5Dg2h0fThPE54/Dk2aMphYACvEiPhEWxjB2C9RIAlHTDePULqIQ7XfoTGvWZ oWZgEeV0NxxW7O8ZNL20b7tTUbYpuoE3vKQAiu9UJN8Pe6LEmiSoivmiOTu2AqgNa1XX I/HGDvwBBfaanvvWSCb+Gh3ATIGuz4PDoKe9sT7/C6J1DGbjTW5pSmrqN06Vn3SITHsN PzG9z5HRyxqV115IE3ONnTnCWoDclu1b7uPFe/sJ4Pi/bAerbcRCIagXF0ywSF1SZr1Q qdGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=HdL0PoelnNwC+IbWuQ/qzw1k9SeDaMleYXr87Z/Ant4=; b=rgHZQMrb5inWY7PdhYAh8M8yi8u8uHd9Gl0BzKOfxCvLVsF9eCyzkf3i7v4RYDsVAh xcknRxlESCpZ99772VMMVDfLShzoZNV+fUcRi09U4o/YiESt/t09oAtJatgxbn0lD/Vu SunMpq9vEv6mvkMThaAr1844SoCEb8p3pKr3K74XVOTcPyFoGjzRjqwWRjNas3DQi3cV ZHLOKtJCXKkXCtMvL1fKdUK+kzvRsww2jHqMGJZ9SlhDnNgI78LqMVHoP46lhZFO+lGs qMcHcR6RVhmE06YqcV2NucQ4WJnGWxWRAdGls+gKwVgiFt2CcywXUvaXahPvDL/qLRu9 aHog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QQawiJ16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si6788652edj.13.2020.05.12.07.06.30; Tue, 12 May 2020 07:06:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QQawiJ16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730193AbgELODT (ORCPT + 99 others); Tue, 12 May 2020 10:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728085AbgELODS (ORCPT ); Tue, 12 May 2020 10:03:18 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76262C061A0C for ; Tue, 12 May 2020 07:03:18 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id x13so4444777qvr.2 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=Q0NBK5lHZsAcHvWtKSXeF4OMVAmj+MWvjZiX4XJroRAqc7VZotpDIXZeWV6STScnXP RM6VIWm9SpmFzXmSqK9rQhcOYbDaactyVyLnrvp14eIdd5NyY5OWtbQhjBDEONloJil7 vRTV9LNVsrLhcipx1qDW0PIY6ttxDR6/0OdYfpWJob3KQJIsqB/QyEQcIQY3d0+q5Dg+ Ep3utR74FocJBg661qJJjZxY6AFHyD+51ArER/VaN+3Jk3x3cnlj9DCDA9lBJ2/jvQIw pKSB67JfmLrhcZ4UB3oUMR4KOziMwH1Rdoy8YxiJIrfJuXRCl7QXfDIpBmnQEY1lN3QO PfnQ== X-Gm-Message-State: AGi0PuaekFZNiKiQzHyV7BcSPwj0pytalqNHmdekZjyoLxskQNOCGEik j9zUnluJRLxQziDlOws7YhyO8tc/o7fFrSjrCwJR5g== 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.