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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham 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 31091CA9EAF for ; Tue, 22 Oct 2019 02:27:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1F5C2089E for ; Tue, 22 Oct 2019 02:27:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gUPc3+r0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1F5C2089E 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 7B09A6B0003; Mon, 21 Oct 2019 22:27:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 760686B0006; Mon, 21 Oct 2019 22:27:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 675C06B0007; Mon, 21 Oct 2019 22:27:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id 467956B0003 for ; Mon, 21 Oct 2019 22:27:22 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id B34F18249980 for ; Tue, 22 Oct 2019 02:27:21 +0000 (UTC) X-FDA: 76069833882.07.board49_231e7964ec75f X-HE-Tag: board49_231e7964ec75f X-Filterd-Recvd-Size: 5219 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Oct 2019 02:27:21 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id 71so10986176qkl.0 for ; Mon, 21 Oct 2019 19:27:21 -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=VN4XOQxWZMWnSTs2Dh2Lw0yjzpEOfDxml7hxLuxIwLs=; b=gUPc3+r0SNz5/3BwEP/jyh2XSQNeJOemtUsONV716BzuDnty9pw46TrLUwK6o1cscy 8uXKN3QbQeDI4bNQJbBIPchpNZXoFUU5P+ci1bZd9YXOaeNT7UMcp6y3sB0Y17A/Dq6s Du4/0ZaY520ok4LbWICjEYsktLstQJ6TxDDt99B9okzfv2X4Q+MZ3cyoIk2QHSHRXoCF YzwKH4T9VELi04rhOhLbFInmRMfP2vjAVoCyc41Vz/WcbXKrNB1g/4pHEH6IL/2uK0/5 Gttu/YQGKgixxsJnaXKUoUyu1+sHU/YFbVoPgt0YQKXWJM4XvxbvNXCiyhz5euildoC1 h/gA== 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=VN4XOQxWZMWnSTs2Dh2Lw0yjzpEOfDxml7hxLuxIwLs=; b=Khn6na39Nu4UUtfdrV5OhUIx64yyVMGHj9CF66CTbLCTkkXmAZhxPSXX7vWf+obs9s AJvK/shNcXyuSyxiqTPsu5RSPaT3G9HbwDdkMYEER2/OEjOErBGoWu97TMv0J8b87lF2 sxpYEoI6P8M48RADL/5gj0yMFPoDx/GsBFv7V54J1PNjts4/Oj5lxDWF6syxbHRgUwHk DFIG3pQKlStW3GZvCgVxT4F2XmN3HQzlhKk5GOMUef5mDyZiyebx5j4e99HVQEq8m1M0 ab1QZMDudoAMe+gWpjwDXOgMsk3i11TaezdA04hjdCQ50fh9wxCLFKCYs92xR4Xbk5g3 YBjQ== X-Gm-Message-State: APjAAAU5HyegyCDEMgJ8Z+rg4HKPHFBhv4sRscT5ietl0YwA3vCxdeCP Ha0N0xummadjSZP2txulkHy8bietgoLmYD5m5F+cQA== X-Google-Smtp-Source: APXvYqzli1POTBKn0kITztaQ0CotLZWI9kuTgVDX+qwQpn+d/fAMU56WobWzNiniZRveIUy3KQbdmwei73fofxuITjk= X-Received: by 2002:a37:4a87:: with SMTP id x129mr908751qka.43.1571711240126; Mon, 21 Oct 2019 19:27:20 -0700 (PDT) MIME-Version: 1.0 References: <20191022021810.3216-1-lyude@redhat.com> In-Reply-To: <20191022021810.3216-1-lyude@redhat.com> From: Dmitry Vyukov Date: Tue, 22 Oct 2019 04:27:08 +0200 Message-ID: Subject: Re: [RFC] kasan: include the hashed pointer for an object's location To: Lyude Paul Cc: Linux-MM , kasan-dev , Sean Paul , Daniel Vetter , Andrey Ryabinin , Alexander Potapenko , LKML 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, Oct 22, 2019 at 4:19 AM Lyude Paul wrote: > > The vast majority of the kernel that needs to print out pointers as a > way to keep track of a specific object in the kernel for debugging > purposes does so using hashed pointers, since these are "good enough". > Ironically, the one place we don't do this is within kasan. While > simply printing a hashed version of where an out of bounds memory access > occurred isn't too useful, printing out the hashed address of the object > in question usually is since that's the format most of the kernel is > likely to be using in debugging output. > > Of course this isn't perfect though-having the object's originating > address doesn't help users at all that need to do things like printing > the address of a struct which is embedded within another struct, but > it's certainly better then not printing any hashed addresses. And users > which need to handle less trivial cases like that can simply fall back > to careful usage of %px. > > Signed-off-by: Lyude Paul > Cc: Sean Paul > Cc: Daniel Vetter > Cc: Andrey Ryabinin > Cc: Alexander Potapenko > Cc: Dmitry Vyukov > Cc: kasan-dev@googlegroups.com > --- > mm/kasan/report.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/mm/kasan/report.c b/mm/kasan/report.c > index 621782100eaa..0a5663fee1f7 100644 > --- a/mm/kasan/report.c > +++ b/mm/kasan/report.c > @@ -128,8 +128,9 @@ static void describe_object_addr(struct kmem_cache *cache, void *object, > int rel_bytes; > > pr_err("The buggy address belongs to the object at %px\n" > - " which belongs to the cache %s of size %d\n", > - object, cache->name, cache->object_size); > + " (aka %p) which belongs to the cache\n" > + " %s of size %d\n", > + object, object, cache->name, cache->object_size); Hi Lyude, This only prints hashed address for heap objects, but print_address_description() has 4 different code paths for different types of addresses (heap, global, stack, page). Plus there is a case for address without shadow. Should we print the hashed address at least for all cases in print_address_description()? > if (!addr) > return; > -- > 2.21.0 >