Patch "kselftest: vm: fix mdwe's mmap_FIXED test case" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kselftest: vm: fix mdwe's mmap_FIXED test case

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kselftest-vm-fix-mdwe-s-mmap_fixed-test-case.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2ee6e365e524862d0a563f94d948edf474ce9bf1
Author: Florent Revest <revest@xxxxxxxxxxxx>
Date:   Mon Aug 28 17:08:54 2023 +0200

    kselftest: vm: fix mdwe's mmap_FIXED test case
    
    [ Upstream commit a27e2e2d465e4ed73371974040689ac3e78fe3ee ]
    
    I checked with the original author, the mmap_FIXED test case wasn't
    properly tested and fails.  Currently, it maps two consecutive (non
    overlapping) pages and expects the second mapping to be denied by MDWE but
    these two pages have nothing to do with each other so MDWE is actually out
    of the picture here.
    
    What the test actually intended to do was to remap a virtual address using
    MAP_FIXED.  However, this operation unmaps the existing mapping and
    creates a new one so the va is backed by a new page and MDWE is again out
    of the picture, all remappings should succeed.
    
    This patch keeps the test case to make it clear that this situation is
    expected to work: MDWE shouldn't block a MAP_FIXED replacement.
    
    Link: https://lkml.kernel.org/r/20230828150858.393570-3-revest@xxxxxxxxxxxx
    Fixes: 4cf1fe34fd18 ("kselftest: vm: add tests for memory-deny-write-execute")
    Signed-off-by: Florent Revest <revest@xxxxxxxxxxxx>
    Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>
    Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx>
    Reviewed-by: Ryan Roberts <ryan.roberts@xxxxxxx>
    Tested-by: Ryan Roberts <ryan.roberts@xxxxxxx>
    Tested-by: Ayush Jain <ayush.jain3@xxxxxxx>
    Cc: Alexey Izbyshev <izbyshev@xxxxxxxxx>
    Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx>
    Cc: Greg Thelen <gthelen@xxxxxxxxxx>
    Cc: Joey Gouly <joey.gouly@xxxxxxx>
    Cc: KP Singh <kpsingh@xxxxxxxxxx>
    Cc: Mark Brown <broonie@xxxxxxxxxx>
    Cc: Michal Hocko <mhocko@xxxxxxxx>
    Cc: Peter Xu <peterx@xxxxxxxxxx>
    Cc: Szabolcs Nagy <Szabolcs.Nagy@xxxxxxx>
    Cc: Topi Miettinen <toiwoton@xxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c
index bc91bef5d254e..0c5e469ae38fa 100644
--- a/tools/testing/selftests/mm/mdwe_test.c
+++ b/tools/testing/selftests/mm/mdwe_test.c
@@ -168,13 +168,10 @@ TEST_F(mdwe, mmap_FIXED)
 	self->p = mmap(NULL, self->size, PROT_READ, self->flags, 0, 0);
 	ASSERT_NE(self->p, MAP_FAILED);
 
-	p = mmap(self->p + self->size, self->size, PROT_READ | PROT_EXEC,
+	/* MAP_FIXED unmaps the existing page before mapping which is allowed */
+	p = mmap(self->p, self->size, PROT_READ | PROT_EXEC,
 		 self->flags | MAP_FIXED, 0, 0);
-	if (variant->enabled) {
-		EXPECT_EQ(p, MAP_FAILED);
-	} else {
-		EXPECT_EQ(p, self->p);
-	}
+	EXPECT_EQ(p, self->p);
 }
 
 TEST_F(mdwe, arm64_BTI)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux