Patch "kasan: fix memory corruption in kasan_bitops_tags test" has been added to the 5.10-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

    kasan: fix memory corruption in kasan_bitops_tags test

to the 5.10-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:
     kasan-fix-memory-corruption-in-kasan_bitops_tags-tes.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 49d11a413c892f839e501e6ad60d838992b06909
Author: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
Date:   Wed Feb 24 12:05:42 2021 -0800

    kasan: fix memory corruption in kasan_bitops_tags test
    
    [ Upstream commit e66e1799a76621003e5b04c9c057826a2152e103 ]
    
    Since the hardware tag-based KASAN mode might not have a redzone that
    comes after an allocated object (when kasan.mode=prod is enabled), the
    kasan_bitops_tags() test ends up corrupting the next object in memory.
    
    Change the test so it always accesses the redzone that lies within the
    allocated object's boundaries.
    
    Link: https://linux-review.googlesource.com/id/I67f51d1ee48f0a8d0fe2658c2a39e4879fe0832a
    Link: https://lkml.kernel.org/r/7d452ce4ae35bb1988d2c9244dfea56cf2cc9315.1610733117.git.andreyknvl@xxxxxxxxxx
    Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
    Reviewed-by: Marco Elver <elver@xxxxxxxxxx>
    Reviewed-by: Alexander Potapenko <glider@xxxxxxxxxx>
    Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
    Cc: Branislav Rankov <Branislav.Rankov@xxxxxxx>
    Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
    Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
    Cc: Evgenii Stepanov <eugenis@xxxxxxxxxx>
    Cc: Kevin Brodsky <kevin.brodsky@xxxxxxx>
    Cc: Peter Collingbourne <pcc@xxxxxxxxxx>
    Cc: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
    Cc: Will Deacon <will.deacon@xxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 662f862702fc..400507f1e5db 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -737,13 +737,13 @@ static void kasan_bitops_tags(struct kunit *test)
 		return;
 	}
 
-	/* Allocation size will be rounded to up granule size, which is 16. */
-	bits = kzalloc(sizeof(*bits), GFP_KERNEL);
+	/* kmalloc-64 cache will be used and the last 16 bytes will be the redzone. */
+	bits = kzalloc(48, GFP_KERNEL);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, bits);
 
-	/* Do the accesses past the 16 allocated bytes. */
-	kasan_bitops_modify(test, BITS_PER_LONG, &bits[1]);
-	kasan_bitops_test_and_modify(test, BITS_PER_LONG + BITS_PER_BYTE, &bits[1]);
+	/* Do the accesses past the 48 allocated bytes, but within the redone. */
+	kasan_bitops_modify(test, BITS_PER_LONG, (void *)bits + 48);
+	kasan_bitops_test_and_modify(test, BITS_PER_LONG + BITS_PER_BYTE, (void *)bits + 48);
 
 	kfree(bits);
 }



[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