From patchwork Wed Mar 16 14:38:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 12782757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 637C1C433F5 for ; Wed, 16 Mar 2022 14:38:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 763116B0071; Wed, 16 Mar 2022 10:38:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7128E8D0002; Wed, 16 Mar 2022 10:38:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D9E18D0001; Wed, 16 Mar 2022 10:38:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 4A0B66B0071 for ; Wed, 16 Mar 2022 10:38:53 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0EE372318F for ; Wed, 16 Mar 2022 14:38:53 +0000 (UTC) X-FDA: 79250506146.09.061A29B Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf29.hostedemail.com (Postfix) with ESMTP id A02CB120016 for ; Wed, 16 Mar 2022 14:38:52 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id z16so4138466pfh.3 for ; Wed, 16 Mar 2022 07:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HRSEkw1CwIUBYt3oT8CIfHxPAh4A2dT5S1V22XBxkjY=; b=L6EEIt20AmsUK5UdjWUgnow+eqiw93e5FY88u9E2+IretKfpFZH1NIyQVQzrxaCqAc rs16BWjxmzNKNQy03CFfe04mar03DNCDhw+2NPVoxW/ORP63R8Tqy2SCir9QlC+dPjof lYvZbQegOc7gTahSofq0Fm44BQHyIzORz7jW0SoAVwDKm24B7uGsNKAElmLbuLui3JJb NZ4N9/cHxEjxnKZQOnzgbw4ZPhfBRNGuTJhY1CqIx+dluGDxAfb9MlhI1/PjKkkdLFgm wef68rmC8tX6hq/f8iC0ZFW7tmoyWQ9LKTA+RW9MLCjHId5b1b2tIa3qcvGNkUtG4HYj QuyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HRSEkw1CwIUBYt3oT8CIfHxPAh4A2dT5S1V22XBxkjY=; b=bj5jkUOD8yT3Dc0s5JG0ZreAFCPc625TWIYJEYK5zt39rSVrW/7utEjFIsNRgOwt+3 RlC6U1kWvoyP72zsBJ2PfYbcPFHXDSisLd8dUVZJhEA102oqrZdgLJlqh0N/ghS0voog kUoPBJxIEXshMnhjDjnIlFvJYRuAhTOFlDc2iwsXGamsx7HuPX+HKaZrsLIRO/fGrOVq RaxNi7n+0dRfrdCngWS/gjDbo3r7U+cBpFHkO5So+u+EvV9DgIbY/G6PYDmdHCh9VTuB wT19SYw9Al4CLt+kBjg9v/2ckygPwSOAhYoS1jVEwXbYQmUFkwvr37PfY3Lo1JgRTAyD QNXw== X-Gm-Message-State: AOAM531JbsWbQlVFwXdrvtYxR4z76CCoHSd/FL4dptRHhpPaGqwEKsWO pShqLyuHdkk10zCdU4DVwCIGNWnAH55AuQ== X-Google-Smtp-Source: ABdhPJz5IzSAdgsu4JJ+KSDgRtM8RovxGtSnmWufop8aqc51YiNJlEq04WNxYF9GNbobbyptSjWfzg== X-Received: by 2002:a62:f203:0:b0:4f6:f330:7e56 with SMTP id m3-20020a62f203000000b004f6f3307e56mr34436386pfh.49.1647441531140; Wed, 16 Mar 2022 07:38:51 -0700 (PDT) Received: from ip-172-31-19-208.ap-northeast-1.compute.internal (ec2-18-181-137-102.ap-northeast-1.compute.amazonaws.com. [18.181.137.102]) by smtp.gmail.com with ESMTPSA id w27-20020a637b1b000000b00380437ab89asm2671062pgc.50.2022.03.16.07.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 07:38:50 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: linux-mm@kvack.org Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , 42.hyeyoo@gmail.com, Oliver Glitta Subject: [PATCH] mm/slub, kunit: Make slub_kunit pass even when SLAB_RED_ZONE flag is set Date: Wed, 16 Mar 2022 14:38:41 +0000 Message-Id: <20220316143841.160373-1-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: A02CB120016 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=L6EEIt20; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 3qusxmcegudqmme1rjaoxtrox9xb4snj X-Rspamd-Server: rspam07 X-HE-Tag: 1647441532-225068 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: Testcase test_next_pointer in slub_kunit fails when SLAB_RED_ZONE flag is globally set. This is because on_freelist() cuts corrupted freelist chain and does not update cut objects' redzone to SLUB_RED_ACTIVE. When the test validates a slab that whose freelist is cut, it expects redzone of objects unreachable by freelist is set to SLUB_RED_ACTIVE. And it reports "Left Redzone overritten" error because the expectation failed. This patch makes slub_kunit expect two more errors for reporting and fixing red overwritten error when SLAB_RED_ZONE flag is set. The test passes on slub_debug and slub_debug=Z after this patch. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- lib/slub_kunit.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index 8662dc6cb509..7cf1fb5a7fde 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -45,21 +45,36 @@ static void test_next_pointer(struct kunit *test) * Expecting three errors. * One for the corrupted freechain and the other one for the wrong * count of objects in use. The third error is fixing broken cache. + * + * When flag SLUB_RED_ZONE is set, we expect two more errors for reporting + * and fixing overwritten redzone error. This two errors are detected + * because SLUB cuts corrupted freelist in on_freelist(), but does not + * update its redzone to SLUB_RED_ACTIVE. */ validate_slab_cache(s); - KUNIT_EXPECT_EQ(test, 3, slab_errors); + + if (s->flags & SLAB_RED_ZONE) + KUNIT_EXPECT_EQ(test, 5, slab_errors); + else + KUNIT_EXPECT_EQ(test, 3, slab_errors); /* * Try to repair corrupted freepointer. * Still expecting two errors. The first for the wrong count * of objects in use. * The second error is for fixing broken cache. + * + * When SLUB_RED_ZONE flag is set, we expect two more errors + * for same reason as above. */ *ptr_addr = tmp; slab_errors = 0; validate_slab_cache(s); - KUNIT_EXPECT_EQ(test, 2, slab_errors); + if (s->flags & SLAB_RED_ZONE) + KUNIT_EXPECT_EQ(test, 4, slab_errors); + else + KUNIT_EXPECT_EQ(test, 2, slab_errors); /* * Previous validation repaired the count of objects in use.