From nobody Tue Nov 26 17:32:29 2024 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 5A92C1E531; Wed, 16 Oct 2024 13:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729084696; cv=none; b=Sxu9l9rQnanMP+XSOo/+TL6frxPTdbvqA6JvrhCsuyL/QPkaZQOUwRQ+bs3RCZa29HKuNBYFRf6hISX3QLzCnLRsvkqsmLPUrXAvIlcvMtm9jF5ehUojbSqw8+DKFGs9Dn2h6dD4Y0b3iOwHIt5SkKmK0uNCCFPyKHHKOM+MwMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729084696; c=relaxed/simple; bh=k5jHVU5o1XkCwlhhkfpdMmMdfMfX5fqRpC8pZhrWBks=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Aa59qkgfsbQLCOtR+MYMVXAs8dVlUpm1Uf332Ie1mf8vLYFStvGnsYvBb0Hg/JlnrkVngUmHnmDNkZdx9I1zfTsbNxMs8u4zqk+9JJwdh9xHX9tb1y+BFA624eL5lGdFCv9goglBMXm1+d00yI4Tzc+1zeV5L02yF67m7dJQzrc= 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=dxKntXep; arc=none smtp.client-ip=209.85.128.49 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="dxKntXep" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-431195c3538so47321535e9.3; Wed, 16 Oct 2024 06:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729084694; x=1729689494; 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=vp8mlzCFerHZwOQsdYQzAEyYccT5PlBtmx7TKcs3NbQ=; b=dxKntXep6Otl4T0n3DRgpAUXt+xudMkoH5Exn7J+cSKLRE0APyc4SWbAhnuhCtoVEr 5894TT9Rjwcp4riPlpvH8VP7JMLgdEDzQbmSl6dHBdesk7HEESNGecWA+j7atu+9PWwf zMReRHoyLnJM3UDDMpzqvrnvb2ZHYZd1fBRPlihwLxhPjpvcmwple0Q2HTM0+8IOGtUZ gwemrDUzCsALo9+DQfOiDqyT3tKDsmUFU/7+gVEKzA9Qt0UPFP345wDP3FnXhRoBreP+ XFEG6EYXUoirs6tYT9yGTPXMNSQOehDs7SV5almmuokZ9p6TcCG6f3CNHFBDuqrJWmD6 4k/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729084694; x=1729689494; 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=vp8mlzCFerHZwOQsdYQzAEyYccT5PlBtmx7TKcs3NbQ=; b=MJYRh3gl11FrQUHw/PItGOzl1q+9gQbB7TFLLimodfNNeZYRCjmuuXOjGS5Rkz/Ikf 7mxGqh6h4kgNu4Kr9RcUMO6PMKvyT30AqVe/7w1dW9+40r8+be7ollJ/sn8kSh2mAeFQ ulbST/aiw+h00pvv63uV8WaXFOFRALqV5pPfl5t5IS0x563TTeHOxZBSjFyNlrT1T992 fZgBn8iKqSoQlmqNBBBljkf7ckN2508LDjmnsLMPhdWBdlsZUdumnqTqs5QeRq3dpQHB PhTHxQgg1KrILn2+gbynUgV87p8/UUb0lt/Kwx11Wn2AD5pNctwdlj8XWuUZfmQXnXC7 ZVGw== X-Forwarded-Encrypted: i=1; AJvYcCVr62KzCukePw2vL//h/CIYeil8BPuBzDcVT7BbqNS86k+2r8lKVaCteCCaU7MOmg9pFHLH793nNhsVVFPY@vger.kernel.org, AJvYcCWbBSrnWJK4IrHiNvAgTk2I92sDCB0TxZ3mHBEPoKohQlBt6q5R7ZoCoH4IMHKK4S5RzfmaNypZFbQ=@vger.kernel.org, AJvYcCXJ3exfttWqifJrcPMT5kIbU9Xaav+pyBM3dzmvkUyzk9ji+B1kl2ciB3+zT8TlXiTynKsfV5aL5Eb+@vger.kernel.org X-Gm-Message-State: AOJu0YwTzMG/+ABUF6QM/r48vdjbj+0yb25RUO2HGW0w/Bh0UHSmN9YQ uBX5gdfQdDcU0G3AFV1Ov1PVntIASzQRj4rmROMC5S7zGzRewFMh X-Google-Smtp-Source: AGHT+IEPh2uD/e424mZy3TzaSgh1zMe8F8B2stIBFMZzi9dKTninoOvYVP/vLIQdZEOFtDvCeX2T8g== X-Received: by 2002:a05:600c:4514:b0:426:60b8:d8ba with SMTP id 5b1f17b1804b1-4314a362525mr29799615e9.28.1729084693271; Wed, 16 Oct 2024 06:18:13 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f5698aesm49612825e9.11.2024.10.16.06.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 06:18:12 -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 v4 1/3] kasan: move checks to do_strncpy_from_user Date: Wed, 16 Oct 2024 18:18:00 +0500 Message-Id: <20241016131802.3115788-2-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241016131802.3115788-1-snovitoll@gmail.com> References: <20241016131802.3115788-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..6dc234913dd 100644 --- a/lib/strncpy_from_user.c +++ b/lib/strncpy_from_user.c @@ -120,6 +120,9 @@ long strncpy_from_user(char *dst, const char __user *sr= c, long count) if (unlikely(count <=3D 0)) return 0; =20 + kasan_check_write(dst, count); + check_object_size(dst, count, false); + if (can_do_masked_user_access()) { long retval; =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 Tue Nov 26 17:32:29 2024 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 AD35520ADDA; Wed, 16 Oct 2024 13:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729084701; cv=none; b=k2FGyPdLhNelC+NM9msINZ1YZr/Asol4m301nyK6hLrq4og4/hWlYbhiaGL6is0CMfSaDqS8zVsNOzwfT+zjjqIsJZZDqVcFYOQEVxty9N/q257TmoejZpfk/UBcwobsaDLUorDhZwYgxMRqbuisv+VzrtkwiRObstInnOLX2hM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729084701; c=relaxed/simple; bh=3nJnFVnwR+L3Z18DYoST7sOHYfHg//9WUdBRCtPPyWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OiwkgVbygaEt1bth4qZccIW73y6SrJoFze7zbFgsHUkR6ywnKvJzNFm9AnPeTPnbVsZZu1ErQYwb4sappFwcNc8Dic+eyRjxxjE8yWEsxr75xU833cO+7fs/AcFs27Qjp6hnuO+PkbZbHo7wBql16ZftB6uRWjS0skTlRsKSRpw= 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=dJv6AZ6C; arc=none smtp.client-ip=209.85.128.47 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="dJv6AZ6C" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4314311959aso14595265e9.1; Wed, 16 Oct 2024 06:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729084698; x=1729689498; 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=dJv6AZ6C+50MKDw33WRDZu5TNWmQhc7BCQQQrUEAx/1SniRVEAw7nAagPv1849n5V/ llyhkBYgpO8uTwbILkH9iteOSaW+4lZtZ0jER4dfCf+9NuMUNnbBAoeORRdQm7872IWB LfCrNuWsc0NsKQP2t0lNHFgZe3Nnxm42DK4ZHmsMejGp8rn/W32bqr77xINBa/p0f0jI APCOC0oKNjVsAMsnxBhE5H4G2UUWbhzTnzS9FqVd9ubSmOrFX1nYkZtGZl9oFbs1EzKq th5v9THksMR4e508qC9l+eQW/TvfAZtn6U/Ecjenm76jDzPNbZHqQdLIxZ/yM3uh50Ic xzow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729084698; x=1729689498; 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=h+P59+V2XJ2TwMZXZHywsl3A36VHsv2ma5dX/9fM+HdfCh8w2GLFP8R3635MXu+U1z HqUEr1XwUhLS+2ZeVQaA2BHHzeKE/bVpRE/LUbl7Eha9T1VIjPRvkZxV6kvP64ncuRHL YGG2/O+YEUEvP5xmrlccd5R0Aj+1ybFtYpQ30MRe1ElSR02Kop5NrwtxJQhPMf3R1FKd 98JQ1IjJEM8/mBxyT/HoFFUideTjyO/UCk/LGINgrBxMR4rMjcAbC+Oa2gf+plw+H9EX wpQQfqAMx/WAiXVSy79TOqaYHXjzQiXPsm9oMPaLU01MeeUHwZYDxb4x+r20I3aNM5ES vi+w== X-Forwarded-Encrypted: i=1; AJvYcCUHSXMuzjThKTwzYudlj1ifHMM7Hge5L68Xm2WTD2DPBzAe8BRlGO/q0xlXucx2+GXFlkauIFKuFLlvgsfE@vger.kernel.org, AJvYcCUMg/nTpMR0bgA0IvgjB4wraPKa8vG2ccfPGu8oM9MhP60VUFwhrz0P3+DqSywW5txFvcRc61sbHzk=@vger.kernel.org, AJvYcCViuOpjKX6wpILhhkeV+saCOnLsBixXx1S36iLfzQMaZA+T18U1Y2DFbZjkiZXvyss6a4fXgceVgteF@vger.kernel.org X-Gm-Message-State: AOJu0Yx3VM8FCdegaTwr/aAnCwppPJhLCx36+de2y+He7eJ5hvtpP1Fm 4DaNByQ1vGyANjvc8UynY/Hg1R6XLfN4SQ6uep6Qp9rte8JQO5Ac X-Google-Smtp-Source: AGHT+IH3FuLlFjmqTs3wizKlwLXV6vFTExlSBMXK4B6QAGh74FnpgDABFCIjNm+jC+pHYvNYiZORlg== X-Received: by 2002:a05:600c:4fd3:b0:431:5503:43ca with SMTP id 5b1f17b1804b1-43155035333mr7296085e9.28.1729084697677; Wed, 16 Oct 2024 06:18:17 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f5698aesm49612825e9.11.2024.10.16.06.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 06:18:17 -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 v4 2/3] kasan: migrate copy_user_test to kunit Date: Wed, 16 Oct 2024 18:18:01 +0500 Message-Id: <20241016131802.3115788-3-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241016131802.3115788-1-snovitoll@gmail.com> References: <20241016131802.3115788-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 Tue Nov 26 17:32:29 2024 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 496B1209F48; Wed, 16 Oct 2024 13:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729084706; cv=none; b=lmyHGwNXwoU3v1JqHqTTdahTb8+s6Y7Orye24G/RBCC/T48HzM61XmCZKJbFcdi1yz/U+E6/NTG3G3pXQWz+cZ85fTZJkDV3HLMjLLXGYDmYF/wiyf6amebv4mAsHcDgxpfC0fzrwlhiuUo6cgkuDVl/2AEoS3kcpHA0PyO4Cg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729084706; c=relaxed/simple; bh=j4lwfqIfhg3o9c/qxDv63TOPSlOrzp7Cd7ov8oxJkXc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=HNiduwbD943yAafM/f8aFHEeo3QLLewLLjllpYebKgGk3V5o2pDYeljdbqNHrQf4cQO3S9PQ0OKrqsJj7PGdoQ0lFf5xRddjI9uR1T9pldLVV0rnmNRtsnpwMZt/6cClPCxzigf7TgdILHRBSu7ehufLz5IAqM6CT7wB22tLOdY= 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=R8fmnS7X; arc=none smtp.client-ip=209.85.221.43 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="R8fmnS7X" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-37d49ffaba6so4287940f8f.0; Wed, 16 Oct 2024 06:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729084702; x=1729689502; 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=R8fmnS7XknkpD//IQLFeW5MACYzmuiF5nOWxid4BDY3YR3FEVKqDf0YJe0nYxaHgL9 YjwdbaU/WilKdv0oDPrnuKFHoxyiT188Q5RguePMqGqEqeR409LEvLPCmsMQLpKeN5a3 LniW1FdbwIedKJdbdnqKRFl3bueGy8fpudZwHwLYMkJ9hWM+uTC5yYe7gTWdd0dLVC1x 4fRGisBDpp8Ql3//W3jlZu0n7CtB7aDYO9xE6gO66e7fs17JroSYvscWks8gHyv64+gr ao7ZD6qWZvtrYWdzo7kEjdJJ43PMIW7NQMM5yTx6ny+MCtpIXOj3Rpw6om46uVuDsf+w DvpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729084702; x=1729689502; 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=PzMIgx2UzYePa+++HBSyRYGAe5Nt79FhM8/gIoer269h6UDMU5quqhdXKzo3gPmVqy +aBISR7gPs+L9TMdECt4MH6V3U1dNPLbYtwkv970BRboYRCFXg59ooQnm78N7kTps20N jd6D7OnbFkMQ6iWDe25Q3Arsi/DQMt7/s1pd6RYJtrzrnbSmQnjOl6H9U2a2lcmCJApm ql+F8LREnqlj4a2t0bDMDdL9b46n6bmMq5ZjnjM8qMl5uPTB85C8ENZz6wqKQlNbs0e2 lDNt6Chbf9FVAfUKTLEQDcBHm6Aatr2mVbfBEobxE8lcMfJFbQ4OOz46oC+hd3szzPC+ X8jQ== X-Forwarded-Encrypted: i=1; AJvYcCUJlhvu4nvnvMe38Fic1cXMUKJm0SrJBiDgEdYMODjqtlyZVHGf1dWb3PdY9SX7BB5TVdVqmNbu7zw=@vger.kernel.org, AJvYcCWq7J5CwYyn9Sievr/dH7HhwkFd4cLzTQfRR2/U6Sm80w+hxiCkWnefZtxPCmJkXuMP4gmypWsbc/Y+@vger.kernel.org, AJvYcCX4K78JgRKtcbhIt0GNLLhZrZMxsQ2xiEeJIQMopf08dgeQ//oPKGi4PKOc8ZoyU2AuQ5xlAtTCxmA5yLFS@vger.kernel.org X-Gm-Message-State: AOJu0Yw+xDRyck8vxKagVZjNNfhvPvO0OOgHwgj66XibZHnTc2+UkquK 3rXKoi2hbim2kLwJW4pk2FDBWsi3BL6LFxFF0K5UfNURjwr1Gw5m X-Google-Smtp-Source: AGHT+IEnqE33zAEZ4Osvb5YV0WmK6TiqgW5ppvcNvuX+PIESYEVsFYkFYZLCq1hdV0OqDyWWM/vbiw== X-Received: by 2002:a5d:6109:0:b0:37d:3999:7b4 with SMTP id ffacd0b85a97d-37d5519cbb6mr11646512f8f.17.1729084702303; Wed, 16 Oct 2024 06:18:22 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f5698aesm49612825e9.11.2024.10.16.06.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 06:18:21 -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 v4 3/3] kasan: delete CONFIG_KASAN_MODULE_TEST Date: Wed, 16 Oct 2024 18:18:02 +0500 Message-Id: <20241016131802.3115788-4-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241016131802.3115788-1-snovitoll@gmail.com> References: <20241016131802.3115788-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