From patchwork Sat Feb 19 01:26:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12752123 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 02450C433F5 for ; Sat, 19 Feb 2022 01:26:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76F916B0074; Fri, 18 Feb 2022 20:26:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71F9D6B0075; Fri, 18 Feb 2022 20:26:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E77F6B0078; Fri, 18 Feb 2022 20:26:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 4F9B26B0074 for ; Fri, 18 Feb 2022 20:26:51 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 10D05605DD for ; Sat, 19 Feb 2022 01:26:51 +0000 (UTC) X-FDA: 79157790222.05.E42FEC3 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf10.hostedemail.com (Postfix) with ESMTP id 82A29C0003 for ; Sat, 19 Feb 2022 01:26:49 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id a19-20020a25ca13000000b0061db44646b3so15478181ybg.2 for ; Fri, 18 Feb 2022 17:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=GR0HxBHdu+1whCHjKpBJmBVcaIZPKqMpbWMwF7BnSY8=; b=fMEgejCbPgVKrgzNzH9q5GR2hVegi4vQ9kx5M/fxJ6Nzw+1qN0hW1Lb6fnpPo623y0 z7BxNjM0rgrWN7APnP4lD1JmREkpk5+puqNSlC6gDkGwg414tKKXaY2IBznKXo9ceKhd 353poi0NalP1IZYMBO7GR5DS56q1S6LCx/kxLwGKkmQ5AqCblRN5VCRjMBhfQSswc4jF 6r24V/oUlFGUX+g2GQMgOpeWSSO3FZEOCRVKFzLWmXu/ANnzNQauOSEhByVpOwOYByyX 7UGrJpjzyRecvgoKD1JayKBtRRwemonvnb2eGUSLth7C+4DaiEfXleVWyHZ3XNNUeTA8 mo2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=GR0HxBHdu+1whCHjKpBJmBVcaIZPKqMpbWMwF7BnSY8=; b=imQntQ0V54Xvu9kdMyMzAF8JhCTVS8rKI1itwVCDD8VvsOSDkXcE3fKDfIcHRhn+wy 5S/HYJk6gPnxeIYW9cR56/RBVhzGu+OPv8elpDEN7NsXriZEA2Lag3jpdYG9666l7cIn Qpp+n/e+4NdbkTPWFLWU4ska6bdq/YXbrLfbA7wFcBjXnbEfdcpWClavWmioOvhAxdch Vzm/3lELv1BOo48A3k4yBnB/YIJa83LxUWX7InL/rxXfDFTg7Zwkbpz3smGF5jf4EH3N 8Ttn89DD5MsYyk8n42EMYvEBKD/hNHwZnkEYrTavl5gLdHhSFFZCFNPBRlkXFKSwiXOD ClaA== X-Gm-Message-State: AOAM532M9dZP/IjeFmtgVNUYWCpSCszmPEOky7NGpwAhPIbARGyb/56s ArbRqlHWDvzqE/kcNKiphqcZBfw= X-Google-Smtp-Source: ABdhPJyKAv/S51NatxlTTYsdmi7kUKMFu2MgGGVbvpFKoRd7A29DxVM5ugfVroTyk9hFZTBctlyYI2c= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:4926:4660:7cdf:2d]) (user=pcc job=sendgmr) by 2002:a25:ec01:0:b0:61d:917f:66f0 with SMTP id j1-20020a25ec01000000b0061d917f66f0mr10067213ybh.22.1645234008848; Fri, 18 Feb 2022 17:26:48 -0800 (PST) Date: Fri, 18 Feb 2022 17:26:43 -0800 Message-Id: <20220219012643.892158-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog Subject: [PATCH] kasan: fix more unit tests with CONFIG_UBSAN_LOCAL_BOUNDS enabled From: Peter Collingbourne To: Andrey Konovalov , Marco Elver Cc: Peter Collingbourne , Kees Cook , Andrew Morton , linux-mm@kvack.org, stable@vger.kernel.org Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=fMEgejCb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 3WEcQYgMKCD8qddhpphmf.dpnmjovy-nnlwbdl.psh@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3WEcQYgMKCD8qddhpphmf.dpnmjovy-nnlwbdl.psh@flex--pcc.bounces.google.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 82A29C0003 X-Stat-Signature: yz4bsrfa5g6f7xece8f1bxb96jph5cor X-HE-Tag: 1645234009-950381 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: This is a followup to commit f649dc0e0d7b ("kasan: fix unit tests with CONFIG_UBSAN_LOCAL_BOUNDS enabled") that fixes tests that fail as a result of __alloc_size annotations being added to the kernel allocator functions. Link: https://linux-review.googlesource.com/id/I4334cafc5db600fda5cebb851b2ee9fd09fb46cc Signed-off-by: Peter Collingbourne Cc: # 5.16.x Fixes: c37495d6254c ("slab: add __alloc_size attributes for better bounds checking") --- lib/test_kasan.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 26a5c9007653..3bf8801d0e66 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -177,7 +177,8 @@ static void kmalloc_node_oob_right(struct kunit *test) */ static void kmalloc_pagealloc_oob_right(struct kunit *test) { - char *ptr; + /* See comment in kasan_global_oob_right. */ + char *volatile ptr; size_t size = KMALLOC_MAX_CACHE_SIZE + 10; KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_SLUB); @@ -272,7 +273,8 @@ static void kmalloc_large_oob_right(struct kunit *test) static void krealloc_more_oob_helper(struct kunit *test, size_t size1, size_t size2) { - char *ptr1, *ptr2; + /* See comment in kasan_global_oob_right. */ + char *ptr1, *volatile ptr2; size_t middle; KUNIT_ASSERT_LT(test, size1, size2); @@ -304,7 +306,8 @@ static void krealloc_more_oob_helper(struct kunit *test, static void krealloc_less_oob_helper(struct kunit *test, size_t size1, size_t size2) { - char *ptr1, *ptr2; + /* See comment in kasan_global_oob_right. */ + char *ptr1, *volatile ptr2; size_t middle; KUNIT_ASSERT_LT(test, size2, size1);