Patch "selftests/net: mptcp: fix uninitialized variable warnings" 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

    selftests/net: mptcp: fix uninitialized variable warnings

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:
     selftests-net-mptcp-fix-uninitialized-variable-warni.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 14fc3eb027d5fdc7bb85826ace30faadd9923d6d
Author: Willem de Bruijn <willemb@xxxxxxxxxx>
Date:   Fri Nov 24 12:15:22 2023 -0500

    selftests/net: mptcp: fix uninitialized variable warnings
    
    [ Upstream commit 00a4f8fd9c750f20d8fd4535c71c9caa7ef5ff2f ]
    
    Same init_rng() in both tests. The function reads /dev/urandom to
    initialize srand(). In case of failure, it falls back onto the
    entropy in the uninitialized variable. Not sure if this is on purpose.
    But failure reading urandom should be rare, so just fail hard. While
    at it, convert to getrandom(). Which man 4 random suggests is simpler
    and more robust.
    
        mptcp_inq.c:525:6:
        mptcp_connect.c:1131:6:
    
        error: variable 'foo' is used uninitialized
        whenever 'if' condition is false
        [-Werror,-Wsometimes-uninitialized]
    
    Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp")
    Fixes: b51880568f20 ("selftests: mptcp: add inq test case")
    Cc: Florian Westphal <fw@xxxxxxxxx>
    Signed-off-by: Willem de Bruijn <willemb@xxxxxxxxxx>
    
    ----
    
    When input is randomized because this is expected to meaningfully
    explore edge cases, should we also add
    1. logging the random seed to stdout and
    2. adding a command line argument to replay from a specific seed
    I can do this in net-next, if authors find it useful in this case.
    Reviewed-by: Matthieu Baerts <matttbe@xxxxxxxxxx>
    
    Link: https://lore.kernel.org/r/20231124171645.1011043-5-willemdebruijn.kernel@xxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index 77bb62feb8726..37c1ec888ba2e 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -15,6 +15,7 @@
 #include <unistd.h>
 
 #include <sys/poll.h>
+#include <sys/random.h>
 #include <sys/sendfile.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -734,15 +735,11 @@ int main_loop_s(int listensock)
 
 static void init_rng(void)
 {
-	int fd = open("/dev/urandom", O_RDONLY);
 	unsigned int foo;
 
-	if (fd > 0) {
-		int ret = read(fd, &foo, sizeof(foo));
-
-		if (ret < 0)
-			srand(fd + foo);
-		close(fd);
+	if (getrandom(&foo, sizeof(foo), 0) == -1) {
+		perror("getrandom");
+		exit(1);
 	}
 
 	srand(foo);



[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