Skip to content

Commit e1a57c3

Browse files
mtth-bfftl0kod
authored andcommitted
selftests/landlock: Remove invalid unix socket bind()
Remove bind() call on a client socket that doesn't make sense. Since strlen(cli_un.sun_path) returns a random value depending on stack garbage, that many uninitialized bytes are read from the stack as an unix socket address. This creates random test failures due to the bind address being invalid or already in use if the same stack value comes up twice. Fixes: f83d51a ("selftests/landlock: Check IOCTL restrictions for named UNIX domain sockets") Signed-off-by: Matthieu Buffet <matthieu@buffet.re> Reviewed-by: Günther Noack <gnoack@google.com> Link: https://lore.kernel.org/r/20251201003631.190817-1-matthieu@buffet.re Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent 6685201 commit e1a57c3

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

tools/testing/selftests/landlock/fs_test.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4391,9 +4391,6 @@ TEST_F_FORK(layout1, named_unix_domain_socket_ioctl)
43914391
cli_fd = socket(AF_UNIX, SOCK_STREAM, 0);
43924392
ASSERT_LE(0, cli_fd);
43934393

4394-
size = offsetof(struct sockaddr_un, sun_path) + strlen(cli_un.sun_path);
4395-
ASSERT_EQ(0, bind(cli_fd, (struct sockaddr *)&cli_un, size));
4396-
43974394
bzero(&cli_un, sizeof(cli_un));
43984395
cli_un.sun_family = AF_UNIX;
43994396
strncpy(cli_un.sun_path, path, sizeof(cli_un.sun_path));

0 commit comments

Comments
 (0)