From patchwork Tue Oct 22 02:18:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lyude Paul X-Patchwork-Id: 11203657 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F17413B1 for ; Tue, 22 Oct 2019 02:19:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 254312166E for ; Tue, 22 Oct 2019 02:19:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jBLmQmnu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 254312166E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 40EDD6B0003; Mon, 21 Oct 2019 22:19:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3951C6B0006; Mon, 21 Oct 2019 22:19:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 236366B0007; Mon, 21 Oct 2019 22:19:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id EE4176B0003 for ; Mon, 21 Oct 2019 22:19:50 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 827E16116 for ; Tue, 22 Oct 2019 02:19:50 +0000 (UTC) X-FDA: 76069814940.18.wound33_72f038d765129 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,lyude@redhat.com,::kasan-dev@googlegroups.com:sean@poorly.run:daniel.vetter@ffwll.ch:aryabinin@virtuozzo.com:glider@google.com:dvyukov@google.com:linux-kernel@vger.kernel.org,RULES_HIT:30003:30025:30029:30041:30054:30070,0,RBL:205.139.110.120:@redhat.com:.lbl8.mailshell.net-62.18.0.100 66.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: wound33_72f038d765129 X-Filterd-Recvd-Size: 4081 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Oct 2019 02:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571710789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cy1H0yNRlADn6s5BcmmX0kDdj1YRyEm1IRV1QcI4xNE=; b=jBLmQmnuQeWcrZ0JsiZupKbuDGkddQnr/8j6c6HKxp42Jb2zR9ScirZaDAtvROfK00EQZ/ XYkcAPuOp3g5p50zE9AJ6bB37bkJEm6teqsPxSPwU/mVlZQ2W7/4CsXs11+/ADkoK4lX3I WvwaQTtcwwxJhXSmNdROE2HgbANalfA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-qGaYFtxgOfqv3l0NUq_F-w-1; Mon, 21 Oct 2019 22:19:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B345107AD31; Tue, 22 Oct 2019 02:19:44 +0000 (UTC) Received: from malachite.redhat.com (ovpn-120-98.rdu2.redhat.com [10.10.120.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7EA85C22C; Tue, 22 Oct 2019 02:19:21 +0000 (UTC) From: Lyude Paul To: linux-mm@kvack.org, kasan-dev@googlegroups.com Cc: Sean Paul , Daniel Vetter , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , linux-kernel@vger.kernel.org Subject: [RFC] kasan: include the hashed pointer for an object's location Date: Mon, 21 Oct 2019 22:18:11 -0400 Message-Id: <20191022021810.3216-1-lyude@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: qGaYFtxgOfqv3l0NUq_F-w-1 X-Mimecast-Spam-Score: 0 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: 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); if (!addr) return;