Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp369140ybk; Wed, 13 May 2020 02:19:27 -0700 (PDT) X-Google-Smtp-Source: APiQypIba/qjFcj0cVSXpJvnM5gC6gbNn5pv+HNv8mImTuzJTIVTmp7Dnraydkcdi1Dtt4RRpzcd X-Received: by 2002:a17:906:5695:: with SMTP id am21mr15832837ejc.223.1589361567555; Wed, 13 May 2020 02:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589361567; cv=none; d=google.com; s=arc-20160816; b=k3Jh/c+hDBjhqrAdA0L41O6lsfiRlpfFHkm8rjZNAhEqhPjVaEjxLreJiFG3YiHaNJ D+722/4nVpJw+Usdp3864KRyXa5lhEEQvN7oHmkn8koEvKdWaj3ZQiBC4dk1dWX4BtGW KcG6G73Ww3umVdCj5vuSdyrW/vGARmm0GuXxF1n6e0RKS2NTOlqaGlekmKHWUoj7tN6D ek0simLy7QVLIfouatuquSRBfVUAt9r1MmYNWZXZA+YumovWyPtP0FVXzdT4sUVEZmTg 5oU5x3BNncsk0gvB8p6R3DOuW6k0t1hli+AI+7r9owT6eOqkzY9gyd85SAbk4U+vSOqJ X/Ug== 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=itos8LHRnARIlzXTWR1kJY/omxPbBoUWPcSfUqjsoA4=; b=vEpla7gPPI6F0Jn/YPJbYPrjEH3ytKGu4mAdHvhRvRAuHbVyC4BllWpkF0R9nX23aI cUD39uEQjOwPVUxT3I9sRpGXnL+K3NhDcfaE8BMq4bu1CFjjWLy4pmRRkBRKxMEPfPab B4Pwvo++2tEROfVFjDLiNtEeoOgmKGXdr9lzUBol8oc9pBvzP7rBuflDY8DtXLE8ndZO TbMOn1Wp0O2IrkJ5czWfYAm2J19M4axHXBoXBsQxRDBMsg820Zx7zvBMJR9rLgQhLDK1 odooPQkEh7Jwh89UlOu/+xrLuxwxlrfhUZmWplW+/KBdiDaMAX835MhBRoRBbcvE0sDj NVug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A5K6VoJj; 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 i18si619455ejk.81.2020.05.13.02.19.03; Wed, 13 May 2020 02:19:27 -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=A5K6VoJj; 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 S1732465AbgEMJQP (ORCPT + 99 others); Wed, 13 May 2020 05:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730334AbgEMJQO (ORCPT ); Wed, 13 May 2020 05:16:14 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D133C061A0C for ; Wed, 13 May 2020 02:16:14 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id f189so10916691qkd.5 for ; Wed, 13 May 2020 02:16:14 -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=itos8LHRnARIlzXTWR1kJY/omxPbBoUWPcSfUqjsoA4=; b=A5K6VoJjI1dL1KN/df5QAgoFGmJhl6hWdd6tZEPcPBTKXaPrdVWtwhgh8whNo4BjYe bm+xeV36/ASRg95TApfRBFZ6lB1iULFvHksmM/H4aSPXFYUIshFowGhO6YmjyogHCYkh 0Q8LujaVHkcfsfLQDRh3E6L2ke6nGUOYrADpgIpAXMeMZOCIHCypUbWJFzyIPmN5Mq+x +1A4YD7OT1Xz0L1cZ/z848MWlGSbO3bosMDEeR9ZYiGZzzArSWG8X8G0pSWj1sYo6FZl MabnV+0zbmVxYJsgjX5/iHjXfmdXLBYwRV0OZzQ3T7Xn4UDHhm4a66yvWMlwC6HoKgcb 2G6g== 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=itos8LHRnARIlzXTWR1kJY/omxPbBoUWPcSfUqjsoA4=; b=UafJaels1ZkwsVQyWNiW5VfCmKKfg868UqwSidiVq5cQxdu/DeKGMeAJdUPQb2VhPI KJuknSLGfwlGHbhRoQ/342dSJW+b7H2hqHyFL8WQIjHGbEvtwleT5LiO8UPxKk28vZNQ CmxcJlIVaDlEUf9bj2gk/Hyy7xiUGUXhhC1tsOaiKP4giOoarmp8N5QRWevRIxWbZ9b2 VAzfla1h0dCm2n7oTJ8TI+m4+KKZgxZLK0TyBtajU87GDmg17j2kAKLQfXQiEXfy2FW3 x6mKHN8t4zhzVquG2a9mbo52pAsSR3j88A+R2jXiWqWM9Q092OoY4xpN2FzPCHY+puei 1ncg== X-Gm-Message-State: AGi0PuY9YtT6lqShlUhW8d1xXRtTHC2vH7OY7iqOnDMvE1tvjsg9JMGT rwjuj0RyUGIGuLjowQoDGetikWmAeCp1PNqx7z6IMg== X-Received: by 2002:a37:9d55:: with SMTP id g82mr21819383qke.407.1589361373420; Wed, 13 May 2020 02:16:13 -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> <1589360744.14554.10.camel@mtksdccf07> In-Reply-To: <1589360744.14554.10.camel@mtksdccf07> From: Dmitry Vyukov Date: Wed, 13 May 2020 11:16:01 +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 11:05 AM Walter Wu wrote: > > On Wed, 2020-05-13 at 08:51 +0200, 'Dmitry Vyukov' via kasan-dev wrote: > > 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. > > > > I want to make a summary. Which of the following is the approach we > want? or if I have some misunderstandings, please help me to correct. > Thanks. > > 1) For different object, then it will has two ways. > 1.a) When object are LAB_TYPESAFE_BY_RCU || cache->ctor, then store free > stack into free track of struct kasan_free_meta. > 2.b) Except 1.a), store free stack into freed object. > > or > > 2) We always store free stack into free track of struct kasan_free_meta I meant 2): We always store free stack into free track of struct kasan_free_meta. I think it will do the same as other options but just with less code (and simpler code). Maybe I am missing something here? > > > > 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.