Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3921409pxj; Mon, 21 Jun 2021 09:25:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx3FdyLrqB9fPvw7UWmGPS9UZ+daa4o/qY2lzXvKi0taR6xdSL5QLvOfWfDDVoluRmuRjn X-Received: by 2002:a17:906:724b:: with SMTP id n11mr25776226ejk.338.1624292700757; Mon, 21 Jun 2021 09:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292700; cv=none; d=google.com; s=arc-20160816; b=jHShy61piMIG8P3CdNtlUOo/4oGpWVEGKOYdRTqTfdmZtZUQ5gDZ23g70xCSR69f1t 2bVyVbGNkNAw28XlPtZ8IQkGPd4yL8axJuW3X4AMVnf92l+98SuQTnBopPFCGMqRYiYN S894Vv4P9e8rU8JlsViDFTMTXpsCcmJdhgReIftOFzdjWrRIHQwJNL80LkQYCqnJV6m2 dtm8/hlXOibnGGw9Uw03/bflzESCZcD1XUNPSYohhicBLkdmni2XAlabNDtkbrnEkC1b CqsbhoPmmVBoamEFV7NYanDkPu2dOH46yBt7e/Gjhl4rQ1YLHkk0jhmTgNpwbIhnF0W+ d9Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VB/EakrbB6NbGmmuD3/J5ibSjvh8/8Vlxi/VFjbUpno=; b=Gox9nm3GB6todhj+nWOWmObYmc/48Sk6aHhPwHbK1tnuXr2HzX5Ia4Wwff/Q6B8Z4E d3yiLw2MkeqH2sOY4l9RF5MTiXEVwgaNZZEu7e8133AjQfwWh7rp3GiSXjDaIvKmwFLK wxtYrNNNeBDjJl+OhiAlF0QnP+MMsZH3plyDkta09UgrT9sMbnBKJkPXr0IO/absCwD5 0BTBHBHYLZytO9ElGl/sQCxJaQL8QGpWii8CbBztktJAp7UY404NamdsRfUSUNRbFO7P qE14AzZXreygzdQWOp2Gaeokp9DZXvWWUtkqAorDow5hhV9+FR+HC3rJyHqTrn5anFBy Vp3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ypyz7nZd; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si10700066ejp.651.2021.06.21.09.24.38; Mon, 21 Jun 2021 09:25:00 -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=@linuxfoundation.org header.s=korg header.b=ypyz7nZd; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbhFUQZ2 (ORCPT + 99 others); Mon, 21 Jun 2021 12:25:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:42340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231593AbhFUQXz (ORCPT ); Mon, 21 Jun 2021 12:23:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED213613BA; Mon, 21 Jun 2021 16:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292450; bh=MtWNnDTWO2vMtOUV2Ib8DUE/O77VN9T0Gyrm7Wgbp+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ypyz7nZdN21CCri9s9Ywu4sWhpUGSbE6iGUgu9NTwUPntxm7Vg7LJxNbSWCK/DZic 54liGImMAOL5lMdhrSV4/P8GFNLPn8oxDSBeUTa5XpEFmIwOND7YIW4zNyR+SjjrSx o3JE2JMQYNH0g24zERfl+vULceLZUeWRTgil9Gf0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Vlastimil Babka , Marco Elver , "Lin, Zhenpeng" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 78/90] mm/slub: clarify verification reporting Date: Mon, 21 Jun 2021 18:15:53 +0200 Message-Id: <20210621154906.798748669@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook commit 8669dbab2ae56085c128894b181c2aa50f97e368 upstream. Patch series "Actually fix freelist pointer vs redzoning", v4. This fixes redzoning vs the freelist pointer (both for middle-position and very small caches). Both are "theoretical" fixes, in that I see no evidence of such small-sized caches actually be used in the kernel, but that's no reason to let the bugs continue to exist, especially since people doing local development keep tripping over it. :) This patch (of 3): Instead of repeating "Redzone" and "Poison", clarify which sides of those zones got tripped. Additionally fix column alignment in the trailer. Before: BUG test (Tainted: G B ): Redzone overwritten ... Redzone (____ptrval____): bb bb bb bb bb bb bb bb ........ Object (____ptrval____): f6 f4 a5 40 1d e8 ...@.. Redzone (____ptrval____): 1a aa .. Padding (____ptrval____): 00 00 00 00 00 00 00 00 ........ After: BUG test (Tainted: G B ): Right Redzone overwritten ... Redzone (____ptrval____): bb bb bb bb bb bb bb bb ........ Object (____ptrval____): f6 f4 a5 40 1d e8 ...@.. Redzone (____ptrval____): 1a aa .. Padding (____ptrval____): 00 00 00 00 00 00 00 00 ........ The earlier commits that slowly resulted in the "Before" reporting were: d86bd1bece6f ("mm/slub: support left redzone") ffc79d288000 ("slub: use print_hex_dump") 2492268472e7 ("SLUB: change error reporting format to follow lockdep loosely") Link: https://lkml.kernel.org/r/20210608183955.280836-1-keescook@chromium.org Link: https://lkml.kernel.org/r/20210608183955.280836-2-keescook@chromium.org Link: https://lore.kernel.org/lkml/cfdb11d7-fb8e-e578-c939-f7f5fb69a6bd@suse.cz/ Signed-off-by: Kees Cook Acked-by: Vlastimil Babka Cc: Marco Elver Cc: "Lin, Zhenpeng" Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Roman Gushchin Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- Documentation/vm/slub.rst | 10 +++++----- mm/slub.c | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) --- a/Documentation/vm/slub.rst +++ b/Documentation/vm/slub.rst @@ -160,7 +160,7 @@ SLUB Debug output Here is a sample of slub debug output:: ==================================================================== - BUG kmalloc-8: Redzone overwritten + BUG kmalloc-8: Right Redzone overwritten -------------------------------------------------------------------- INFO: 0xc90f6d28-0xc90f6d2b. First byte 0x00 instead of 0xcc @@ -168,10 +168,10 @@ Here is a sample of slub debug output:: INFO: Object 0xc90f6d20 @offset=3360 fp=0xc90f6d58 INFO: Allocated in get_modalias+0x61/0xf5 age=53 cpu=1 pid=554 - Bytes b4 0xc90f6d10: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ - Object 0xc90f6d20: 31 30 31 39 2e 30 30 35 1019.005 - Redzone 0xc90f6d28: 00 cc cc cc . - Padding 0xc90f6d50: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ + Bytes b4 (0xc90f6d10): 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ + Object (0xc90f6d20): 31 30 31 39 2e 30 30 35 1019.005 + Redzone (0xc90f6d28): 00 cc cc cc . + Padding (0xc90f6d50): 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ [] dump_trace+0x63/0x1eb [] show_trace_log_lvl+0x1a/0x2f --- a/mm/slub.c +++ b/mm/slub.c @@ -688,15 +688,15 @@ static void print_trailer(struct kmem_ca p, p - addr, get_freepointer(s, p)); if (s->flags & SLAB_RED_ZONE) - print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, + print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, s->red_left_pad); else if (p > addr + 16) print_section(KERN_ERR, "Bytes b4 ", p - 16, 16); - print_section(KERN_ERR, "Object ", p, + print_section(KERN_ERR, "Object ", p, min_t(unsigned int, s->object_size, PAGE_SIZE)); if (s->flags & SLAB_RED_ZONE) - print_section(KERN_ERR, "Redzone ", p + s->object_size, + print_section(KERN_ERR, "Redzone ", p + s->object_size, s->inuse - s->object_size); off = get_info_end(s); @@ -708,7 +708,7 @@ static void print_trailer(struct kmem_ca if (off != size_from_object(s)) /* Beginning of the filler is the free pointer */ - print_section(KERN_ERR, "Padding ", p + off, + print_section(KERN_ERR, "Padding ", p + off, size_from_object(s) - off); dump_stack(); @@ -882,11 +882,11 @@ static int check_object(struct kmem_cach u8 *endobject = object + s->object_size; if (s->flags & SLAB_RED_ZONE) { - if (!check_bytes_and_report(s, page, object, "Redzone", + if (!check_bytes_and_report(s, page, object, "Left Redzone", object - s->red_left_pad, val, s->red_left_pad)) return 0; - if (!check_bytes_and_report(s, page, object, "Redzone", + if (!check_bytes_and_report(s, page, object, "Right Redzone", endobject, val, s->inuse - s->object_size)) return 0; } else { @@ -901,7 +901,7 @@ static int check_object(struct kmem_cach if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) && (!check_bytes_and_report(s, page, p, "Poison", p, POISON_FREE, s->object_size - 1) || - !check_bytes_and_report(s, page, p, "Poison", + !check_bytes_and_report(s, page, p, "End Poison", p + s->object_size - 1, POISON_END, 1))) return 0; /*