Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp296498ybk; Tue, 12 May 2020 23:56:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqeiTkU5G2NAYa0/b0TLMuHY93L5EzPInPvXKEBxqi/NrG8qgvEdb3+Ux3OiEqFOj6vE6h X-Received: by 2002:a05:6402:8c7:: with SMTP id d7mr9665547edz.113.1589352965323; Tue, 12 May 2020 23:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589352965; cv=none; d=google.com; s=arc-20160816; b=PiNFfr8juJkEpEKffAjzCOnf2oa4Si9qWgiW/APG+n3jcXe45vAkqafySi2lVbk6Yz JJu+kVLjV6vbq62n1iiRLdLfoVJ7mGRvNXOtVJ5B7h2Px9yZC+t9fKuWguDTCBlIKiel TrF+10TnlY//OG+qWa53hebXyMZEaQd3mHdBEab2+gnhu/wqzVNroHGB1aNxOVbEfcHf OKBfIjQTMdJOQ3OSP9nIkg+Hcv4r0Y3aBBknsL5eaHWtjR1lSZAHahNgIMIhzUkp5iay 67W4BZ1U5gLeHxW7h9cT8FgLfkE+IJx+3XKv+clAHEaU3kYIwnAY1AfbYdqd/CxOD1DL 2p0g== 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=e6QbSlNOUjKcG/ZMZ3XtXHK+IfmeCzylC8Xkh73q0Aw=; b=rstGUZJryUh2l1MiLl5irKENiH76/cSD2b01o96sgB9zTBG1kiAqTJTEXBIy0O3yni 3barAHXR73c4tJ1tPO0Zllzzg6iKsi5/zeyP7INToOlt/sl4MJci7oxuhM7lbEsKmpz1 OgQr5KwgBpzMCvl7TlOBST6gaHTcb4tH+8GVARGNeClnj0tls1vA52rv6eeaDBYffbHU PcugAILogoVJh6kjhWxhMvlprQw8vQESNcCpEpAQigoMtr25fCNjC58XfRz1H5MvRkZY Fp9B+lOdCGnuJt9EcZQQIQ98ijLmNagWlyZzfeNcuuNkG6pzGpEi9O2ubJej7cu47xZE HcPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MVQ6mRj0; 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 b9si7245186eja.138.2020.05.12.23.55.42; Tue, 12 May 2020 23:56:05 -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=MVQ6mRj0; 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 S1729885AbgEMGvl (ORCPT + 99 others); Wed, 13 May 2020 02:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729367AbgEMGvk (ORCPT ); Wed, 13 May 2020 02:51:40 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83852C061A0C for ; Tue, 12 May 2020 23:51:40 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id g20so4670070qvb.9 for ; Tue, 12 May 2020 23:51:40 -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=e6QbSlNOUjKcG/ZMZ3XtXHK+IfmeCzylC8Xkh73q0Aw=; b=MVQ6mRj0yNs3gHcYY1RhK7VD4fpo64JAOOyD3f9QApNHT5ECfY+bzA0iu4QBJTzYGj sA7TY7dhSyq2eZ3vCVhqHAasszCcpxlanbJ4PJmu+fgoh6Jc0ib1eNbQCgx51n87cV1N MOer2/trIkbKluf0nZZ5UsxSJZFCjjGMX3ntmF0SGx2sfsHqQ9Xw7ZdryxDMzlPnJvxi +6Oc1Ex9QvdOZvGWuqY3FBHWZjufRAUNJNetSevZIZO+CkK4J1WPd4yTXRIohwE55qZt nKVakGPU/7m2ky+3FKJ3ne82FeecYwDpaVUs1bWJowijAAVPkaIPhV6imjhEENxutcLW Q3fA== 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=e6QbSlNOUjKcG/ZMZ3XtXHK+IfmeCzylC8Xkh73q0Aw=; b=JUDM4yGuUxUDYN4aa6BU8sw4FDeZRIh+SBHjFlDdWsHRissIh81m67mi/snpiUScRH l2fZHz7HOPh0TzkPbcCdQkEVa3Rk3FMFoptmNjVsYxLg4WzvEoVUauOkPCzvfZFupi/G Oz7TmNJfQg9qM+xJUQz+J+e+O2pWHgIfBapOPfPovp8uRTrihUTUTgFmQQmL7P8JynPW VcQSvs3aLvjVopJDM5AdWo8A55+2Br7A+19o1ppP3KybFJ/7DrAnSEEdU1N3fdsomqXk 41UePPJBn7oJdjTI7GyWcYQxOt5ij36sA7TqAGxCyHWTvmaK3sgSMj7dNKSXjR2cYBHC +eLw== X-Gm-Message-State: AOAM532ThMlw/S5kESIwgPYca8zzvQZM7YcngLhd7UrPBQMVHLBC5Cbj B5Od9gUqHngRmfJ/Hs/dFH1OnTuRgtTBc0QprwVs6w== X-Received: by 2002:a0c:f153:: with SMTP id y19mr909681qvl.22.1589352699379; Tue, 12 May 2020 23:51:39 -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> <1589334472.19238.44.camel@mtksdccf07> In-Reply-To: <1589334472.19238.44.camel@mtksdccf07> From: Dmitry Vyukov Date: Wed, 13 May 2020 08:51:27 +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 Wed, May 13, 2020 at 3:48 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; > > }; > > > > When I see above struct kasan_free_meta, I know why you don't understand > my meaning, because I thought you were going to overlay the > quarantine_link by free_track, but it seems like to add free_track to > kasan_free_meta. Does it enlarge meta-data size? I would assume it should not increase meta-data size. In both cases we store exactly the same information inside of the object: quarantine link and free track. I see it more as a question of code organization. We already have a concept of "this data is placed inside of the freed object", we already have a name for it (kasan_free_meta), we already have code to choose where to place it, we already have helper functions to access it. And your change effectively duplicates all of this to place the 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. > > I see.