From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f69.google.com (mail-it0-f69.google.com [209.85.214.69]) by kanga.kvack.org (Postfix) with ESMTP id 9F73F6B0253 for ; Thu, 7 Dec 2017 06:13:58 -0500 (EST) Received: by mail-it0-f69.google.com with SMTP id r196so10298585itc.4 for ; Thu, 07 Dec 2017 03:13:58 -0800 (PST) Received: from resqmta-ch2-02v.sys.comcast.net (resqmta-ch2-02v.sys.comcast.net. [2001:558:fe21:29:69:252:207:34]) by mx.google.com with ESMTPS id 76si3356673ioe.277.2017.12.07.03.13.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 03:13:57 -0800 (PST) Date: Thu, 7 Dec 2017 05:13:56 -0600 (CST) From: Christopher Lameter Subject: Re: [PATCH] mm/slab: Do not hash pointers when debugging slab In-Reply-To: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> Message-ID: References: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Geert Uytterhoeven Cc: Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "Tobin C . Harding" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kees Cook On Thu, 7 Dec 2017, Geert Uytterhoeven wrote: > If CONFIG_DEBUG_SLAB/CONFIG_DEBUG_SLAB_LEAK are enabled, the slab code > prints extra debug information when e.g. corruption is detected. > This includes pointers, which are not very useful when hashed. > > Fix this by using %px to print unhashed pointers instead. Acked-by: Christoph Lameter These SLAB config options are only used for testing so this is ok. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f70.google.com (mail-vk0-f70.google.com [209.85.213.70]) by kanga.kvack.org (Postfix) with ESMTP id 0A7116B0038 for ; Thu, 7 Dec 2017 13:43:15 -0500 (EST) Received: by mail-vk0-f70.google.com with SMTP id t20so4350239vkb.17 for ; Thu, 07 Dec 2017 10:43:15 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 32sor2216853uat.303.2017.12.07.10.43.10 for (Google Transport Security); Thu, 07 Dec 2017 10:43:11 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> From: Kees Cook Date: Thu, 7 Dec 2017 10:43:09 -0800 Message-ID: Subject: Re: [PATCH] mm/slab: Do not hash pointers when debugging slab Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Christopher Lameter Cc: Geert Uytterhoeven , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "Tobin C . Harding" , Linux-MM , LKML , Linus Torvalds On Thu, Dec 7, 2017 at 3:13 AM, Christopher Lameter wrote: > On Thu, 7 Dec 2017, Geert Uytterhoeven wrote: > >> If CONFIG_DEBUG_SLAB/CONFIG_DEBUG_SLAB_LEAK are enabled, the slab code >> prints extra debug information when e.g. corruption is detected. >> This includes pointers, which are not very useful when hashed. >> >> Fix this by using %px to print unhashed pointers instead. > > Acked-by: Christoph Lameter > > These SLAB config options are only used for testing so this is ok. Most systems use SLUB so I can't say how common CONFIG_DEBUG_SLAB is. (Though, FWIW with SLUB, CONFIG_SLUB_DEBUG is very common.) -Kees -- Kees Cook Pixel Security -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f71.google.com (mail-it0-f71.google.com [209.85.214.71]) by kanga.kvack.org (Postfix) with ESMTP id F2B0A6B0033 for ; Thu, 7 Dec 2017 15:15:29 -0500 (EST) Received: by mail-it0-f71.google.com with SMTP id o66so274020ita.3 for ; Thu, 07 Dec 2017 12:15:29 -0800 (PST) Received: from resqmta-ch2-03v.sys.comcast.net (resqmta-ch2-03v.sys.comcast.net. [2001:558:fe21:29:69:252:207:35]) by mx.google.com with ESMTPS id c70si4588357ioa.57.2017.12.07.12.15.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 12:15:29 -0800 (PST) Date: Thu, 7 Dec 2017 14:15:27 -0600 (CST) From: Christopher Lameter Subject: Re: [PATCH] mm/slab: Do not hash pointers when debugging slab In-Reply-To: Message-ID: References: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Kees Cook Cc: Geert Uytterhoeven , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "Tobin C . Harding" , Linux-MM , LKML , Linus Torvalds On Thu, 7 Dec 2017, Kees Cook wrote: > > These SLAB config options are only used for testing so this is ok. > > Most systems use SLUB so I can't say how common CONFIG_DEBUG_SLAB is. > (Though, FWIW with SLUB, CONFIG_SLUB_DEBUG is very common.) CONFIG_SLUB_DEBUG is on by default because it compiles into the kernel the runtime configurable debugging framework. It does not activate any debugging. CONFIG_SLUB_DEBUG_ON is the equivalent to CONFIG_SLAB_DEBUG. The kernel will boot with debugging on without any extra kernel options with these. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f69.google.com (mail-it0-f69.google.com [209.85.214.69]) by kanga.kvack.org (Postfix) with ESMTP id 13C156B0033 for ; Sun, 10 Dec 2017 15:45:16 -0500 (EST) Received: by mail-it0-f69.google.com with SMTP id w125so10962827itf.0 for ; Sun, 10 Dec 2017 12:45:16 -0800 (PST) Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id e9sor6521664ioe.155.2017.12.10.12.45.10 for (Google Transport Security); Sun, 10 Dec 2017 12:45:11 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> References: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> From: Linus Torvalds Date: Sun, 10 Dec 2017 12:45:10 -0800 Message-ID: Subject: Re: [PATCH] mm/slab: Do not hash pointers when debugging slab Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Geert Uytterhoeven Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "Tobin C . Harding" , linux-mm , Linux Kernel Mailing List On Thu, Dec 7, 2017 at 2:17 AM, Geert Uytterhoeven wrote: > > if (cachep->flags & SLAB_STORE_USER) { > - pr_err("Last user: [<%p>](%pSR)\n", > + pr_err("Last user: [<%px>](%pSR)\n", > *dbg_userword(cachep, objp), > *dbg_userword(cachep, objp)); Is there actually any point to the %px at all? Why not remove it? the _real_ information is printed out by %pSR, and that's both sufficient and useful in ways %px isn't. > - pr_err("Slab corruption (%s): %s start=%p, len=%d\n", > + pr_err("Slab corruption (%s): %s start=%px, len=%d\n", > print_tainted(), cachep->name, > realobj, size); and here, is the pointer actually interesting, or should we just give the offset to the allocation? But if the pointer is interesting, then ack. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by kanga.kvack.org (Postfix) with ESMTP id E339D6B0033 for ; Mon, 11 Dec 2017 03:08:19 -0500 (EST) Received: by mail-qt0-f197.google.com with SMTP id h4so20921637qtj.0 for ; Mon, 11 Dec 2017 00:08:19 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l5sor9630672qkc.132.2017.12.11.00.08.16 for (Google Transport Security); Mon, 11 Dec 2017 00:08:16 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> From: Geert Uytterhoeven Date: Mon, 11 Dec 2017 09:08:15 +0100 Message-ID: Subject: Re: [PATCH] mm/slab: Do not hash pointers when debugging slab Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Linus Torvalds Cc: Geert Uytterhoeven , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "Tobin C . Harding" , linux-mm , Linux Kernel Mailing List Hi Linus, On Sun, Dec 10, 2017 at 9:45 PM, Linus Torvalds wrote: > On Thu, Dec 7, 2017 at 2:17 AM, Geert Uytterhoeven > wrote: >> - pr_err("Slab corruption (%s): %s start=%p, len=%d\n", >> + pr_err("Slab corruption (%s): %s start=%px, len=%d\n", >> print_tainted(), cachep->name, >> realobj, size); > > and here, is the pointer actually interesting, or should we just give > the offset to the allocation? The pointer may help to identify e.g. an empty list_head in the written data. > But if the pointer is interesting, then ack. Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f71.google.com (mail-it0-f71.google.com [209.85.214.71]) by kanga.kvack.org (Postfix) with ESMTP id 03F996B0033 for ; Mon, 11 Dec 2017 07:01:43 -0500 (EST) Received: by mail-it0-f71.google.com with SMTP id 207so14078200iti.5 for ; Mon, 11 Dec 2017 04:01:43 -0800 (PST) Received: from resqmta-ch2-05v.sys.comcast.net (resqmta-ch2-05v.sys.comcast.net. [69.252.207.37]) by mx.google.com with ESMTPS id e41si10212815ioj.46.2017.12.11.04.01.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 04:01:42 -0800 (PST) Date: Mon, 11 Dec 2017 06:00:40 -0600 (CST) From: Christopher Lameter Subject: Re: [PATCH] mm/slab: Do not hash pointers when debugging slab In-Reply-To: Message-ID: References: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Linus Torvalds Cc: Geert Uytterhoeven , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "Tobin C . Harding" , linux-mm , Linux Kernel Mailing List On Sun, 10 Dec 2017, Linus Torvalds wrote: > On Thu, Dec 7, 2017 at 2:17 AM, Geert Uytterhoeven > wrote: > > > > if (cachep->flags & SLAB_STORE_USER) { > > - pr_err("Last user: [<%p>](%pSR)\n", > > + pr_err("Last user: [<%px>](%pSR)\n", > > *dbg_userword(cachep, objp), > > *dbg_userword(cachep, objp)); > > Is there actually any point to the %px at all? > > Why not remove it? the _real_ information is printed out by %pSR, and > that's both sufficient and useful in ways %px isn't. This pointer refers to code so we can remove it. > > > - pr_err("Slab corruption (%s): %s start=%p, len=%d\n", > > + pr_err("Slab corruption (%s): %s start=%px, len=%d\n", > > print_tainted(), cachep->name, > > realobj, size); > > and here, is the pointer actually interesting, or should we just give > the offset to the allocation? > > But if the pointer is interesting, then ack. The pointer here is to an slab object which could be important if one wants to find the pointer value in a hexdump of another object (f.e. listhead) or other pointer information that is being inspected in a debugging session. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Geert Uytterhoeven Subject: [PATCH] mm/slab: Do not hash pointers when debugging slab Date: Thu, 7 Dec 2017 11:17:41 +0100 Message-Id: <1512641861-5113-1-git-send-email-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton Cc: "Tobin C . Harding" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven List-ID: If CONFIG_DEBUG_SLAB/CONFIG_DEBUG_SLAB_LEAK are enabled, the slab code prints extra debug information when e.g. corruption is detected. This includes pointers, which are not very useful when hashed. Fix this by using %px to print unhashed pointers instead. Fixes: ad67b74d2469d9b8 ("printk: hash addresses printed with %p") Signed-off-by: Geert Uytterhoeven --- It's been ages I needed the above options. But of course I need them just after the introduction of address hashing... --- mm/slab.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 183e996dde5ff37a..70be5823227dcb3e 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1585,7 +1585,7 @@ static void print_objinfo(struct kmem_cache *cachep, void *objp, int lines) } if (cachep->flags & SLAB_STORE_USER) { - pr_err("Last user: [<%p>](%pSR)\n", + pr_err("Last user: [<%px>](%pSR)\n", *dbg_userword(cachep, objp), *dbg_userword(cachep, objp)); } @@ -1621,7 +1621,7 @@ static void check_poison_obj(struct kmem_cache *cachep, void *objp) /* Mismatch ! */ /* Print header */ if (lines == 0) { - pr_err("Slab corruption (%s): %s start=%p, len=%d\n", + pr_err("Slab corruption (%s): %s start=%px, len=%d\n", print_tainted(), cachep->name, realobj, size); print_objinfo(cachep, objp, 0); @@ -1650,13 +1650,13 @@ static void check_poison_obj(struct kmem_cache *cachep, void *objp) if (objnr) { objp = index_to_obj(cachep, page, objnr - 1); realobj = (char *)objp + obj_offset(cachep); - pr_err("Prev obj: start=%p, len=%d\n", realobj, size); + pr_err("Prev obj: start=%px, len=%d\n", realobj, size); print_objinfo(cachep, objp, 2); } if (objnr + 1 < cachep->num) { objp = index_to_obj(cachep, page, objnr + 1); realobj = (char *)objp + obj_offset(cachep); - pr_err("Next obj: start=%p, len=%d\n", realobj, size); + pr_err("Next obj: start=%px, len=%d\n", realobj, size); print_objinfo(cachep, objp, 2); } } @@ -2608,7 +2608,7 @@ static void slab_put_obj(struct kmem_cache *cachep, /* Verify double free bug */ for (i = page->active; i < cachep->num; i++) { if (get_free_obj(page, i) == objnr) { - pr_err("slab: double free detected in cache '%s', objp %p\n", + pr_err("slab: double free detected in cache '%s', objp %px\n", cachep->name, objp); BUG(); } @@ -2772,7 +2772,7 @@ static inline void verify_redzone_free(struct kmem_cache *cache, void *obj) else slab_error(cache, "memory outside object was overwritten"); - pr_err("%p: redzone 1:0x%llx, redzone 2:0x%llx\n", + pr_err("%px: redzone 1:0x%llx, redzone 2:0x%llx\n", obj, redzone1, redzone2); } @@ -3078,7 +3078,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, if (*dbg_redzone1(cachep, objp) != RED_INACTIVE || *dbg_redzone2(cachep, objp) != RED_INACTIVE) { slab_error(cachep, "double free, or memory outside object was overwritten"); - pr_err("%p: redzone 1:0x%llx, redzone 2:0x%llx\n", + pr_err("%px: redzone 1:0x%llx, redzone 2:0x%llx\n", objp, *dbg_redzone1(cachep, objp), *dbg_redzone2(cachep, objp)); } @@ -3091,7 +3091,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, cachep->ctor(objp); if (ARCH_SLAB_MINALIGN && ((unsigned long)objp & (ARCH_SLAB_MINALIGN-1))) { - pr_err("0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n", + pr_err("0x%px: not aligned to ARCH_SLAB_MINALIGN=%d\n", objp, (int)ARCH_SLAB_MINALIGN); } return objp; @@ -4283,7 +4283,7 @@ static void show_symbol(struct seq_file *m, unsigned long address) return; } #endif - seq_printf(m, "%p", (void *)address); + seq_printf(m, "%px", (void *)address); } static int leaks_show(struct seq_file *m, void *p) -- 2.7.4