[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <bd7ff00a-6892-fd56-b3ca-4b3feb6121d8@alu.unizg.hr>
Date: Fri, 6 Jan 2023 18:18:58 +0100
From: Mirsad Goran Todorovac <mirsad.todorovac@....unizg.hr>
To: netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Shuah Khan <shuah@...nel.org>,
Kuniyuki Iwashima <kuniyu@...zon.co.jp>,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
Florian Westphal <fw@...len.de>
Subject: [PATCH selftest/net/af_unix 1/1] Fix size of parameter to connect()
From: Mirsad Goran Todorovac <mirsad.todorovac@....unizg.hr>
Adjust size parameter in connect() to match the type of the parameter, to fix "No such file or directory"
error in selftests/net/af_unix/test_oob_unix.c:127.
The existing code happens to work provided that the autogenerated pathname is shorter than
sizeof (struct sockaddr), which is why it hasn't been noticed earlier.
Visible from the trace excerpt:
bind(3, {sa_family=AF_UNIX, sun_path="unix_oob_453059"}, 110) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fa6a6577a10) = 453060
[pid <child>] connect(6, {sa_family=AF_UNIX, sun_path="unix_oob_45305"}, 16) = -1 ENOENT (No such file or directory)
BUG: The filename is trimmed to sizeof (struct sockaddr).
The patch is generated against the "vanilla" torvalds mainline tree 6.2-rc2.
Thanks and regards,
Mirsad Todorovac
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@....unizg.hr>
Cc: "David S. Miller" <davem@...emloft.net>
Cc: Eric Dumazet <edumazet@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>
Cc: Paolo Abeni <pabeni@...hat.com>
Cc: Shuah Khan <shuah@...nel.org>
Cc: Kuniyuki Iwashima <kuniyu@...zon.co.jp>
Cc: Florian Westphal <fw@...len.de>
Reviewed-by: Florian Westphal <fw@...len.de>
---
tools/testing/selftests/net/af_unix/test_unix_oob.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/af_unix/test_unix_oob.c b/tools/testing/selftests/net/af_unix/test_unix_oob.c
index b57e91e1c3f2..532459a15067 100644
--- a/tools/testing/selftests/net/af_unix/test_unix_oob.c
+++ b/tools/testing/selftests/net/af_unix/test_unix_oob.c
@@ -124,7 +124,7 @@ void producer(struct sockaddr_un *consumer_addr)
wait_for_signal(pipefd[0]);
if (connect(cfd, (struct sockaddr *)consumer_addr,
- sizeof(struct sockaddr)) != 0) {
+ sizeof(*consumer_addr)) != 0) {
perror("Connect failed");
kill(0, SIGTERM);
exit(1);
--
Mirsad Goran Todorovac
Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
--
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb, Republic of Croatia
The European Union
Powered by blists - more mailing lists