* [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU
@ 2024-06-19 20:25 Kees Cook
2024-06-20 21:13 ` Rae Moar
2024-07-02 4:05 ` David Gow
0 siblings, 2 replies; 6+ messages in thread
From: Kees Cook @ 2024-06-19 20:25 UTC (permalink / raw)
To: Shuah Khan
Cc: Kees Cook, kernel test robot, Brendan Higgins, David Gow,
Rae Moar, Gustavo A. R. Silva, Andrew Morton, linux-kselftest,
kunit-dev, linux-hardening, linux-mm, linux-kernel
Since arch_pick_mmap_layout() is an inline for non-MMU systems, disable
this test there.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406160505.uBge6TMY-lkp@intel.com/
Signed-off-by: Kees Cook <kees@kernel.org>
---
Resending as v2 with Shuah in To:
---
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Rae Moar <rmoar@google.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU
2024-06-19 20:25 [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU Kees Cook
@ 2024-06-20 21:13 ` Rae Moar
2024-06-27 17:07 ` Kees Cook
2024-07-02 4:05 ` David Gow
1 sibling, 1 reply; 6+ messages in thread
From: Rae Moar @ 2024-06-20 21:13 UTC (permalink / raw)
To: Kees Cook
Cc: Shuah Khan, kernel test robot, Brendan Higgins, David Gow,
Gustavo A. R. Silva, Andrew Morton, linux-kselftest, kunit-dev,
linux-hardening, linux-mm, linux-kernel
On Wed, Jun 19, 2024 at 4:25 PM Kees Cook <kees@kernel.org> wrote:
>
> Since arch_pick_mmap_layout() is an inline for non-MMU systems, disable
> this test there.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202406160505.uBge6TMY-lkp@intel.com/
> Signed-off-by: Kees Cook <kees@kernel.org>
Hello!
This looks good to me. And seems to fix the problem. Thanks for the fix!
Reviewed-by: Rae Moar <rmoar@google.com>
-Rae
> ---
> Resending as v2 with Shuah in To:
> ---
> Cc: Shuah Khan <skhan@linuxfoundation.org>
> Cc: Brendan Higgins <brendan.higgins@linux.dev>
> Cc: David Gow <davidgow@google.com>
> Cc: Rae Moar <rmoar@google.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU
2024-06-20 21:13 ` Rae Moar
@ 2024-06-27 17:07 ` Kees Cook
2024-07-02 16:18 ` Shuah Khan
0 siblings, 1 reply; 6+ messages in thread
From: Kees Cook @ 2024-06-27 17:07 UTC (permalink / raw)
To: Shuah Khan
Cc: Rae Moar, kernel test robot, Brendan Higgins, David Gow,
Gustavo A. R. Silva, Andrew Morton, linux-kselftest, kunit-dev,
linux-hardening, linux-mm, linux-kernel
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 <kees@kernel.org> wrote:
> >
> > Since arch_pick_mmap_layout() is an inline for non-MMU systems, disable
> > this test there.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202406160505.uBge6TMY-lkp@intel.com/
> > Signed-off-by: Kees Cook <kees@kernel.org>
>
> Hello!
>
> This looks good to me. And seems to fix the problem. Thanks for the fix!
>
> Reviewed-by: Rae Moar <rmoar@google.com>
>
> -Rae
>
> > ---
> > Resending as v2 with Shuah in To:
> > ---
> > Cc: Shuah Khan <skhan@linuxfoundation.org>
> > Cc: Brendan Higgins <brendan.higgins@linux.dev>
> > Cc: David Gow <davidgow@google.com>
> > Cc: Rae Moar <rmoar@google.com>
> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU
2024-06-19 20:25 [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU Kees Cook
2024-06-20 21:13 ` Rae Moar
@ 2024-07-02 4:05 ` David Gow
2024-07-02 16:15 ` Shuah Khan
1 sibling, 1 reply; 6+ messages in thread
From: David Gow @ 2024-07-02 4:05 UTC (permalink / raw)
To: Kees Cook
Cc: Shuah Khan, kernel test robot, Brendan Higgins, Rae Moar,
Gustavo A. R. Silva, Andrew Morton, linux-kselftest, kunit-dev,
linux-hardening, linux-mm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 860 bytes --]
On Thu, 20 Jun 2024 at 04:25, Kees Cook <kees@kernel.org> wrote:
>
> Since arch_pick_mmap_layout() is an inline for non-MMU systems, disable
> this test there.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202406160505.uBge6TMY-lkp@intel.com/
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Resending as v2 with Shuah in To:
> ---
> Cc: Shuah Khan <skhan@linuxfoundation.org>
> Cc: Brendan Higgins <brendan.higgins@linux.dev>
> Cc: David Gow <davidgow@google.com>
> Cc: Rae Moar <rmoar@google.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-kselftest@vger.kernel.org
> Cc: kunit-dev@googlegroups.com
> Cc: linux-hardening@vger.kernel.org
> Cc: linux-mm@kvack.org
> ---
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4014 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU
2024-07-02 4:05 ` David Gow
@ 2024-07-02 16:15 ` Shuah Khan
0 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2024-07-02 16:15 UTC (permalink / raw)
To: David Gow, Kees Cook
Cc: kernel test robot, Brendan Higgins, Rae Moar, Gustavo A. R. Silva,
Andrew Morton, linux-kselftest, kunit-dev, linux-hardening,
linux-mm, linux-kernel, Shuah Khan
On 7/1/24 22:05, David Gow wrote:
> On Thu, 20 Jun 2024 at 04:25, Kees Cook <kees@kernel.org> wrote:
>>
>> Since arch_pick_mmap_layout() is an inline for non-MMU systems, disable
>> this test there.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Closes: https://lore.kernel.org/oe-kbuild-all/202406160505.uBge6TMY-lkp@intel.com/
>> Signed-off-by: Kees Cook <kees@kernel.org>
>> ---
>> Resending as v2 with Shuah in To:
>> ---
>> Cc: Shuah Khan <skhan@linuxfoundation.org>
>> Cc: Brendan Higgins <brendan.higgins@linux.dev>
>> Cc: David Gow <davidgow@google.com>
>> Cc: Rae Moar <rmoar@google.com>
>> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: linux-kselftest@vger.kernel.org
>> Cc: kunit-dev@googlegroups.com
>> Cc: linux-hardening@vger.kernel.org
>> Cc: linux-mm@kvack.org
>> ---
>
> Reviewed-by: David Gow <davidgow@google.com>
>
> Cheers,
> -- David
Thank you both. Applied to linux-kselftest kunit branch for next.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU
2024-06-27 17:07 ` Kees Cook
@ 2024-07-02 16:18 ` Shuah Khan
0 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2024-07-02 16:18 UTC (permalink / raw)
To: Kees Cook
Cc: Rae Moar, kernel test robot, Brendan Higgins, David Gow,
Gustavo A. R. Silva, Andrew Morton, linux-kselftest, kunit-dev,
linux-hardening, linux-mm, linux-kernel, Shuah Khan
On 6/27/24 11:07, Kees Cook wrote:
> 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").
>
Applied to linux-kselftest kunit branch for next.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-02 16:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 20:25 [PATCH v2] kunit/usercopy: Disable testing on !CONFIG_MMU Kees Cook
2024-06-20 21:13 ` Rae Moar
2024-06-27 17:07 ` Kees Cook
2024-07-02 16:18 ` Shuah Khan
2024-07-02 4:05 ` David Gow
2024-07-02 16:15 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).