From: Rongguang Wei 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 --- 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