All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] syscalls/bind03: Bugfix for running with option "-i"
@ 2021-05-08  2:14 Zhao Gongyi
  2021-05-10 14:54 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi @ 2021-05-08  2:14 UTC (permalink / raw)
  To: ltp

When run the test with option "-i 2", test will fail and
report EADDRINUSE.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v1->v2:replace unlink() with SAFE_UNLINK()
 testcases/kernel/syscalls/bind/bind03.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/bind/bind03.c b/testcases/kernel/syscalls/bind/bind03.c
index ebde19591..879ce1bc6 100644
--- a/testcases/kernel/syscalls/bind/bind03.c
+++ b/testcases/kernel/syscalls/bind/bind03.c
@@ -62,16 +62,14 @@ void run(void)
 	 */
 	TST_EXP_FAIL(bind(sock2, (struct sockaddr *)&sun1, sizeof(sun1)),
 	             EADDRINUSE, "bind() with bound pathname");
-}

-static void cleanup(void)
-{
+	SAFE_UNLINK(sun1.sun_path);
+	SAFE_UNLINK(sun2.sun_path);
 	SAFE_CLOSE(sock1);
 	SAFE_CLOSE(sock2);
 }

 static struct tst_test test = {
-	.cleanup = cleanup,
 	.test_all = run,
 	.needs_tmpdir = 1,
 };
--
2.17.1


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

* [LTP] [PATCH v2] syscalls/bind03: Bugfix for running with option "-i"
  2021-05-08  2:14 [LTP] [PATCH v2] syscalls/bind03: Bugfix for running with option "-i" Zhao Gongyi
@ 2021-05-10 14:54 ` Cyril Hrubis
  2021-05-10 17:15   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2021-05-10 14:54 UTC (permalink / raw)
  To: ltp

Hi!
I was looking at the test wondering why do you try to unlink socket that
wasn't bind properly and it looks like kernel creates the socket even in
a case that the bind fails, which is strange and I would call it a bug.

Looking at the kernel code it indeed does mknod before it takes locks
and checks the socket. Even more it turns out that there is in-flight
patchset that is fixing this:

https://lore.kernel.org/netdev/YDQAmH9zSsaqf+Dg@zeniv-ca.linux.org.uk/

Anyways for now moved the code initializing the sockets into a setup()
function and the only call that had to stay in the run() function is the
unlink(SNAME_B); with a comment that kernel is buggy.

And we will have to write a regression test for this bug once upstream
kernel is fixed.

Also note that I use unlink() here since the test will fail otherwise
once kernel is fixed and there is no socket to be unlinked.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2] syscalls/bind03: Bugfix for running with option "-i"
  2021-05-10 14:54 ` Cyril Hrubis
@ 2021-05-10 17:15   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-05-10 17:15 UTC (permalink / raw)
  To: ltp

Hi,

> Hi!
> I was looking at the test wondering why do you try to unlink socket that
> wasn't bind properly and it looks like kernel creates the socket even in
> a case that the bind fails, which is strange and I would call it a bug.

> Looking at the kernel code it indeed does mknod before it takes locks
> and checks the socket. Even more it turns out that there is in-flight
> patchset that is fixing this:

> https://lore.kernel.org/netdev/YDQAmH9zSsaqf+Dg@zeniv-ca.linux.org.uk/

> Anyways for now moved the code initializing the sockets into a setup()
> function and the only call that had to stay in the run() function is the
> unlink(SNAME_B); with a comment that kernel is buggy.

> And we will have to write a regression test for this bug once upstream
> kernel is fixed.

> Also note that I use unlink() here since the test will fail otherwise
> once kernel is fixed and there is no socket to be unlinked.

FYI I created issue #817 for it, feel free to improve the description.

https://github.com/linux-test-project/ltp/issues/814

Kind regards,
Petr

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

end of thread, other threads:[~2021-05-10 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08  2:14 [LTP] [PATCH v2] syscalls/bind03: Bugfix for running with option "-i" Zhao Gongyi
2021-05-10 14:54 ` Cyril Hrubis
2021-05-10 17:15   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.