From patchwork Wed Jun 19 20:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13704502 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 399D8C27C53 for ; Wed, 19 Jun 2024 20:25:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9CD678D008B; Wed, 19 Jun 2024 16:25:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97D1D8D0066; Wed, 19 Jun 2024 16:25:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8445F8D008B; Wed, 19 Jun 2024 16:25:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 669968D0066 for ; Wed, 19 Jun 2024 16:25:24 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0D035141178 for ; Wed, 19 Jun 2024 20:25:24 +0000 (UTC) X-FDA: 82248768168.13.3ED0447 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 22DE91C000B for ; Wed, 19 Jun 2024 20:25:20 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UzRggGZn; spf=pass (imf18.hostedemail.com: domain of kees@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718828717; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=dcVit8GJ4KgG7HbX+YCIMIrcdcmxGO4v8nvLV8HUxd0=; b=sXR5mxcEeEw3wYHi98kQE4v+0RV6n23wk42PtWVE+ROrsLgK2lCVAgjeG+qn66uIZtGDa4 is7gYIdDU1s7P0p0KHaf99/wFTneaddlUvROTquTm+Nhk76dnorru6ToSutnTytLpev414 h6UA7LMKebF/ypQPBF+NBz+Avi6RQxw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UzRggGZn; spf=pass (imf18.hostedemail.com: domain of kees@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718828717; a=rsa-sha256; cv=none; b=h0cOJCTUZP5oIloGDeEeZIB0R75HntpvFhcLxo5Q9xpGy5p9dCxMQHjN5tmOBz5e0JIIhf VtBR87y6FNcfMc+bz7mIuP4RnEzSdU4o63wnQp/ejvyvut59x7sN21jJM8rsZuYjTiUTb0 Hdd9A0Qq9qQTyAHkBpnrUcM6r3E8jxc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 345AB61E29; Wed, 19 Jun 2024 20:25:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5349C2BBFC; Wed, 19 Jun 2024 20:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718828719; bh=0z/x4MbHkEbrGTPcfTeUJ/C6WA/I36PZC2kojq3ru0U=; h=From:To:Cc:Subject:Date:From; b=UzRggGZnu1PG7nb9uFUxMW+IohcWrxAskgFAQgF0qAV/CF25ETWzCD4SaHDI8SLdl 7SYbcnt+NM+8e28uSW35DH7+YYCvxIIKL5tFKW85kBwk/XbbmU41v876fKphrq7biw fqxSjDjsr8XO6GkTlrAf+C8wU0kO9GZFtkNY5pPnN65Qn3YCA0knMdlgCZtOAkaQ8s T2NTNvWlBPiBufibsmAQZr67CbUg2KUjU9+lg+6Ly93QiH2U+yOdP7wYbrKMc82gnf CBmKSkakkvgXKtiBd/xjZIhcaV2OfHX976lrKSeq3RQBhI37hnti5XvJH4pqygRq4H G2mbjjt4DmJ3A== From: Kees Cook To: Shuah Khan Cc: Kees Cook , kernel test robot , Brendan Higgins , David Gow , Rae Moar , "Gustavo A. R. Silva" , Andrew Morton , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU Date: Wed, 19 Jun 2024 13:25:17 -0700 Message-Id: <20240619202511.it.861-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2264; i=kees@kernel.org; h=from:subject:message-id; bh=0z/x4MbHkEbrGTPcfTeUJ/C6WA/I36PZC2kojq3ru0U=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmcz6ty3U7pJ3+ihHl7H2BhHZj95uen4wpNRK9Z 3dLLGlY+JCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZnM+rQAKCRCJcvTf3G3A JiDxEACuAwOoGKwQIEtgmI414mZiL7poZ8RdTRgD6cSwvOyPra7Yf/2KwJkUMiXrLd5ckYIMn5Y 7P1qVJF94xz7dMHVXVuNf7CgeHBtXLvP5YWCmAVHpwKBOX1YDVelLG60ylnwvg7NTEPZ/BMrx1a aFNiaNw6dqwzm0l6efBQF8kQg1fQ9kBjYQ1FJ7O98Iu1ZdX/dn7OT/5KIXndF5mxt7RWvIZ6aVP 6Q1ZGMP1D5gqz7MKRq9ob28HdzJik3g+ehFuQ0WTUXbxzrCRDPDrDiaHnIAqVaUUTcDcm4A1QIg 5hKHvUjHucwHCf8fFK20K06pXLTQ3X1dD3c/GwG3N9aVLj6jmUg7WBo1uO/SYCoDU7RNQyp2UcE yD/Nt9MhV5gKegAzPvjCx0nAvvt7Ur2EuRS0sqojHX0qjlwljwus0jqnn/42UF+ssnSPrDjw8ZX GIZnncTWtPDf64LT+YsEDWFEoI3nAgoafnNljgiCNs3N86eQaQWB0u8EMuoSID6+vvlNBPVgjOA x9Iz3e8qO9aiPm0CgZ77bng7NBx9s++fGrvZ2uZ6olo6QzZz7zXZpdkcMcSgkBQ2gEPGhuksHOA hXWQbi/q6n1u3/ngYkDyOX+Dw8t1KVGLqKn7zEqgrrnYFiWoH2hKTiK7m8urENljyRPiHbdY0Hw q9rSp WPX7HEbz eA== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 22DE91C000B X-Stat-Signature: t8g8mmk3dn9fr3is8fcxouidogi7xy57 X-HE-Tag: 1718828720-464769 X-HE-Meta: U2FsdGVkX18B4eAS6JnigE75ym2LzHqZLNXBnPIT/BtNEyd+bP+UXFKO0JsxbZgyr3/Xat2C7pVjOMTlK9rtKrVT8vdFieO9FK/xw5vVjDyPNTte/4BDmV7W8Ye+Z0exTIIGEeGU15vjUkuoiJC+uN1oWVasmvDc/DzQIXSURXodkWuX1LjfYrQ03QYXnOLH2qbNJ6yULXA00+Z0fI4IZkKx0/z6QDPjOX8vULMxufJs1KXcCYfqVXYej0Hagyvs0B75RCdo7DnjsxZj37ALkd7Ay/c/Mzz2SQXKdDKO5YmayKR5KGs0b9Fqt1Gz6S6whDwogzjqMXJ7mzvqjyhkri0MVtfltt0EnUvVU4gO8/R5fQifRVXX6cTJPo/UANg+g0NBJMkxuGFoKyG7jVYJO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/L4pVr9ECDnBKRwnJX/zmxyx0ysuAJQ/qs5il91KxdbYq0URAaIlT33+HL+x6S+pujh+iEjkagTVRGAa2EDgk/6p16+19m0uWR7LRQB1mdIXDKNL4ahSI= 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: List-Subscribe: List-Unsubscribe: Since arch_pick_mmap_layout() is an inline for non-MMU systems, disable this test there. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202406160505.uBge6TMY-lkp@intel.com/ Signed-off-by: Kees Cook Reviewed-by: Rae Moar Reviewed-by: David Gow --- Resending as v2 with Shuah in To: --- Cc: Shuah Khan Cc: Brendan Higgins Cc: David Gow Cc: Rae Moar Cc: "Gustavo A. R. Silva" Cc: Andrew Morton Cc: linux-kselftest@vger.kernel.org Cc: kunit-dev@googlegroups.com Cc: linux-hardening@vger.kernel.org Cc: linux-mm@kvack.org --- lib/kunit/user_alloc.c | 4 ++++ lib/usercopy_kunit.c | 5 +++++ mm/util.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/lib/kunit/user_alloc.c b/lib/kunit/user_alloc.c index 76d3d1345ed7..ae935df09a5e 100644 --- a/lib/kunit/user_alloc.c +++ b/lib/kunit/user_alloc.c @@ -30,6 +30,10 @@ static int kunit_attach_mm(void) if (current->mm) return 0; + /* arch_pick_mmap_layout() is only sane with MMU systems. */ + if (!IS_ENABLED(CONFIG_MMU)) + return -EINVAL; + mm = mm_alloc(); if (!mm) return -ENOMEM; diff --git a/lib/usercopy_kunit.c b/lib/usercopy_kunit.c index 45f1e558c464..e819561a540d 100644 --- a/lib/usercopy_kunit.c +++ b/lib/usercopy_kunit.c @@ -290,6 +290,11 @@ static int usercopy_test_init(struct kunit *test) struct usercopy_test_priv *priv; unsigned long user_addr; + if (!IS_ENABLED(CONFIG_MMU)) { + kunit_skip(test, "Userspace allocation testing not available on non-MMU systems"); + return 0; + } + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv); test->priv = priv; diff --git a/mm/util.c b/mm/util.c index df37c47d9374..e70e8e439258 100644 --- a/mm/util.c +++ b/mm/util.c @@ -484,7 +484,9 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) clear_bit(MMF_TOPDOWN, &mm->flags); } #endif +#ifdef CONFIG_MMU EXPORT_SYMBOL_IF_KUNIT(arch_pick_mmap_layout); +#endif /** * __account_locked_vm - account locked pages to an mm's locked_vm