Patch "selftests/net/ipsec: Fix Null pointer dereference in rtattr_pack()" has been added to the 6.1-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/net/ipsec: Fix Null pointer dereference in rtattr_pack()

to the 6.1-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-net-ipsec-fix-null-pointer-dereference-in-.patch
and it can be found in the queue-6.1 subdirectory.

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



commit a2048d31e4b3c33a2207cf43c7a9aca766e49a95
Author: Liu Ye <liuye@xxxxxxxxxx>
Date:   Thu Jan 16 09:30:37 2025 +0800

    selftests/net/ipsec: Fix Null pointer dereference in rtattr_pack()
    
    [ Upstream commit 3a0b7fa095212b51ed63892540c4f249991a2d74 ]
    
    Address Null pointer dereference / undefined behavior in rtattr_pack
    (note that size is 0 in the bad case).
    
    Flagged by cppcheck as:
        tools/testing/selftests/net/ipsec.c:230:25: warning: Possible null pointer
        dereference: payload [nullPointer]
        memcpy(RTA_DATA(attr), payload, size);
                               ^
        tools/testing/selftests/net/ipsec.c:1618:54: note: Calling function 'rtattr_pack',
        4th argument 'NULL' value is 0
        if (rtattr_pack(&req.nh, sizeof(req), XFRMA_IF_ID, NULL, 0)) {
                                                           ^
        tools/testing/selftests/net/ipsec.c:230:25: note: Null pointer dereference
        memcpy(RTA_DATA(attr), payload, size);
                               ^
    Signed-off-by: Liu Ye <liuye@xxxxxxxxxx>
    
    Link: https://patch.msgid.link/20250116013037.29470-1-liuye@xxxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
index be4a30a0d02ae..9b44a091802cb 100644
--- a/tools/testing/selftests/net/ipsec.c
+++ b/tools/testing/selftests/net/ipsec.c
@@ -227,7 +227,8 @@ static int rtattr_pack(struct nlmsghdr *nh, size_t req_sz,
 
 	attr->rta_len = RTA_LENGTH(size);
 	attr->rta_type = rta_type;
-	memcpy(RTA_DATA(attr), payload, size);
+	if (payload)
+		memcpy(RTA_DATA(attr), payload, size);
 
 	return 0;
 }




[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