Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4719438pxt; Wed, 11 Aug 2021 12:26:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiAOGuI+0PdsA0n4Ngg/SJMWN8E+lQxgqIV9rtiPQYUkrmwrBxjA0NmCnjFn/6UemOeNi9 X-Received: by 2002:a05:6e02:12e7:: with SMTP id l7mr54449iln.60.1628709984686; Wed, 11 Aug 2021 12:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628709984; cv=none; d=google.com; s=arc-20160816; b=Px3MwE5X3o8etYcGFYIagYdIAEQ/UbG7stfvZo3TC+sg6PKNZvHUDzU0fXkezVlen/ OSKGYhwr+GmrQfnD9kVx6TMdyCPI5CIiLDMaqTKYt/c/psGv8KP9aFJpkidVUC7TS+tB FtummXRRpiNaos4zihAL2PlrDepWGFNFKdLs9EbLmibkIuQfMSu5qdvxm4P2GMhq17Oc ikN4GUvTBnXIuum+TVeKQd3rdqFHByHzP/vdm8mB/XdF1CWWgvEL3TDxdjQ2s5dpNJXf EwCIr7lVrrcB/7syNEAnxYjKSyjcLje1oH7wzljkt39YCPpY+2slYn/YkbdL6kIlknh1 mtVQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ID41gjBfMNhlXLlGhJT64AiAC6qEC6DO99tAHE2Cp4g=; b=E1aHqRcJdHLKqKnrs1i+TOhDhDNLjNjo1os5lWybBGH0DE+qy5kf6tI7OfArYrfcub E7585hUmyHXuvPlM6zo30HNUBNvQwH1pleY/cd3cldKBl+Nm3LyHBUZfHijXE59ORToY CGcDuYS/7TiL9UmPtPCseXqLcg2OIMwMZH1OEjjBSdaW6opeR2249CaOnoEKrHl5aKKc AMh4orbBLHIgRe3FwPFO3LLw2qzCTRlu85kKjK1G83vUw+6gd+scwCv9OcfPeYmEO356 nr9kSnZUizda9j99mJaaw3wM/bw6IBcMIobWtBk9chS5FANqDvqr3jwhlbI/o8c42Iqg 3E5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mtaLyk+u; 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=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si331659jap.71.2021.08.11.12.26.13; Wed, 11 Aug 2021 12:26:24 -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=@linux.dev header.s=key1 header.b=mtaLyk+u; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbhHKTX4 (ORCPT + 99 others); Wed, 11 Aug 2021 15:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbhHKTXz (ORCPT ); Wed, 11 Aug 2021 15:23:55 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48EB9C061765 for ; Wed, 11 Aug 2021 12:23:31 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1628709809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ID41gjBfMNhlXLlGhJT64AiAC6qEC6DO99tAHE2Cp4g=; b=mtaLyk+u+7oahzj0rZrPKhnCKDj1VnWLI/BvMsIE5go8IFuNIG353HryB0EuoqyAdQ6tkq UyokZYQ0HVMRMvSM7FLSpyM/dyF8TOAMvNIYb/2ErEGbEIki37f7OSuQ2troKaEJ8+yg0J jQVLeBU+O0GhXExvNwmkLdJBD2+RztU= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Andrey Ryabinin , Marco Elver , Dmitry Vyukov , Alexander Potapenko , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] kasan: test: clean up ksize_uaf Date: Wed, 11 Aug 2021 21:23:27 +0200 Message-Id: <3773f984cbd64f008af9b03e82fc1b317cda9fda.1628709663.git.andreyknvl@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: andrey.konovalov@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov Some KASAN tests use global variables to store function returns values so that the compiler doesn't optimize away these functions. ksize_uaf() doesn't call any functions, so it doesn't need to use kasan_int_result. Use volatile accesses instead, to be consistent with other similar tests. Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index efd0da5c750f..e159d24b3b49 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -731,8 +731,8 @@ static void ksize_uaf(struct kunit *test) kfree(ptr); KUNIT_EXPECT_KASAN_FAIL(test, ksize(ptr)); - KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = *ptr); - KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = *(ptr + size)); + KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[0]); + KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)ptr)[size]); } static void kasan_stack_oob(struct kunit *test) -- 2.25.1