From patchwork Mon Jun 17 17:41:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13701127 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 C8BE3C2BA1A for ; Mon, 17 Jun 2024 17:41:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F7416B0099; Mon, 17 Jun 2024 13:41:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A6F96B00BA; Mon, 17 Jun 2024 13:41:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16E7E6B00BC; Mon, 17 Jun 2024 13:41:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EF16E6B0099 for ; Mon, 17 Jun 2024 13:41:23 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 92CB340234 for ; Mon, 17 Jun 2024 17:41:23 +0000 (UTC) X-FDA: 82241097246.04.464B67E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id C6E86140019 for ; Mon, 17 Jun 2024 17:41:20 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uGpG03KP; spf=pass (imf26.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=1718646078; 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=uQD07LmR8APf5WnQE6pzl+L/EOlmKyBK4toSSWKGevw=; b=DZ9fK5sIe6scqFF0L+lnOu9WcVyRA9AC7SNBs654M0PwKWw29c8vM2A+Qf40gl/ud7Nxpn 3hndNMiNEo56XTdvlOn/xkutXq+CNnoDfuQmJcMsXe91zTFBVaIS/e1pDkSk5mK9/D/4Ev Y7YcmXnrxQG8n8H4/QBPTsNfHxEhI7I= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uGpG03KP; spf=pass (imf26.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=1718646078; a=rsa-sha256; cv=none; b=jse6mi6/zTTx2KnQdLEx5bSoV/M4vlOD/jGvZ+PIyCxKLOPfL+j6pwFmSTk9m0Msa8sTli Qi3Iec7VIuuB5GjPMBqybZeqcojwQJgq1qbgU3Suio5uP7kRrd1Wf3dwT79SrnU0zv7Ved 8tMAUtUf4k/sL39YdRDobGGrDBcE9nk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7EB6D6124A; Mon, 17 Jun 2024 17:41:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26CD1C2BD10; Mon, 17 Jun 2024 17:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718646079; bh=SyTGqPdHpuy3gJMpwFjM312Sys8XLnxtGOp+tF8HIfM=; h=From:To:Cc:Subject:Date:From; b=uGpG03KPdReyjC1/opQWeFUmIa7rjKz4qdzL3Hsr8+an6ghDa2V8srd0gkZoUKP9R +eXn5MKn0jYpfdVERyjjKRjlwi1bsgAIgxK73PHYGeg/Pp1dKh4lH2iCBuThx89NQk 99GdpyvBmDe9YgiA5pKjb4uH6OAigy4vZfgbP9ibxuaKDKV/0Xr9rv8xZtnoZD1ZZj yzUIMi5ez50LW1KmtrQLIWoIaa+wgg/CtGw/fF17npZJaWn/hBzXDyA1HnSlmwwoew 794/yiqgBtyjM/dOxETPIz99qXy/lESnTAbZoMVpaximCgFT4CW6VS53ZRbPAy77qk /hKIqpqIHV1mQ== From: Kees Cook To: Brendan Higgins Cc: Kees Cook , kernel test robot , 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] kunit/usercopy: Disable testing on !CONFIG_MMU Date: Mon, 17 Jun 2024 10:41:15 -0700 Message-Id: <20240617174111.work.408-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2180; i=kees@kernel.org; h=from:subject:message-id; bh=SyTGqPdHpuy3gJMpwFjM312Sys8XLnxtGOp+tF8HIfM=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBmcHU71lN3gU2U5/SabG8LFXiX7hR8Kwm6xAE7y fRNHDG70PKJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZnB1OwAKCRCJcvTf3G3A JiWJEACZ5pYWV/fr4xGq+aSoVJGknbuIT4sUIOHFs6bjERXU4LaLDpqPiQ7EXSIbt5ikxK9TD2a PnkHJEECwZSrQr9XZWnMETsHm82Pzy8lgYW0PQZDSg1vyiLJejZAdFNMBfE9y1b0Y/I2zzXhEEm 3umRoPCnNWVER7j/NZ+SDnYETclRNJP5DayslHfYmdd+7ixn0vrjVYWf72kaoJitTor+DKk74In D6+QAfroH2RvrvTAMrG7dgtTGnWahj+xQpqBlZH38pLtPOe1QjA2VrtNAa/RffIHS+vT5IxqqHU 6Fn1Uzlry7ZUxNPK1FySQxTbsBKC4PRLLwP3i1A/Rw4VPwdZWAdqj543xIFivMOIuGX6EpmtUiY al7xYvYqBbriDWeIm+kaNvXJOXri7Qor/jXcGG0XAT3VsDQdZnrYL1PD91OrsUheWQ6oW+TeHrS fotG8J2+PleZj7iGZYXJHqHwpPVTQ9mRckQA5zFJNguxx3GaoVmA+KBFEnhJP9XK7sn/d9MqX0x Y31O1zS7LDzDYlxjxQl6PgoYiAk3NwcEJFd2+LBwV9opREay5cOy2tn1rx17s2RER74jRdJ99ig qF1yxmGx8AVF0zph9SVyTY199DWOaVWlJkPJOi2yMfFCqIrcOzIKo7hQ0C3u8ttQ/1tfmf1Y20c /HOkT B5O3lzQu eQ== X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: C6E86140019 X-Stat-Signature: mkoceizh9jpekms3ff5czs8jw8usx8eh X-HE-Tag: 1718646080-860642 X-HE-Meta: U2FsdGVkX1/GIz8qyORsb0Uswzxo8qjGGt7ZQreHdZXOADFpiDR6kH1xXVu0jsgRA8mHPDKJeKRX/GYE/BZrkShM6w6RwV/oIZFCEwAXFBTxoRPaZWJddehRAgCeUYU/3oxg0QSyquDWctfGdsxQPIKMyNosmmaHoi5ZJfAzhLVRxVRm/jNPYGNOhQJWF2cnd1k51dE4aSRNS5UzEn9gWfqGJIbsokF1UNAat3dYih7YbPH2OXo06t0Kjc5wrybczKsKs3GxS2MbJQdtoWlYuVWilAmLrJS7F6BEMOtB7OzB+aN0Wq2ALy3z4FVHdxkBrIqqH6EXk92nX4BO06BMEXLFCdV7anawx6VcLN+TM75Yl+0LftRc0+hMMSAdx9jP5gahbnl0fgPm3GvdtB2k82aZ3GzsvizbR9QuzWIkN7i9so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/pAuJ2oLSN+tP5fGnKsjrpmkCVZ/37e76Kw8jqU= 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 --- 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