linux-next: manual merge of the mm tree with Linus' tree

Stephen Rothwell posted 1 patch 1 month, 4 weeks ago
linux-next: manual merge of the mm tree with Linus' tree
Posted by Stephen Rothwell 1 month, 4 weeks ago
Hi all,

Today's linux-next merge of the mm tree got a conflict in:

  mm/kasan/kasan_test_c.c

between commit:

  a2f115470520 ("kasan: rust: Add KASAN smoke test via UAF")

from Linus' tree and commit:

  88ad9dc30bbf ("mm, kasan: instrument copy_from/to_kernel_nofault")

from the mm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc mm/kasan/kasan_test_c.c
index a181e4780d9d,329d815185a5..000000000000
--- a/mm/kasan/kasan_test_c.c
+++ b/mm/kasan/kasan_test_c.c
@@@ -1944,16 -1944,36 +1944,46 @@@ static void match_all_mem_tag(struct ku
  	kfree(ptr);
  }
  
 +/*
 + * Check that Rust performing a use-after-free using `unsafe` is detected.
 + * This is a smoke test to make sure that Rust is being sanitized properly.
 + */
 +static void rust_uaf(struct kunit *test)
 +{
 +	KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_RUST);
 +	KUNIT_EXPECT_KASAN_FAIL(test, kasan_test_rust_uaf());
 +}
 +
+ static void copy_from_to_kernel_nofault_oob(struct kunit *test)
+ {
+ 	char *ptr;
+ 	char buf[128];
+ 	size_t size = sizeof(buf);
+ 
+ 	/* Not detecting fails currently with HW_TAGS */
+ 	KASAN_TEST_NEEDS_CONFIG_OFF(test, CONFIG_KASAN_HW_TAGS);
+ 
+ 	ptr = kmalloc(size - KASAN_GRANULE_SIZE, GFP_KERNEL);
+ 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
+ 	OPTIMIZER_HIDE_VAR(ptr);
+ 
+ 	if (IS_ENABLED(CONFIG_KASAN_SW_TAGS)) {
+ 		/* Check that the returned pointer is tagged. */
+ 		KUNIT_EXPECT_GE(test, (u8)get_tag(ptr), (u8)KASAN_TAG_MIN);
+ 		KUNIT_EXPECT_LT(test, (u8)get_tag(ptr), (u8)KASAN_TAG_KERNEL);
+ 	}
+ 
+ 	KUNIT_EXPECT_KASAN_FAIL(test,
+ 		copy_from_kernel_nofault(&buf[0], ptr, size));
+ 	KUNIT_EXPECT_KASAN_FAIL(test,
+ 		copy_from_kernel_nofault(ptr, &buf[0], size));
+ 	KUNIT_EXPECT_KASAN_FAIL(test,
+ 		copy_to_kernel_nofault(&buf[0], ptr, size));
+ 	KUNIT_EXPECT_KASAN_FAIL(test,
+ 		copy_to_kernel_nofault(ptr, &buf[0], size));
+ 	kfree(ptr);
+ }
+ 
  static struct kunit_case kasan_kunit_test_cases[] = {
  	KUNIT_CASE(kmalloc_oob_right),
  	KUNIT_CASE(kmalloc_oob_left),
@@@ -2027,7 -2047,7 +2057,8 @@@
  	KUNIT_CASE(match_all_not_assigned),
  	KUNIT_CASE(match_all_ptr_tag),
  	KUNIT_CASE(match_all_mem_tag),
 +	KUNIT_CASE(rust_uaf),
+ 	KUNIT_CASE(copy_from_to_kernel_nofault_oob),
  	{}
  };
  
Re: linux-next: manual merge of the mm tree with Linus' tree
Posted by Miguel Ojeda 1 month, 4 weeks ago
On Mon, Sep 30, 2024 at 1:57 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the mm tree got a conflict in:
>
>   mm/kasan/kasan_test_c.c

Looks good, of course, thanks!

Cheers,
Miguel