From nobody Wed Nov 27 04:29:39 2024 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 505DE5A4D5; Mon, 14 Oct 2024 02:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728874568; cv=none; b=M5jEl37cNN0+9ukapT6iwBQsqjdP2nPwfD023nat22EeZJNZNLEygZr2m7gyiMrRCgSd/Q2fS2b2Qq+tpAytWFt9eK9c2I4Nt1yUtQXni/gQWUhJ6nm/sRx79TPWd5hhh/kF19LAkYphMpzuXLHuPG+SpMdLQwonSGXMPY1AESY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728874568; c=relaxed/simple; bh=Qe2ChtW/mBRF94ySzEHdaeNT66y9rdZInIjzCEIRchI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i40RvNxG6uVI/ug0R9iz97bb4quj4QoNalXBiQMB3Z5B7d/UTkINmC9CzASz5wQlhOBSBh8ahs8QJ27TT3e5vC2DALoftG1QuzR7gVIvuu1ZajldedOaytujbrN1bKV0CQlz+ifqtLI2Yx5cwPT+gHvw4e/iqP8u3g6lL5QRPOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BL0ZrgUn; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BL0ZrgUn" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5c96936065dso1537612a12.3; Sun, 13 Oct 2024 19:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728874565; x=1729479365; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fsia9jopa1EBGuIlree1T5OAe+wj8zghwoJWVSExaNA=; b=BL0ZrgUnE8KYw819rzDDM98Nda7D5h2637zGFp/eIa5fwGhXjyVD6kgbaI+/LAa2Gu 4ayh7NsVKJdJqregKkNRHLhcA7+AGY495irr+3yHRyYwW0wERUNdS/ZyYMAhgHIYMcoF vBZkJxJ11pBR9+FNRUul92QI1w/APdQHmD7FsiBx/1rrfD/SF7OOhGB5uXYgrBBPNgR0 aC31+SgTBUaKv9gNAKiHYcSSbHFAcVUFd1UyClj/dfUVbqQu58Zpg3b3Al42lUbHEA5k 1JLV4mKJ/85pjouSoC18XnC0PvpoewL90livGsNTvE5HJXZN2eG8vtUNlV2w+8PT7/8J re0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728874565; x=1729479365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fsia9jopa1EBGuIlree1T5OAe+wj8zghwoJWVSExaNA=; b=MXTo7RtNNqksyVtyr+bKfX/agOpSdwZRBObhMecLgaa6q+rGH23FQl82lT12aTji7A 8ZLsZQwiBJtbmDP+Z3mhiPD/WI7LbCzdEiXPvsN75YkEROMc0BmIuiBayZt/KHyf4jOD QzpYybT/XmnShOtfhrD7tGYdFlPJ+jdjMg7xAg1TZRDn2O4YyTjmh9IeqLL79FZ1kpz2 Po40a5ofLTIV8EDp6Bwy2PGxqaR1dvrBRFWfQ/3OEMJyqptkebd7hgU1dbCRMEDz37Al HnLc3qHU3CFKnMeOeOTV5EhDkwFB0wPBq31p2TqEXY62avLkScnSAWed9j8griMB7oGU L/mg== X-Forwarded-Encrypted: i=1; AJvYcCUag4GWUnYoNd5bXRjkJV1J9eKg9lqbzhiqC6tPJXyTrKUON6zrXWiFq/BXrUKDNabx4HR1+La+C3gZSsCZ@vger.kernel.org, AJvYcCVFm7Pc/oCCTZGpSNE7S96goy67AcswK8FcVNDZBPADsY2qsR+pceJoo3GBe/0ZGNxTB44pf0PJDok=@vger.kernel.org, AJvYcCXfYBWRWa+YT4QAlwttBIPGha3cTHra096VCpEWz4qGssIvPC8dOxgK7S40/A0Oje2vKLKLDVSq1OTM@vger.kernel.org X-Gm-Message-State: AOJu0YxyglI+Vdux8OES8BC4WPrvOkY2Lg4SbM9HA3NGgw6ShcTzRQix IMH1EjMqGasL/qfcVSuNxs3859apBtVK9uE7P81rsBy9HD2il+zT X-Google-Smtp-Source: AGHT+IGnwwZeigphOJ9brMGXGLoktj1FJV8WBeBfj1WroyrEnTp3w3CdGAC9gyG0bLeuTFdMUZwEGA== X-Received: by 2002:a17:906:6a12:b0:a99:742c:5c7 with SMTP id a640c23a62f3a-a99b9305ed1mr791073066b.10.1728874565516; Sun, 13 Oct 2024 19:56:05 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99ebdfbff1sm270501366b.39.2024.10.13.19.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 19:56:05 -0700 (PDT) From: Sabyrzhan Tasbolatov To: andreyknvl@gmail.com Cc: 2023002089@link.tyut.edu.cn, akpm@linux-foundation.org, alexs@kernel.org, corbet@lwn.net, dvyukov@google.com, elver@google.com, glider@google.com, kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ryabinin.a.a@gmail.com, siyanteng@loongson.cn, snovitoll@gmail.com, vincenzo.frascino@arm.com, workflows@vger.kernel.org Subject: [PATCH RESEND v3 1/3] kasan: move checks to do_strncpy_from_user Date: Mon, 14 Oct 2024 07:56:59 +0500 Message-Id: <20241014025701.3096253-2-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014025701.3096253-1-snovitoll@gmail.com> References: <20241014025701.3096253-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since in the commit 2865baf54077("x86: support user address masking instead of non-speculative conditional") do_strncpy_from_user() is called from multiple places, we should sanitize the kernel *dst memory and size which were done in strncpy_from_user() previously. Fixes: 2865baf54077 ("x86: support user address masking instead of non-spec= ulative conditional") Reviewed-by: Andrey Konovalov Signed-off-by: Sabyrzhan Tasbolatov --- lib/strncpy_from_user.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index 989a12a6787..f36ad821176 100644 --- a/lib/strncpy_from_user.c +++ b/lib/strncpy_from_user.c @@ -31,6 +31,9 @@ static __always_inline long do_strncpy_from_user(char *ds= t, const char __user *s const struct word_at_a_time constants =3D WORD_AT_A_TIME_CONSTANTS; unsigned long res =3D 0; =20 + kasan_check_write(dst, count); + check_object_size(dst, count, false); + if (IS_UNALIGNED(src, dst)) goto byte_at_a_time; =20 @@ -142,8 +145,6 @@ long strncpy_from_user(char *dst, const char __user *sr= c, long count) if (max > count) max =3D count; =20 - kasan_check_write(dst, count); - check_object_size(dst, count, false); if (user_read_access_begin(src, max)) { retval =3D do_strncpy_from_user(dst, src, count, max); user_read_access_end(); --=20 2.34.1 From nobody Wed Nov 27 04:29:39 2024 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DE193CF73; Mon, 14 Oct 2024 02:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728874606; cv=none; b=a/UfvFH2LApRC5Dt/DX1qOmMlRYE91eUttdK+Equf+IR1zJnbpSEmgKmFVi3DwHlsIjsr75mIu5bwzVFaRFRNej2cJJe610H45f/n4EXssBscrRFwXcISafAiVz+n+iHGtQ4wFN2/dT4tsk+kNvmlMiJi8MsjDnrS7I5zseiddY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728874606; c=relaxed/simple; bh=3nJnFVnwR+L3Z18DYoST7sOHYfHg//9WUdBRCtPPyWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hSi4DnnzA5enOLOvnjPHuyZP/w2FcnafXj9S+WOKzY/2Ko3sWDT9V8j1UEipynN8jeDP2GHEiSqiOgxqYGveBd0MWOKLN1dBE1/E+jfAf67Tkb3upML5Mzbxlq5ewHSCKKkhf7nw6imgADNk4AH9FevYmOcXDnwT0FbuGVG6RQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VcvMalOO; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VcvMalOO" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a99f1fd20c4so220805966b.0; Sun, 13 Oct 2024 19:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728874603; x=1729479403; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/8xPPGnp2eNdFzyDsH77udpuxb5hGHHiKYVsaBBQcww=; b=VcvMalOOiVxQDojiwALQKOK7h9mXaO1kSU59jDQr8C+yZ/MNncxYvjG6ttUiC5yyvf IaQaDSoDkfIJzJtqaDlBQ9ItQN4Qef5ImVWvhPwUNnzwVVZZzE+FBpMtfln3FdlKW67w kZlP5Br+Cb9T6u1JmqwiCLox+44U9kYd2KyqPkK9mJKe0U3a6zQ0W75uFFxMnvOSnzi0 0ZN2kPgkvB8ZbHdudPZ+veS/JBxb8XZN5oQ15ShnHuU/E1oLVbvymsw0Ocf7WLAVYBqU sQgAZ0U9HmhVU7EcISXBG00YIfDtSz7m7LudYdUCAv/2oa03lqQ5zz1gTl/6UP4HCE0Z SizQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728874603; x=1729479403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/8xPPGnp2eNdFzyDsH77udpuxb5hGHHiKYVsaBBQcww=; b=Y9rRP8WqUVPZSegOY4eghER9bIxK4du7/nZ7u+CeQqaGIPnWdDDxxdYe7ZUKO48BND +txEw+IG4JeiWvEDyFidoVs1tInCLRkf2/CqTXep0jAknVdbQ48a0THmxnaylt3ejFHJ IDHXQy6mjRDRaiWg49/CB73fgpGAnOQ7pd9GiBVEMudqC2Z+9DLBn3xfW7crnuYSsknR PvIK4agyVZW+i/Ru9qEODc14zEfZAk22ugcdXcLV4c3bAw89UJ4J/wvs+s9H0t2hSLaI adpSLPSr6zavd1J9wnTP16HsqN50FrtJ3YuUp+pbAklWmXXWEo4xJYNNhbpU6U99Ro3C I5vw== X-Forwarded-Encrypted: i=1; AJvYcCU3MXVK3iZsNaA4rDoFwHbCJS+ImZpe9zh9at61BkzvnLHvgIdS9iL4wE8DDdj9f31hzojXGZnNrp4=@vger.kernel.org, AJvYcCVaffj4K54njIYTgJ0LHs68OoUbKWVkoq/nzw8+jktpVmwlsZlkXVZXlrjv2Ibx9SoxLsnw87aHbqE8sQhf@vger.kernel.org, AJvYcCXnQJSyWSx3C7RMa7WXlq0nBbWXCYPJnF3Bk+FwoM8MO35gQkMIknF5CA30xICNUu8Xhu/wgOTjuNOI@vger.kernel.org X-Gm-Message-State: AOJu0Yx7jN46bgQ9TUfXGruVNM6mxM9u7Gb1btsHbdLacMOSpe0HrL27 dJqv6MY6OO8zgs6dZZFVckWJ7krRr0NILlvd1mqHlZ8MLD+KHAcC X-Google-Smtp-Source: AGHT+IGg2zTiSP9pkdThFwEPz88Rrc+thazAWWlSrFQkSIpC5/PWk+n9SRWCQsJl50F54xDsLVUSLg== X-Received: by 2002:a17:907:9488:b0:a9a:791:fb86 with SMTP id a640c23a62f3a-a9a0792046fmr282817966b.64.1728874602739; Sun, 13 Oct 2024 19:56:42 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99ebdfbff1sm270501366b.39.2024.10.13.19.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 19:56:42 -0700 (PDT) From: Sabyrzhan Tasbolatov To: andreyknvl@gmail.com Cc: 2023002089@link.tyut.edu.cn, akpm@linux-foundation.org, alexs@kernel.org, corbet@lwn.net, dvyukov@google.com, elver@google.com, glider@google.com, kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ryabinin.a.a@gmail.com, siyanteng@loongson.cn, snovitoll@gmail.com, vincenzo.frascino@arm.com, workflows@vger.kernel.org Subject: [PATCH RESEND v3 2/3] kasan: migrate copy_user_test to kunit Date: Mon, 14 Oct 2024 07:57:00 +0500 Message-Id: <20241014025701.3096253-3-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014025701.3096253-1-snovitoll@gmail.com> References: <20241014025701.3096253-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Migrate the copy_user_test to the KUnit framework to verify out-of-bound detection via KASAN reports in copy_from_user(), copy_to_user() and their static functions. This is the last migrated test in kasan_test_module.c, therefore delete the file. Reviewed-by: Andrey Konovalov Signed-off-by: Sabyrzhan Tasbolatov --- Changes v2 -> v3: - added a long string in usermem for strncpy_from_user. Suggested by Andrey. --- mm/kasan/Makefile | 2 - mm/kasan/kasan_test_c.c | 47 +++++++++++++++++++++ mm/kasan/kasan_test_module.c | 81 ------------------------------------ 3 files changed, 47 insertions(+), 83 deletions(-) delete mode 100644 mm/kasan/kasan_test_module.c diff --git a/mm/kasan/Makefile b/mm/kasan/Makefile index b88543e5c0c..1a958e7c8a4 100644 --- a/mm/kasan/Makefile +++ b/mm/kasan/Makefile @@ -46,7 +46,6 @@ endif =20 CFLAGS_kasan_test_c.o :=3D $(CFLAGS_KASAN_TEST) RUSTFLAGS_kasan_test_rust.o :=3D $(RUSTFLAGS_KASAN) -CFLAGS_kasan_test_module.o :=3D $(CFLAGS_KASAN_TEST) =20 obj-y :=3D common.o report.o obj-$(CONFIG_KASAN_GENERIC) +=3D init.o generic.o report_generic.o shadow.= o quarantine.o @@ -59,4 +58,3 @@ ifdef CONFIG_RUST endif =20 obj-$(CONFIG_KASAN_KUNIT_TEST) +=3D kasan_test.o -obj-$(CONFIG_KASAN_MODULE_TEST) +=3D kasan_test_module.o diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c index a181e4780d9..382bc64e42d 100644 --- a/mm/kasan/kasan_test_c.c +++ b/mm/kasan/kasan_test_c.c @@ -1954,6 +1954,52 @@ static void rust_uaf(struct kunit *test) KUNIT_EXPECT_KASAN_FAIL(test, kasan_test_rust_uaf()); } =20 +static void copy_user_test_oob(struct kunit *test) +{ + char *kmem; + char __user *usermem; + unsigned long useraddr; + size_t size =3D 128 - KASAN_GRANULE_SIZE; + int __maybe_unused unused; + + kmem =3D kunit_kmalloc(test, size, GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, kmem); + + useraddr =3D kunit_vm_mmap(test, NULL, 0, PAGE_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_ANONYMOUS | MAP_PRIVATE, 0); + KUNIT_ASSERT_NE_MSG(test, useraddr, 0, + "Could not create userspace mm"); + KUNIT_ASSERT_LT_MSG(test, useraddr, (unsigned long)TASK_SIZE, + "Failed to allocate user memory"); + + OPTIMIZER_HIDE_VAR(size); + usermem =3D (char __user *)useraddr; + + KUNIT_EXPECT_KASAN_FAIL(test, + unused =3D copy_from_user(kmem, usermem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused =3D copy_to_user(usermem, kmem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused =3D __copy_from_user(kmem, usermem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused =3D __copy_to_user(usermem, kmem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused =3D __copy_from_user_inatomic(kmem, usermem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused =3D __copy_to_user_inatomic(usermem, kmem, size + 1)); + + /* + * Prepare a long string in usermem to avoid the strncpy_from_user test + * bailing out on '\0' before it reaches out-of-bounds. + */ + memset(kmem, 'a', size); + KUNIT_EXPECT_EQ(test, copy_to_user(usermem, kmem, size), 0); + + KUNIT_EXPECT_KASAN_FAIL(test, + unused =3D strncpy_from_user(kmem, usermem, size + 1)); +} + static struct kunit_case kasan_kunit_test_cases[] =3D { KUNIT_CASE(kmalloc_oob_right), KUNIT_CASE(kmalloc_oob_left), @@ -2028,6 +2074,7 @@ static struct kunit_case kasan_kunit_test_cases[] =3D= { KUNIT_CASE(match_all_ptr_tag), KUNIT_CASE(match_all_mem_tag), KUNIT_CASE(rust_uaf), + KUNIT_CASE(copy_user_test_oob), {} }; =20 diff --git a/mm/kasan/kasan_test_module.c b/mm/kasan/kasan_test_module.c deleted file mode 100644 index 27ec22767e4..00000000000 --- a/mm/kasan/kasan_test_module.c +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * Author: Andrey Ryabinin - */ - -#define pr_fmt(fmt) "kasan: test: " fmt - -#include -#include -#include -#include -#include - -#include "kasan.h" - -static noinline void __init copy_user_test(void) -{ - char *kmem; - char __user *usermem; - size_t size =3D 128 - KASAN_GRANULE_SIZE; - int __maybe_unused unused; - - kmem =3D kmalloc(size, GFP_KERNEL); - if (!kmem) - return; - - usermem =3D (char __user *)vm_mmap(NULL, 0, PAGE_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_ANONYMOUS | MAP_PRIVATE, 0); - if (IS_ERR(usermem)) { - pr_err("Failed to allocate user memory\n"); - kfree(kmem); - return; - } - - OPTIMIZER_HIDE_VAR(size); - - pr_info("out-of-bounds in copy_from_user()\n"); - unused =3D copy_from_user(kmem, usermem, size + 1); - - pr_info("out-of-bounds in copy_to_user()\n"); - unused =3D copy_to_user(usermem, kmem, size + 1); - - pr_info("out-of-bounds in __copy_from_user()\n"); - unused =3D __copy_from_user(kmem, usermem, size + 1); - - pr_info("out-of-bounds in __copy_to_user()\n"); - unused =3D __copy_to_user(usermem, kmem, size + 1); - - pr_info("out-of-bounds in __copy_from_user_inatomic()\n"); - unused =3D __copy_from_user_inatomic(kmem, usermem, size + 1); - - pr_info("out-of-bounds in __copy_to_user_inatomic()\n"); - unused =3D __copy_to_user_inatomic(usermem, kmem, size + 1); - - pr_info("out-of-bounds in strncpy_from_user()\n"); - unused =3D strncpy_from_user(kmem, usermem, size + 1); - - vm_munmap((unsigned long)usermem, PAGE_SIZE); - kfree(kmem); -} - -static int __init kasan_test_module_init(void) -{ - /* - * Temporarily enable multi-shot mode. Otherwise, KASAN would only - * report the first detected bug and panic the kernel if panic_on_warn - * is enabled. - */ - bool multishot =3D kasan_save_enable_multi_shot(); - - copy_user_test(); - - kasan_restore_multi_shot(multishot); - return -EAGAIN; -} - -module_init(kasan_test_module_init); -MODULE_LICENSE("GPL"); --=20 2.34.1 From nobody Wed Nov 27 04:29:39 2024 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EBB65336D; Mon, 14 Oct 2024 02:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728874609; cv=none; b=IRmAkeVRzvDPRyweSHftJuWS+1JfWzAsy9qtUOCeBlJ7BsFQg8VZsJi1CNTKwV1uovetIH+d+qABmolMsptudZsbeqrEMx7/hCt8P1PCjTiVQRBttaZsqJ2fYuaa5Vj7Gf8dU39EMq8WpjKd+bE+rNSjyaud1uU8fbP6WL4c4+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728874609; c=relaxed/simple; bh=j4lwfqIfhg3o9c/qxDv63TOPSlOrzp7Cd7ov8oxJkXc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=tfvdn+WX5e5u0rom/J6daEiCc8o6RhENbeqFlQbHKo2XfcigVZQ+NdUR/y5JXf/EbiLtnPXjJL80vJBHgoFFqL2wBuV5EukAk+bFU5C8eFfZgtDJoZp7fppNwyhVRK0dLeOthqvq/ksOnBVLPcZid4ThYmp5BoaStGzcBjpTlwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Tongjfoh; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tongjfoh" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a9a0ef5179dso71908666b.1; Sun, 13 Oct 2024 19:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728874606; x=1729479406; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JGMf0QveJLuqNVGuhCQVRHmO+zBayTHS2lF5VIrEUbY=; b=TongjfohGpxNQG40WWDgKWZcsngHw3EwHvshZVy6cRTvxOxcUOF8hDOn/Kb2RJx+Rm fgOGxRM4V6fGQOOKDK4dTTHSU399nd02zjAIU07xqxG2mqXycycRfuBBWki51zA3Aimk H2cSorz2BgKzvMIjLmFANuFNDfN89CJjMFtoFaIVYQzXrRhrTF13PNBCYqB34bElbUjc 0CzzxsA0aNiVzdDxX+ydkzlWHbdS8pkMjfARfwI9Ru0SRMCHxyAqeK/nFAnOpHNGxMF9 wbPhP5zUTygwtBXUYM//VaCNcrQrR7saPbPtkTUBeu7oMiyxrCYm2OMd+d8Zaz+LFG0q BDvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728874606; x=1729479406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JGMf0QveJLuqNVGuhCQVRHmO+zBayTHS2lF5VIrEUbY=; b=F4RicDHAoQOOeygTw1yWmU9jvnkrxrQ8JMLh2vqO8ba+dhnJJEVYSNAxc34ov3G99I b9Vk4W8tLXRSTcLopk/I4qI7HwZbSdKFsHJtosUGNzrgedo3FWEJAGwJvWjyo4P4YXDD N3X4zVRJEL4pNluf1euv5ZUgGWGhCmwnTis1Dc/ksuP/hTE3iPGMMsaccdR0HlZD2C5c ImIGMxdpPUZdHWE6swtRc0nTIveDbCxMXdUc8jG4NDRSsgvVcNT3eF4ysdcKpmr4QSC/ DugkwvBqW+5IH/Jjet6/LytlE/E27kNz1laD0uGEnREsZjv7v375l6X5cEaUoL0bYx82 tQ8Q== X-Forwarded-Encrypted: i=1; AJvYcCV+8ecSE3zuWJb9WUyR5mFeOp3SqgNcT5abQxp/eSnFJxU8s8le1vGI0r/O9CIzpewWc3eJTCads7/flMVY@vger.kernel.org, AJvYcCWOcwVGTstbToh9l0qRI5u4yA9K94m2VbcV5hJeEeKpSN0zIyirejamjdze1ZNuhAqKTiArXSfI/FH6@vger.kernel.org, AJvYcCWdbu0CLmZD8CBqMWbyrtIHRDWEfwHhD9/C/1rVjlAgUXeFKx/GKa00A0/5+uf6h1kkVF5vWSS9JOU=@vger.kernel.org X-Gm-Message-State: AOJu0YwOgVuXP1LFh4FOmy24w+erG0Qv4bSUorhIjrbIuwhoFU6SDUGP 21B02PpkC68YpyMJXyF2z0vv9uca4qxsAHi0eyD61Cysqm9yVT6P X-Google-Smtp-Source: AGHT+IGlDB8KlTXo7DMjdLaANmivxjxlnYDmQ0l9WvS8pEmuPKYpnSfmCvDI08URAXjBlRXZF+7cEQ== X-Received: by 2002:a17:907:72c1:b0:a9a:17f5:79a8 with SMTP id a640c23a62f3a-a9a17f59d0bmr26163766b.13.1728874606156; Sun, 13 Oct 2024 19:56:46 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99ebdfbff1sm270501366b.39.2024.10.13.19.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 19:56:45 -0700 (PDT) From: Sabyrzhan Tasbolatov To: andreyknvl@gmail.com Cc: 2023002089@link.tyut.edu.cn, akpm@linux-foundation.org, alexs@kernel.org, corbet@lwn.net, dvyukov@google.com, elver@google.com, glider@google.com, kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ryabinin.a.a@gmail.com, siyanteng@loongson.cn, snovitoll@gmail.com, vincenzo.frascino@arm.com, workflows@vger.kernel.org Subject: [PATCH RESEND v3 3/3] kasan: delete CONFIG_KASAN_MODULE_TEST Date: Mon, 14 Oct 2024 07:57:01 +0500 Message-Id: <20241014025701.3096253-4-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014025701.3096253-1-snovitoll@gmail.com> References: <20241014025701.3096253-1-snovitoll@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Since we've migrated all tests to the KUnit framework, we can delete CONFIG_KASAN_MODULE_TEST and mentioning of it in the documentation as well. I've used the online translator to modify the non-English documentation. Reviewed-by: Andrey Konovalov Signed-off-by: Sabyrzhan Tasbolatov --- Changes v2 -> v3: - applied Andrey's patch to modify further kasan.rst. --- Documentation/dev-tools/kasan.rst | 23 ++++++++----------- .../translations/zh_CN/dev-tools/kasan.rst | 20 +++++++--------- .../translations/zh_TW/dev-tools/kasan.rst | 21 ++++++++--------- lib/Kconfig.kasan | 7 ------ mm/kasan/kasan.h | 2 +- mm/kasan/report.c | 2 +- 6 files changed, 28 insertions(+), 47 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/ka= san.rst index d7de44f5339..0a1418ab72f 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -511,19 +511,14 @@ Tests ~~~~~ =20 There are KASAN tests that allow verifying that KASAN works and can detect -certain types of memory corruptions. The tests consist of two parts: +certain types of memory corruptions. =20 -1. Tests that are integrated with the KUnit Test Framework. Enabled with -``CONFIG_KASAN_KUNIT_TEST``. These tests can be run and partially verified +All KASAN tests are integrated with the KUnit Test Framework and can be en= abled +via ``CONFIG_KASAN_KUNIT_TEST``. The tests can be run and partially verifi= ed automatically in a few different ways; see the instructions below. =20 -2. Tests that are currently incompatible with KUnit. Enabled with -``CONFIG_KASAN_MODULE_TEST`` and can only be run as a module. These tests = can -only be verified manually by loading the kernel module and inspecting the -kernel log for KASAN reports. - -Each KUnit-compatible KASAN test prints one of multiple KASAN reports if an -error is detected. Then the test prints its number and status. +Each KASAN test prints one of multiple KASAN reports if an error is detect= ed. +Then the test prints its number and status. =20 When a test passes:: =20 @@ -550,16 +545,16 @@ Or, if one of the tests failed:: =20 not ok 1 - kasan =20 -There are a few ways to run KUnit-compatible KASAN tests. +There are a few ways to run the KASAN tests. =20 1. Loadable module =20 - With ``CONFIG_KUNIT`` enabled, KASAN-KUnit tests can be built as a load= able - module and run by loading ``kasan_test.ko`` with ``insmod`` or ``modpro= be``. + With ``CONFIG_KUNIT`` enabled, the tests can be built as a loadable mod= ule + and run by loading ``kasan_test.ko`` with ``insmod`` or ``modprobe``. =20 2. Built-In =20 - With ``CONFIG_KUNIT`` built-in, KASAN-KUnit tests can be built-in as we= ll. + With ``CONFIG_KUNIT`` built-in, the tests can be built-in as well. In this case, the tests will run at boot as a late-init call. =20 3. Using kunit_tool diff --git a/Documentation/translations/zh_CN/dev-tools/kasan.rst b/Documen= tation/translations/zh_CN/dev-tools/kasan.rst index 4491ad2830e..fd2e3afbdfa 100644 --- a/Documentation/translations/zh_CN/dev-tools/kasan.rst +++ b/Documentation/translations/zh_CN/dev-tools/kasan.rst @@ -422,16 +422,12 @@ KASAN=E8=BF=9E=E6=8E=A5=E5=88=B0vmap=E5=9F=BA=E7=A1= =80=E6=9E=B6=E6=9E=84=E4=BB=A5=E6=87=92=E6=B8=85=E7=90=86=E6=9C=AA=E4=BD=BF= =E7=94=A8=E7=9A=84=E5=BD=B1=E5=AD=90=E5=86=85=E5=AD=98=E3=80=82 ~~~~ =20 =E6=9C=89=E4=B8=80=E4=BA=9BKASAN=E6=B5=8B=E8=AF=95=E5=8F=AF=E4=BB=A5=E9=AA= =8C=E8=AF=81KASAN=E6=98=AF=E5=90=A6=E6=AD=A3=E5=B8=B8=E5=B7=A5=E4=BD=9C=E5= =B9=B6=E5=8F=AF=E4=BB=A5=E6=A3=80=E6=B5=8B=E6=9F=90=E4=BA=9B=E7=B1=BB=E5=9E= =8B=E7=9A=84=E5=86=85=E5=AD=98=E6=8D=9F=E5=9D=8F=E3=80=82 -=E6=B5=8B=E8=AF=95=E7=94=B1=E4=B8=A4=E9=83=A8=E5=88=86=E7=BB=84=E6=88=90: =20 -1. =E4=B8=8EKUnit=E6=B5=8B=E8=AF=95=E6=A1=86=E6=9E=B6=E9=9B=86=E6=88=90=E7= =9A=84=E6=B5=8B=E8=AF=95=E3=80=82=E4=BD=BF=E7=94=A8 ``CONFIG_KASAN_KUNIT_TE= ST`` =E5=90=AF=E7=94=A8=E3=80=82 -=E8=BF=99=E4=BA=9B=E6=B5=8B=E8=AF=95=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87= =E5=87=A0=E7=A7=8D=E4=B8=8D=E5=90=8C=E7=9A=84=E6=96=B9=E5=BC=8F=E8=87=AA=E5= =8A=A8=E8=BF=90=E8=A1=8C=E5=92=8C=E9=83=A8=E5=88=86=E9=AA=8C=E8=AF=81=EF=BC= =9B=E8=AF=B7=E5=8F=82=E9=98=85=E4=B8=8B=E9=9D=A2=E7=9A=84=E8=AF=B4=E6=98=8E= =E3=80=82 +=E6=89=80=E6=9C=89 KASAN =E6=B5=8B=E8=AF=95=E9=83=BD=E4=B8=8E KUnit =E6=B5= =8B=E8=AF=95=E6=A1=86=E6=9E=B6=E9=9B=86=E6=88=90=EF=BC=8C=E5=8F=AF=E9=80=9A= =E8=BF=87 ``CONFIG_KASAN_KUNIT_TEST`` =E5=90=AF=E7=94=A8=E3=80=82 +=E6=B5=8B=E8=AF=95=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87=E5=87=A0=E7=A7=8D= =E4=B8=8D=E5=90=8C=E7=9A=84=E6=96=B9=E5=BC=8F=E8=87=AA=E5=8A=A8=E8=BF=90=E8= =A1=8C=E5=92=8C=E9=83=A8=E5=88=86=E9=AA=8C=E8=AF=81=EF=BC=9B=E8=AF=B7=E5=8F= =82=E9=98=85=E4=BB=A5=E4=B8=8B=E8=AF=B4=E6=98=8E=E3=80=82 =20 -2. =E4=B8=8EKUnit=E4=B8=8D=E5=85=BC=E5=AE=B9=E7=9A=84=E6=B5=8B=E8=AF=95=E3= =80=82=E4=BD=BF=E7=94=A8 ``CONFIG_KASAN_MODULE_TEST`` =E5=90=AF=E7=94=A8=E5= =B9=B6=E4=B8=94=E5=8F=AA=E8=83=BD=E4=BD=9C=E4=B8=BA=E6=A8=A1=E5=9D=97 -=E8=BF=90=E8=A1=8C=E3=80=82=E8=BF=99=E4=BA=9B=E6=B5=8B=E8=AF=95=E5=8F=AA= =E8=83=BD=E9=80=9A=E8=BF=87=E5=8A=A0=E8=BD=BD=E5=86=85=E6=A0=B8=E6=A8=A1=E5= =9D=97=E5=B9=B6=E6=A3=80=E6=9F=A5=E5=86=85=E6=A0=B8=E6=97=A5=E5=BF=97=E4=BB= =A5=E8=8E=B7=E5=8F=96KASAN=E6=8A=A5=E5=91=8A=E6=9D=A5=E6=89=8B=E5=8A=A8=E9= =AA=8C=E8=AF=81=E3=80=82 - -=E5=A6=82=E6=9E=9C=E6=A3=80=E6=B5=8B=E5=88=B0=E9=94=99=E8=AF=AF=EF=BC=8C= =E6=AF=8F=E4=B8=AAKUnit=E5=85=BC=E5=AE=B9=E7=9A=84KASAN=E6=B5=8B=E8=AF=95= =E9=83=BD=E4=BC=9A=E6=89=93=E5=8D=B0=E5=A4=9A=E4=B8=AAKASAN=E6=8A=A5=E5=91= =8A=E4=B9=8B=E4=B8=80=EF=BC=8C=E7=84=B6=E5=90=8E=E6=B5=8B=E8=AF=95=E6=89=93= =E5=8D=B0 -=E5=85=B6=E7=BC=96=E5=8F=B7=E5=92=8C=E7=8A=B6=E6=80=81=E3=80=82 +=E5=A6=82=E6=9E=9C=E6=A3=80=E6=B5=8B=E5=88=B0=E9=94=99=E8=AF=AF=EF=BC=8C= =E6=AF=8F=E4=B8=AA KASAN =E6=B5=8B=E8=AF=95=E9=83=BD=E4=BC=9A=E6=89=93=E5= =8D=B0=E5=A4=9A=E4=BB=BD KASAN =E6=8A=A5=E5=91=8A=E4=B8=AD=E7=9A=84=E4=B8= =80=E4=BB=BD=E3=80=82 +=E7=84=B6=E5=90=8E=E6=B5=8B=E8=AF=95=E4=BC=9A=E6=89=93=E5=8D=B0=E5=85=B6= =E7=BC=96=E5=8F=B7=E5=92=8C=E7=8A=B6=E6=80=81=E3=80=82 =20 =E5=BD=93=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87:: =20 @@ -458,16 +454,16 @@ KASAN=E8=BF=9E=E6=8E=A5=E5=88=B0vmap=E5=9F=BA=E7=A1= =80=E6=9E=B6=E6=9E=84=E4=BB=A5=E6=87=92=E6=B8=85=E7=90=86=E6=9C=AA=E4=BD=BF= =E7=94=A8=E7=9A=84=E5=BD=B1=E5=AD=90=E5=86=85=E5=AD=98=E3=80=82 =20 not ok 1 - kasan =20 -=E6=9C=89=E5=87=A0=E7=A7=8D=E6=96=B9=E6=B3=95=E5=8F=AF=E4=BB=A5=E8=BF=90= =E8=A1=8C=E4=B8=8EKUnit=E5=85=BC=E5=AE=B9=E7=9A=84KASAN=E6=B5=8B=E8=AF=95= =E3=80=82 +=E6=9C=89=E5=87=A0=E7=A7=8D=E6=96=B9=E6=B3=95=E5=8F=AF=E4=BB=A5=E8=BF=90= =E8=A1=8C KASAN =E6=B5=8B=E8=AF=95=E3=80=82 =20 1. =E5=8F=AF=E5=8A=A0=E8=BD=BD=E6=A8=A1=E5=9D=97 =20 - =E5=90=AF=E7=94=A8 ``CONFIG_KUNIT`` =E5=90=8E=EF=BC=8CKASAN-KUnit=E6=B5= =8B=E8=AF=95=E5=8F=AF=E4=BB=A5=E6=9E=84=E5=BB=BA=E4=B8=BA=E5=8F=AF=E5=8A=A0= =E8=BD=BD=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=B9=B6=E9=80=9A=E8=BF=87=E4=BD=BF=E7= =94=A8 - ``insmod`` =E6=88=96 ``modprobe`` =E5=8A=A0=E8=BD=BD ``kasan_test.ko`` = =E6=9D=A5=E8=BF=90=E8=A1=8C=E3=80=82 + =E5=90=AF=E7=94=A8 ``CONFIG_KUNIT`` =E5=90=8E=EF=BC=8C=E5=8F=AF=E4=BB= =A5=E5=B0=86=E6=B5=8B=E8=AF=95=E6=9E=84=E5=BB=BA=E4=B8=BA=E5=8F=AF=E5=8A=A0= =E8=BD=BD=E6=A8=A1=E5=9D=97 + =E5=B9=B6=E9=80=9A=E8=BF=87=E4=BD=BF=E7=94=A8 ``insmod`` =E6=88=96 ``mo= dprobe`` =E5=8A=A0=E8=BD=BD ``kasan_test.ko`` =E6=9D=A5=E8=BF=90=E8=A1=8C= =E3=80=82 =20 2. =E5=86=85=E7=BD=AE =20 - =E9=80=9A=E8=BF=87=E5=86=85=E7=BD=AE ``CONFIG_KUNIT`` =EF=BC=8C=E4=B9= =9F=E5=8F=AF=E4=BB=A5=E5=86=85=E7=BD=AEKASAN-KUnit=E6=B5=8B=E8=AF=95=E3=80= =82=E5=9C=A8=E8=BF=99=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C + =E9=80=9A=E8=BF=87=E5=86=85=E7=BD=AE ``CONFIG_KUNIT``=EF=BC=8C=E6=B5=8B= =E8=AF=95=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=86=85=E7=BD=AE=E3=80=82 =E6=B5=8B=E8=AF=95=E5=B0=86=E5=9C=A8=E5=90=AF=E5=8A=A8=E6=97=B6=E4=BD= =9C=E4=B8=BA=E5=90=8E=E6=9C=9F=E5=88=9D=E5=A7=8B=E5=8C=96=E8=B0=83=E7=94=A8= =E8=BF=90=E8=A1=8C=E3=80=82 =20 3. =E4=BD=BF=E7=94=A8kunit_tool diff --git a/Documentation/translations/zh_TW/dev-tools/kasan.rst b/Documen= tation/translations/zh_TW/dev-tools/kasan.rst index ed342e67d8e..35b7fd18aa4 100644 --- a/Documentation/translations/zh_TW/dev-tools/kasan.rst +++ b/Documentation/translations/zh_TW/dev-tools/kasan.rst @@ -404,16 +404,13 @@ KASAN=E9=80=A3=E6=8E=A5=E5=88=B0vmap=E5=9F=BA=E7=A4= =8E=E6=9E=B6=E6=A7=8B=E4=BB=A5=E6=87=B6=E6=B8=85=E7=90=86=E6=9C=AA=E4=BD=BF= =E7=94=A8=E7=9A=84=E5=BD=B1=E5=AD=90=E5=85=A7=E5=AD=98=E3=80=82 ~~~~ =20 =E6=9C=89=E4=B8=80=E4=BA=9BKASAN=E6=B8=AC=E8=A9=A6=E5=8F=AF=E4=BB=A5=E9=A9= =97=E8=AD=89KASAN=E6=98=AF=E5=90=A6=E6=AD=A3=E5=B8=B8=E5=B7=A5=E4=BD=9C=E4= =B8=A6=E5=8F=AF=E4=BB=A5=E6=AA=A2=E6=B8=AC=E6=9F=90=E4=BA=9B=E9=A1=9E=E5=9E= =8B=E7=9A=84=E5=85=A7=E5=AD=98=E6=90=8D=E5=A3=9E=E3=80=82 -=E6=B8=AC=E8=A9=A6=E7=94=B1=E5=85=A9=E9=83=A8=E5=88=86=E7=B5=84=E6=88=90: =20 -1. =E8=88=87KUnit=E6=B8=AC=E8=A9=A6=E6=A1=86=E6=9E=B6=E9=9B=86=E6=88=90=E7= =9A=84=E6=B8=AC=E8=A9=A6=E3=80=82=E4=BD=BF=E7=94=A8 ``CONFIG_KASAN_KUNIT_TE= ST`` =E5=95=93=E7=94=A8=E3=80=82 -=E9=80=99=E4=BA=9B=E6=B8=AC=E8=A9=A6=E5=8F=AF=E4=BB=A5=E9=80=9A=E9=81=8E= =E5=B9=BE=E7=A8=AE=E4=B8=8D=E5=90=8C=E7=9A=84=E6=96=B9=E5=BC=8F=E8=87=AA=E5= =8B=95=E9=81=8B=E8=A1=8C=E5=92=8C=E9=83=A8=E5=88=86=E9=A9=97=E8=AD=89=EF=BC= =9B=E8=AB=8B=E5=8F=83=E9=96=B1=E4=B8=8B=E9=9D=A2=E7=9A=84=E8=AA=AA=E6=98=8E= =E3=80=82 +=E6=89=80=E6=9C=89 KASAN =E6=B8=AC=E8=A9=A6=E5=9D=87=E8=88=87 KUnit =E6=B8= =AC=E8=A9=A6=E6=A1=86=E6=9E=B6=E9=9B=86=E6=88=90=EF=BC=8C=E4=B8=A6=E4=B8=94= =E5=8F=AF=E4=BB=A5=E5=95=9F=E7=94=A8 +=E9=80=8F=E9=81=8E ``CONFIG_KASAN_KUNIT_TEST``=E3=80=82=E5=8F=AF=E4=BB=A5= =E9=81=8B=E8=A1=8C=E6=B8=AC=E8=A9=A6=E4=B8=A6=E9=80=B2=E8=A1=8C=E9=83=A8=E5= =88=86=E9=A9=97=E8=AD=89 + =E4=BB=A5=E5=B9=BE=E7=A8=AE=E4=B8=8D=E5=90=8C=E7=9A=84=E6=96=B9=E5=BC=8F= =E8=87=AA=E5=8B=95=E9=80=B2=E8=A1=8C=EF=BC=9B=E8=AB=8B=E5=8F=83=E9=96=B1=E4= =B8=8B=E9=9D=A2=E7=9A=84=E8=AA=AA=E6=98=8E=E3=80=82 =20 -2. =E8=88=87KUnit=E4=B8=8D=E5=85=BC=E5=AE=B9=E7=9A=84=E6=B8=AC=E8=A9=A6=E3= =80=82=E4=BD=BF=E7=94=A8 ``CONFIG_KASAN_MODULE_TEST`` =E5=95=93=E7=94=A8=E4= =B8=A6=E4=B8=94=E5=8F=AA=E8=83=BD=E4=BD=9C=E7=88=B2=E6=A8=A1=E5=A1=8A -=E9=81=8B=E8=A1=8C=E3=80=82=E9=80=99=E4=BA=9B=E6=B8=AC=E8=A9=A6=E5=8F=AA= =E8=83=BD=E9=80=9A=E9=81=8E=E5=8A=A0=E8=BC=89=E5=85=A7=E6=A0=B8=E6=A8=A1=E5= =A1=8A=E4=B8=A6=E6=AA=A2=E6=9F=A5=E5=85=A7=E6=A0=B8=E6=97=A5=E8=AA=8C=E4=BB= =A5=E7=8D=B2=E5=8F=96KASAN=E5=A0=B1=E5=91=8A=E4=BE=86=E6=89=8B=E5=8B=95=E9= =A9=97=E8=AD=89=E3=80=82 - -=E5=A6=82=E6=9E=9C=E6=AA=A2=E6=B8=AC=E5=88=B0=E9=8C=AF=E8=AA=A4=EF=BC=8C= =E6=AF=8F=E5=80=8BKUnit=E5=85=BC=E5=AE=B9=E7=9A=84KASAN=E6=B8=AC=E8=A9=A6= =E9=83=BD=E6=9C=83=E6=89=93=E5=8D=B0=E5=A4=9A=E5=80=8BKASAN=E5=A0=B1=E5=91= =8A=E4=B9=8B=E4=B8=80=EF=BC=8C=E7=84=B6=E5=BE=8C=E6=B8=AC=E8=A9=A6=E6=89=93= =E5=8D=B0 -=E5=85=B6=E7=B7=A8=E8=99=9F=E5=92=8C=E7=8B=80=E6=85=8B=E3=80=82 +=E5=A6=82=E6=9E=9C=E5=81=B5=E6=B8=AC=E5=88=B0=E9=8C=AF=E8=AA=A4=EF=BC=8C= =E6=AF=8F=E5=80=8B KASAN =E6=B8=AC=E8=A9=A6=E9=83=BD=E6=9C=83=E5=88=97=E5= =8D=B0=E5=A4=9A=E5=80=8B KASAN =E5=A0=B1=E5=91=8A=E4=B9=8B=E4=B8=80=E3=80= =82 +=E7=84=B6=E5=BE=8C=E6=B8=AC=E8=A9=A6=E5=88=97=E5=8D=B0=E5=85=B6=E7=B7=A8= =E8=99=9F=E5=92=8C=E7=8B=80=E6=85=8B=E3=80=82 =20 =E7=95=B6=E6=B8=AC=E8=A9=A6=E9=80=9A=E9=81=8E:: =20 @@ -440,16 +437,16 @@ KASAN=E9=80=A3=E6=8E=A5=E5=88=B0vmap=E5=9F=BA=E7=A4= =8E=E6=9E=B6=E6=A7=8B=E4=BB=A5=E6=87=B6=E6=B8=85=E7=90=86=E6=9C=AA=E4=BD=BF= =E7=94=A8=E7=9A=84=E5=BD=B1=E5=AD=90=E5=85=A7=E5=AD=98=E3=80=82 =20 not ok 1 - kasan =20 -=E6=9C=89=E5=B9=BE=E7=A8=AE=E6=96=B9=E6=B3=95=E5=8F=AF=E4=BB=A5=E9=81=8B= =E8=A1=8C=E8=88=87KUnit=E5=85=BC=E5=AE=B9=E7=9A=84KASAN=E6=B8=AC=E8=A9=A6= =E3=80=82 +=E6=9C=89=E5=B9=BE=E7=A8=AE=E6=96=B9=E6=B3=95=E5=8F=AF=E4=BB=A5=E5=9F=B7= =E8=A1=8C KASAN =E6=B8=AC=E8=A9=A6=E3=80=82 =20 1. =E5=8F=AF=E5=8A=A0=E8=BC=89=E6=A8=A1=E5=A1=8A =20 - =E5=95=93=E7=94=A8 ``CONFIG_KUNIT`` =E5=BE=8C=EF=BC=8CKASAN-KUnit=E6=B8= =AC=E8=A9=A6=E5=8F=AF=E4=BB=A5=E6=A7=8B=E5=BB=BA=E7=88=B2=E5=8F=AF=E5=8A=A0= =E8=BC=89=E6=A8=A1=E5=A1=8A=EF=BC=8C=E4=B8=A6=E9=80=9A=E9=81=8E=E4=BD=BF=E7= =94=A8 - ``insmod`` =E6=88=96 ``modprobe`` =E5=8A=A0=E8=BC=89 ``kasan_test.ko`` = =E4=BE=86=E9=81=8B=E8=A1=8C=E3=80=82 + =E5=95=9F=E7=94=A8 ``CONFIG_KUNIT`` =E5=BE=8C=EF=BC=8C=E6=B8=AC=E8=A9= =A6=E5=8F=AF=E4=BB=A5=E5=BB=BA=E7=BD=AE=E7=82=BA=E5=8F=AF=E8=BC=89=E5=85=A5= =E6=A8=A1=E7=B5=84 + =E4=B8=A6=E4=B8=94=E9=80=8F=E9=81=8E=E4=BD=BF=E7=94=A8 ``insmod`` =E6= =88=96 ``modprobe`` =E4=BE=86=E8=BC=89=E5=85=A5 ``kasan_test.ko`` =E4=BE=86= =E9=81=8B=E4=BD=9C=E3=80=82 =20 2. =E5=85=A7=E7=BD=AE =20 - =E9=80=9A=E9=81=8E=E5=85=A7=E7=BD=AE ``CONFIG_KUNIT`` =EF=BC=8C=E4=B9= =9F=E5=8F=AF=E4=BB=A5=E5=85=A7=E7=BD=AEKASAN-KUnit=E6=B8=AC=E8=A9=A6=E3=80= =82=E5=9C=A8=E9=80=99=E7=A8=AE=E6=83=85=E6=B3=81=E4=B8=8B=EF=BC=8C + =E9=80=8F=E9=81=8E=E5=85=A7=E5=BB=BA ``CONFIG_KUNIT``=EF=BC=8C=E6=B8=AC= =E8=A9=A6=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=85=A7=E5=BB=BA=E3=80=82 =E6=B8=AC=E8=A9=A6=E5=B0=87=E5=9C=A8=E5=95=93=E5=8B=95=E6=99=82=E4=BD= =9C=E7=88=B2=E5=BE=8C=E6=9C=9F=E5=88=9D=E5=A7=8B=E5=8C=96=E8=AA=BF=E7=94=A8= =E9=81=8B=E8=A1=8C=E3=80=82 =20 3. =E4=BD=BF=E7=94=A8kunit_tool diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 98016e137b7..f82889a830f 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -195,13 +195,6 @@ config KASAN_KUNIT_TEST For more information on KUnit and unit tests in general, please refer to the KUnit documentation in Documentation/dev-tools/kunit/. =20 -config KASAN_MODULE_TEST - tristate "KUnit-incompatible tests of KASAN bug detection capabilities" - depends on m && KASAN && !KASAN_HW_TAGS - help - A part of the KASAN test suite that is not integrated with KUnit. - Incompatible with Hardware Tag-Based KASAN. - config KASAN_EXTRA_INFO bool "Record and report more information" depends on KASAN diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index f438a6cdc96..b7e4b81421b 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -568,7 +568,7 @@ static inline void kasan_kunit_test_suite_end(void) { } =20 #endif /* CONFIG_KASAN_KUNIT_TEST */ =20 -#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) || IS_ENABLED(CONFIG_KASAN_MODULE_= TEST) +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) =20 bool kasan_save_enable_multi_shot(void); void kasan_restore_multi_shot(bool enabled); diff --git a/mm/kasan/report.c b/mm/kasan/report.c index b48c768acc8..3e48668c3e4 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -132,7 +132,7 @@ static bool report_enabled(void) return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags); } =20 -#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) || IS_ENABLED(CONFIG_KASAN_MODULE_= TEST) +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) =20 bool kasan_save_enable_multi_shot(void) { --=20 2.34.1