Patch "selftests/resctrl: Fix memory overflow due to unhandled wraparound" has been added to the 6.6-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

    selftests/resctrl: Fix memory overflow due to unhandled wraparound

to the 6.6-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:
     selftests-resctrl-fix-memory-overflow-due-to-unhandl.patch
and it can be found in the queue-6.6 subdirectory.

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



commit 7cbc05472e0806ead0b531c723863baf4e4872fd
Author: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Date:   Thu Oct 24 14:18:40 2024 -0700

    selftests/resctrl: Fix memory overflow due to unhandled wraparound
    
    [ Upstream commit caf02626b2bf164a02c808240f19dbf97aced664 ]
    
    alloc_buffer() allocates and initializes (with random data) a
    buffer of requested size. The initialization starts from the beginning
    of the allocated buffer and incrementally assigns sizeof(uint64_t) random
    data to each cache line. The initialization uses the size of the
    buffer to control the initialization flow, decrementing the amount of
    buffer needing to be initialized after each iteration.
    
    The size of the buffer is stored in an unsigned (size_t) variable s64
    and the test "s64 > 0" is used to decide if initialization is complete.
    The problem is that decrementing the buffer size may wrap around
    if the buffer size is not divisible by "CL_SIZE / sizeof(uint64_t)"
    resulting in the "s64 > 0" test being true and memory beyond the buffer
    "initialized".
    
    Use a signed value for the buffer size to support all buffer sizes.
    
    Fixes: a2561b12fe39 ("selftests/resctrl: Add built in benchmark")
    Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
    Signed-off-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c
index 635f938b11f09..a85ae8148db84 100644
--- a/tools/testing/selftests/resctrl/fill_buf.c
+++ b/tools/testing/selftests/resctrl/fill_buf.c
@@ -116,7 +116,7 @@ static unsigned char *alloc_buffer(size_t buf_size, int memflush)
 {
 	void *buf = NULL;
 	uint64_t *p64;
-	size_t s64;
+	ssize_t s64;
 	int ret;
 
 	ret = posix_memalign(&buf, PAGE_SIZE, buf_size);




[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