Netdev List
 help / color / mirror / Atom feed
* [PATCH net v1] tun: fix inverted error check when re-attaching the filter
@ 2026-09-23  2:56 Rongguang Wei
  2026-09-24 17:59 ` netdev-bot+sashiko
  0 siblings, 1 reply; 4+ messages in thread
From: Rongguang Wei @ 2026-09-23  2:56 UTC (permalink / raw)
  To: netdev
  Cc: willemdebruijn.kernel, jasowangio, andrew+netdev, davem,
	Rongguang Wei

From: Rongguang Wei <weirongguang@kylinos.cn>

tun_attach() return when sk_attach_filter() succeeds instead of when it
fails, so the queue is never published in tun->tfiles[] while TUNSETIFF
still reports success.

Invert the check; nothing is published at that point, so the attach can be
aborted cleanly.

Fixes: 54f968d6efdb ("tuntap: move socket to tun_file")
Signed-off-by: Rongguang Wei <weirongguang@kylinos.cn>
---
 drivers/net/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 5a302709a68a..09720883b9a1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -754,7 +754,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file,
 		lock_sock(tfile->socket.sk);
 		err = sk_attach_filter(&tun->fprog, tfile->socket.sk);
 		release_sock(tfile->socket.sk);
-		if (!err)
+		if (err)
 			goto out;
 	}
 
-- 
2.25.1


No virus found
		Checked by Hillstone Network AntiVirus


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

end of thread, other threads:[~2026-09-28  2:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23  2:56 [PATCH net v1] tun: fix inverted error check when re-attaching the filter Rongguang Wei
2026-09-24 17:59 ` netdev-bot+sashiko
2026-09-25 17:15   ` Willem de Bruijn
2026-09-28  2:02     ` Rongguang Wei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox