linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH selftest/net/af_unix 1/1] Fix size of parameter to connect()
@ 2023-01-06 17:18 Mirsad Goran Todorovac
  2023-01-06 17:58 ` Kuniyuki Iwashima
  0 siblings, 1 reply; 14+ messages in thread
From: Mirsad Goran Todorovac @ 2023-01-06 17:18 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Shuah Khan, Kuniyuki Iwashima, linux-kselftest, linux-kernel,
	Florian Westphal


From: Mirsad Goran Todorovac <mirsad.todorovac@alu.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@alu.unizg.hr>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Cc: Florian Westphal <fw@strlen.de>
Reviewed-by: Florian Westphal <fw@strlen.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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-01-09  9:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-06 17:18 [PATCH selftest/net/af_unix 1/1] Fix size of parameter to connect() Mirsad Goran Todorovac
2023-01-06 17:58 ` Kuniyuki Iwashima
2023-01-06 19:19   ` Mirsad Goran Todorovac
2023-01-06 19:28   ` [PATCH net v2] af_unix: selftest: Fix the size of the " Mirsad Goran Todorovac
2023-01-07  0:14     ` Jakub Kicinski
2023-01-07  1:37       ` [PATCH net v3] " Mirsad Goran Todorovac
2023-01-07  1:42       ` [PATCH net v2] " Mirsad Goran Todorovac
2023-01-07  2:08         ` Jakub Kicinski
2023-01-07  3:36           ` Mirsad Goran Todorovac
2023-01-07  3:40           ` [PATCH net v4] " Mirsad Goran Todorovac
2023-01-09  1:15             ` Kuniyuki Iwashima
2023-01-09  8:53               ` Mirsad Goran Todorovac
2023-01-09  8:20             ` patchwork-bot+netdevbpf
2023-01-08 21:30           ` [PATCH net v2] " Mirsad Goran Todorovac

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).