From mboxrd@z Thu Jan 1 00:00:00 1970 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 E8B8BC3064D for ; Thu, 27 Jun 2024 17:07:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79CE46B0099; Thu, 27 Jun 2024 13:07:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74D246B009C; Thu, 27 Jun 2024 13:07:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6143A6B009D; Thu, 27 Jun 2024 13:07:28 -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 4368D6B0099 for ; Thu, 27 Jun 2024 13:07:28 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DE90340C88 for ; Thu, 27 Jun 2024 17:07:27 +0000 (UTC) X-FDA: 82277299734.15.8E64391 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 211284000B for ; Thu, 27 Jun 2024 17:07:23 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=M8ppLUtD; spf=pass (imf12.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=1719508021; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=n5JwcbwDdhkF8FmOjUNZgtY9K6Ii0YkvLqH5YjHadoM=; b=pV6JJGFwb3vBFk307N+wXJzW4duRaeyUJm0Yfels4GyhfDCe330S9KzEDrXNEK92qd+bjg Etk5YCUlAScW9GyYUW1UVFj0JZPCR26e0+k2HbdoOzy8YVrtg3B/ccYcSEdWHdisnEFp0F //YXWWeiosqB9FIauXaNJJNvxdKjROw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=M8ppLUtD; spf=pass (imf12.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=1719508021; a=rsa-sha256; cv=none; b=d9D+s1CbNvsBejtlyzCsvvEJ+YV512DVu59Zv+6AtDcB0vC6Jxl3WfQqwvf8sUb3ENd5C0 sCLl3Vo9XC6TBzsB2e9t8kRp4pzRIb8m+hxzHMw+TB5ljpzzpSX/BvBUNFY9+Tt9zmf+9i FRjcoSs+2sCqqriYxHUYAoyEBAZSanU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0FE0161F5D; Thu, 27 Jun 2024 17:07:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6822C2BD10; Thu, 27 Jun 2024 17:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719508042; bh=dCecJH51CViqti7qWLv13tYkYfTd/WBIfPitvC5HPdc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M8ppLUtDZSj40GoxCJkBdtnipmTOwT7siZJmIBCDzKP6WEeYPpYN+KQAeBHBZMZnV xHigF/m20LEu2obCWRbRKgLfI0WMFHW6UiFs1rTqK0EApwkJiLx0hyxKaOFwJCSevk mOxmr0nCMEUbkOCW90BDdUFpUWqa6nuwcW3lIo4JtwZmiCF7511gnHOVCeX1dsMg0A ay8JjnIvgjtKyn4QrkgLRqi2TKn8BZLljfDLZeUJuuZNJgDJmVPYX4fy7sb0f7TE1l nsRROyftHTyOJc0Gilaq2rbz5jXeh7knp42xLlYyoCr9NkF2CPj1Aad8ixc03adTNY Pt0RxZ7375R8A== Date: Thu, 27 Jun 2024 10:07:22 -0700 From: Kees Cook To: Shuah Khan Cc: Rae Moar , kernel test robot , Brendan Higgins , David Gow , "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: Re: [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU Message-ID: <202406271005.4E767DAE@keescook> References: <20240619202511.it.861-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 211284000B X-Stat-Signature: ybpeygaz9ubabx4sxwoc7frdfbyrztuy X-Rspam-User: X-HE-Tag: 1719508043-631483 X-HE-Meta: U2FsdGVkX18nfUGDa8AThCR9EF7NVGbFjo5FcLVCGSFClYtlBWZsl73DjmmJaTiufpccFty+P1PaB2TzZ2ByT28NvAJ956B4lQ9wzusIgqM+l9qqKkyMzGVbZ+Xz6oB/c39Fwh9+ND0141uh8K2DrYcTRVOnTqZo1RammBaJ3UppmmH6Qu6oj+kpURGW6Tu8O2mkEaB9lDu7wu2f1/nzvttjRBB3ydL9j2NaLmRfZe3kbM6yFI2e2mEQgwT6OddTUSP0rkVq6AEFq3NUKiOD+I3VRoLCS/eneh7xA07ldYHBnkTiPbaSYoJ9t4a+9CP8XWmhT/osuDwKQsxF9zUvrm7p2iv9JJR2SC9nghVYFOAQKPk4BSN+LRKVZinJ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rzA/BxS5HA+Z5rO5cgwDskJcJs3naHNE/vjUVsPyDTqy2Neux297PIX5wZ43XX5CqGtGcGszjiKTj4WD7j7exKucqe5rEYra9S+Z+hUQp6G+Geqhu16bIB0OAyMBeTM2GFIBxL5PB7yW929zy+YG0pdy70V1woX7ia5gHbkNLvl6vNX3jmumlkpbf+jIwyn3fLjI0TExn7jNKvY= 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: Hi Shuah, Can you please add this to your -next tree since it fixes test failures on non-MMU systems, after commit cf6219ee889f ("usercopy: Convert test_user_copy to KUnit test"). Thanks! -Kees On Thu, Jun 20, 2024 at 05:13:35PM -0400, Rae Moar wrote: > On Wed, Jun 19, 2024 at 4:25 PM Kees Cook wrote: > > > > 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 > > Hello! > > This looks good to me. And seems to fix the problem. Thanks for the fix! > > Reviewed-by: Rae Moar > > -Rae > > > --- > > 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 > > -- > > 2.34.1 > > -- Kees Cook