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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 E1CCFC43457 for ; Thu, 15 Oct 2020 03:37:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6494320691 for ; Thu, 15 Oct 2020 03:37:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SLL26Mxq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6494320691 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D0FAB6B0072; Wed, 14 Oct 2020 23:37:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C763C6B0073; Wed, 14 Oct 2020 23:37:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B98656B0074; Wed, 14 Oct 2020 23:37:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id 850486B0072 for ; Wed, 14 Oct 2020 23:37:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1E7881EF1 for ; Thu, 15 Oct 2020 03:37:19 +0000 (UTC) X-FDA: 77372749398.15.bee15_501859627211 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id E9EB51814B0C1 for ; Thu, 15 Oct 2020 03:37:18 +0000 (UTC) X-HE-Tag: bee15_501859627211 X-Filterd-Recvd-Size: 8188 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 03:37:18 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id n14so1133194pff.6 for ; Wed, 14 Oct 2020 20:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oE8671fGdc7a/ra0xKjfKpYochKuO322S/sLHjna38o=; b=SLL26MxqLUcSnVrzPPc8gZDG5nPisgFw+JOp2uG+hiEng9js/7mqB0nxf35Tyi2S6Q OFVkrwpHysGEtXORm5Pew42lpCgG1xEiXWRIf0hb9R9BZJPDMYF081NW3O+JjJ+mfjZ2 hvCYBkxSNm3g5s6s6XJS0x8Mr6HYpttqhdhJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oE8671fGdc7a/ra0xKjfKpYochKuO322S/sLHjna38o=; b=ZQ8N9GOaDXy7zHmOKOXkDRTOmScpB8+BOlAvai9OD9311PX4fZJVaEGVm1vtP936aK yyb6V+L90981gBICVi8yNkxLypLGyG6f3Y/a/X86+LL1/hf1LQ7ULOMgh+ajyy4mZqen CpC+A5Zza4RjfVa69wA15oheSoIb/D7vKeFnMXHzOXarPUZXDtU5Ml2f3CyJmnhzDWpY 4+SUfbWsW1id4jbRtiKt4RgLxumwa0LvDfFVdRzTR1PLz2SR2nWBSO/mv+JEQUymIF8V c7FICZuUF8uleCWXpsOYVbuMnxdtg7VA6T1eUjWJ3Da0yh+JLYIShr0+aO+UlLYryo4e ynHw== X-Gm-Message-State: AOAM533M/iOEhVGMwu3yK3Uben3uD7xxBRX3zE+lw9qI7KiYkQ1CEmlH 7/yvcFw5Q+qpNBIH1PzP7mysQg== X-Google-Smtp-Source: ABdhPJxemA8WjaemcI4SUPAgMwduvheXLqyw4BgpfqXRgW9RfNWCCl3QpfT4dnDHY30ExHKaHqU6JQ== X-Received: by 2002:a63:cc42:: with SMTP id q2mr1820442pgi.216.1602733037644; Wed, 14 Oct 2020 20:37:17 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o4sm1077806pjp.37.2020.10.14.20.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 20:37:14 -0700 (PDT) From: Kees Cook To: Andrew Morton Cc: Kees Cook , Vlastimil Babka , Christoph Lameter , Waiman Long , Marco Elver , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 1/3] mm/slub: Clarify verification reporting Date: Wed, 14 Oct 2020 20:37:10 -0700 Message-Id: <20201015033712.1491731-2-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015033712.1491731-1-keescook@chromium.org> References: <20201015033712.1491731-1-keescook@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: 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 lo= osely") Signed-off-by: Kees Cook Acked-by: Vlastimil Babka Link: https://lore.kernel.org/lkml/cfdb11d7-fb8e-e578-c939-f7f5fb69a6bd@s= use.cz/ --- Documentation/vm/slub.rst | 10 +++++----- mm/slub.c | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Documentation/vm/slub.rst b/Documentation/vm/slub.rst index 289d231cee97..77c7a3331eda 100644 --- a/Documentation/vm/slub.rst +++ b/Documentation/vm/slub.rst @@ -181,7 +181,7 @@ SLUB Debug output Here is a sample of slub debug output:: =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - BUG kmalloc-8: Redzone overwritten + BUG kmalloc-8: Right Redzone overwritten -------------------------------------------------------------------- =20 INFO: 0xc90f6d28-0xc90f6d2b. First byte 0x00 instead of 0xcc @@ -189,10 +189,10 @@ Here is a sample of slub debug output:: INFO: Object 0xc90f6d20 @offset=3D3360 fp=3D0xc90f6d58 INFO: Allocated in get_modalias+0x61/0xf5 age=3D53 cpu=3D1 pid=3D554 =20 - 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 1= 019.005 - Redzone 0xc90f6d28: 00 cc cc cc . - Padding 0xc90f6d50: 5a 5a 5a 5a 5a 5a 5a 5a Z= ZZZZZZZ + 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 =20 [] dump_trace+0x63/0x1eb [] show_trace_log_lvl+0x1a/0x2f diff --git a/mm/slub.c b/mm/slub.c index 6d3574013b2f..f4f1d63f0ab9 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -698,15 +698,15 @@ static void print_trailer(struct kmem_cache *s, str= uct page *page, u8 *p) p, p - addr, get_freepointer(s, p)); =20 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); =20 - 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); =20 off =3D get_info_end(s); @@ -718,7 +718,7 @@ static void print_trailer(struct kmem_cache *s, struc= t page *page, u8 *p) =20 if (off !=3D 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); =20 dump_stack(); @@ -895,11 +895,11 @@ static int check_object(struct kmem_cache *s, struc= t page *page, u8 *endobject =3D object + s->object_size; =20 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; =20 - 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 { @@ -914,7 +914,7 @@ static int check_object(struct kmem_cache *s, struct = page *page, if (val !=3D 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; /* --=20 2.25.1