mm: export copy_to_kernel_nofault
Subsystems (2)
PATCH 1/1 mm: export copy_to_kernel_nofault
From: Arnd Bergmann <[email protected]>
This symbol is now used on the kasan test module, so it needs to be exported.
ERROR: modpost: "copy_to_kernel_nofault" [mm/kasan/kasan_test.ko] undefined!
--- mm/maccess.c | 1 + 1 file changed, 1 insertion(+)
mm/maccess.c +1 -0
@@ -82,6 +82,7 @@ long copy_to_kernel_nofault(void *dst, const void *src, size_t size)pagefault_enable ();return -EFAULT ; } +EXPORT_SYMBOL_GPL (copy_to_kernel_nofault);long strncpy_from_kernel_nofault (char *dst,const void *unsafe_addr,long count) {
Signature · 1 line
2.39.5
Quoted 18 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
This symbol is now used on the kasan test module, so it needs to be exported.
ERROR: modpost: "
copy_to_kernel_nofault" [mm/kasan/kasan_test.ko] undefined!Fixes 44749130ffb4 ("kasan: migrate copy_user_test to kunit")Signed-off-by Arnd Bergmann <[email protected]>--- mm/maccess.c | 1 + 1 file changed, 1 insertion(+)mm/maccess.c +0
-0
mm/maccess.c long copy_to_kernel_nofault(void *dst, const void *src, size_t size) · line 88
Quoted 7 lines
mm/maccess.c +1
-0@@ -82,6 +82,7 @@ long copy_to_kernel_nofault(void *dst, const void *src, size_t size)pagefault_enable ();return -EFAULT ; } +EXPORT_SYMBOL_GPL (copy_to_kernel_nofault);long strncpy_from_kernel_nofault (char *dst,const void *unsafe_addr,long count) {
Signature · 3 lines
Cheers, David / dhildenb
Quoted 27 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
This symbol is now used on the kasan test module, so it needs to be exported.
ERROR: modpost: "
copy_to_kernel_nofault" [mm/kasan/kasan_test.ko] undefined!Fixes 44749130ffb4 ("kasan: migrate copy_user_test to kunit")Signed-off-by Arnd Bergmann <[email protected]>--- mm/maccess.c | 1 + 1 file changed, 1 insertion(+)mm/maccess.c +1
-1@@ -82,6 +82,7 @@ long copy_to_kernel_nofault(void *dst, const void *src, size_t size)pagefault_enable ();return -EFAULT ; } +EXPORT_SYMBOL_GPL (copy_to_kernel_nofault);long strncpy_from_kernel_nofault (char *dst,const void *unsafe_addr,long count) { --
Quoted 2 lines
2.39.5
Thank you!
Quoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
This symbol is now used on the kasan test module, so it needs to be exported.
ERROR: modpost: "
copy_to_kernel_nofault" [mm/kasan/kasan_test.ko] undefined!
Meh, it would be great not to export internal helpers just because someone wants to test them. Please just mark that test built-in only instead.
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Quoted 8 lines
Quoted 4 lines
This symbol is now used on the kasan test module, so it needs to be exported.
ERROR: modpost: "
copy_to_kernel_nofault" [mm/kasan/kasan_test.ko] undefined!Meh, it would be great not to export internal helpers just because someone wants to test them. Please just mark that test built-in only instead.
We have EXPORT_SYMBOL_IF_KUNIT. See include/kunit/visibility.h - that's more appropriate, and also adjust kasan_test.c to do MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING).
Quoted 10 lines · Marco Elver
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
This symbol is now used on the kasan test module, so it needs to be exported.
ERROR: modpost: "
copy_to_kernel_nofault" [mm/kasan/kasan_test.ko] undefined!
Quoted 7 lines
Quoted 3 lines
Meh, it would be great not to export internal helpers just because someone wants to test them. Please just mark that test built-in only instead.
We have
EXPORT_SYMBOL_IF_KUNIT. Seeinclude/kunit/visibility.h- that's more appropriate, and also adjustkasan_test.cto doMODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING).
Thats a little better, but at least in this case I still think it is a very bad idea. copy_to_kernel_nofault is a perfect vector for exploit code to probe writing to kernel address without causing faults so it really should never ever be exported.
Quoted 16 lines · Christoph Hellwig
Quoted 14 lines · Marco Elver
Quoted 12 lines · Christoph Hellwig
Quoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
This symbol is now used on the kasan test module, so it needs to be exported.
ERROR: modpost: "
copy_to_kernel_nofault" [mm/kasan/kasan_test.ko] undefined!Meh, it would be great not to export internal helpers just because someone wants to test them. Please just mark that test built-in only instead.
Quoted 8 lines
Quoted 3 lines
We have
EXPORT_SYMBOL_IF_KUNIT. Seeinclude/kunit/visibility.h- that's more appropriate, and also adjustkasan_test.cto doMODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING).Thats a little better, but at least in this case I still think it is a very bad idea.
copy_to_kernel_nofaultis a perfect vector for exploit code to probe writing to kernel address without causing faults so it really should never ever be exported.
Another alternative is to just #ifndef MODULE the offending test case, so it's only available if built-in. No need to just make the whole test built-in only. I know there are users of this particular test that rely on it being a module.
Quoted 4 lines · Marco Elver
Another alternative is to just #ifndef MODULE the offending test case, so it's only available if built-in. No need to just make the whole test built-in only. I know there are users of this particular test that rely on it being a module.
That sounds good to me.
Andrew Morton
maintainerQuoted 7 lines · On Wed, 23 Oct 2024 00:05:36 -0700 Christoph Hellwig <[email protected]> wrote:
Quoted 4 lines · Marco Elver
Another alternative is to just #ifndef MODULE the offending test case, so it's only available if built-in. No need to just make the whole test built-in only. I know there are users of this particular test that rely on it being a module.
That sounds good to me.
We still don't have patch which does this, so this series is stalled.
Sabyrzhan, could you please consider this?
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Wed, 23 Oct 2024 00:05:36 -0700 Christoph Hellwig <[email protected]> wrote:
Quoted 4 lines · Marco Elver
Another alternative is to just #ifndef MODULE the offending test case, so it's only available if built-in. No need to just make the whole test built-in only. I know there are users of this particular test that rely on it being a module.
Quoted 5 lines
Quoted 1 line
That sounds good to me.
We still don't have patch which does this, so this series is stalled.
Sabyrzhan, could you please consider this?
I've just posted a follow-up that removes the exported symbol. See Message-Id: <[email protected]> Sorry for taking so long.