tun: Check tun device queue status in tun_chr_write_iter
Subsystems (3)
PATCH v2 1/1 tun: Check tun device queue status in tun_chr_write_iter
syzbot found below warning:
------------[ cut here ]------------ geneve0 received packet on queue 3, but number of RX queues is 3 WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_get_rxqueue net/core/dev.c:4611 [inline] WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 Modules linked in: CPU: 1 PID: 29734 Comm: syz-executor.0 Not tainted 5.10.0 #5 Hardware name: linux,dummy-virt (DT) pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--) pc : netif_get_rxqueue net/core/dev.c:4611 [inline] pc : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 lr : netif_get_rxqueue net/core/dev.c:4611 [inline] lr : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683
sp : ffffa00016127770
x29: ffffa00016127770 x28: ffff3f4607d6acb4
x27: ffff3f4607d6acb0 x26: ffff3f4607d6ad20
x25: ffff3f461de3c000 x24: ffff3f4607d6ad28
x23: ffffa00010059000 x22: ffff3f4608719100
x21: 0000000000000003 x20: ffffa000161278a0
x19: ffff3f4607d6ac40 x18: 0000000000000000
x17: 0000000000000000 x16: 00000000f2f2f204
x15: 00000000f2f20000 x14: 6465766965636572
x13: 20306576656e6567 x12: ffff98b8ed3b924d
x11: 1ffff8b8ed3b924c x10: ffff98b8ed3b924c
x9 : ffffc5c76525c9c4 x8 : 0000000000000000
x7 : 0000000000000001 x6 : ffff98b8ed3b924c
x5 : ffff3f460f3b29c0 x4 : dfffa00000000000
x3 : ffffc5c765000000 x2 : 0000000000000000
x1 : 0000000000000000 x0 : ffff3f460f3b29c0
Call trace: netif_get_rxqueue net/core/dev.c:4611 [inline] netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 do_xdp_generic net/core/dev.c:4777 [inline] do_xdp_generic+0x9c/0x190 net/core/dev.c:4770 tun_get_user+0xd94/0x2010 drivers/net/tun.c:1938 tun_chr_write_iter+0x98/0x100 drivers/net/tun.c:2036 call_write_iter include/linux/fs.h:1960 [inline] new_sync_write+0x260/0x370 fs/read_write.c:515 vfs_write+0x51c/0x61c fs/read_write.c:602 ksys_write+0xfc/0x200 fs/read_write.c:655 __do_sys_write fs/read_write.c:667 [inline] __se_sys_write fs/read_write.c:664 [inline] __arm64_sys_write+0x50/0x60 fs/read_write.c:664 __invoke_syscall arch/arm64/kernel/syscall.c:36 [inline] invoke_syscall arch/arm64/kernel/syscall.c:48 [inline] el0_svc_common.constprop.0+0xf4/0x414 arch/arm64/kernel/syscall.c:155 do_el0_svc+0x50/0x11c arch/arm64/kernel/syscall.c:217 el0_svc+0x20/0x30 arch/arm64/kernel/entry-common.c:353 el0_sync_handler+0xe4/0x1e0 arch/arm64/kernel/entry-common.c:369 el0_sync+0x148/0x180 arch/arm64/kernel/entry.S:683
This is because the detached queue is used to send data. Therefore, we need to check the queue status in the tun_chr_write_iter function.
---v1->v2: add fixes tag
drivers/net/tun.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/tun.c +5 -0
@@ -2019,6 +2019,11 @@ static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from)if (!tun)return -EBADFD ; +if (tfile->detached) { +tun_put (tun); +return -ENETDOWN ; + } +if ((file->f_flags &O_NONBLOCK ) || (iocb->ki_flags &IOCB_NOWAIT )) noblock =1 ;
Signature · 1 line
2.17.1
Quoted 53 lines · Liu Jian
syzbot found below warning:
------------[ cut here ]------------ geneve0 received packet on queue 3, but number of RX queues is 3 WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_get_rxqueue net/core/dev.c:4611 [inline] WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 Modules linked in: CPU: 1 PID: 29734 Comm: syz-executor.0 Not tainted 5.10.0 #5 Hardware name: linux,dummy-virt (DT) pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--) pc : netif_get_rxqueue net/core/dev.c:4611 [inline] pc : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 lr : netif_get_rxqueue net/core/dev.c:4611 [inline] lr : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683sp :
ffffa00016127770
x29:ffffa00016127770x28:ffff3f4607d6acb4
x27:ffff3f4607d6acb0x26:ffff3f4607d6ad20
x25:ffff3f461de3c000x24:ffff3f4607d6ad28
x23:ffffa00010059000x22:ffff3f4608719100
x21: 0000000000000003 x20:ffffa000161278a0
x19:ffff3f4607d6ac40x18: 0000000000000000
x17: 0000000000000000 x16:00000000f2f2f204
x15:00000000f2f20000x14: 6465766965636572
x13:20306576656e6567x12:ffff98b8ed3b924d
x11:1ffff8b8ed3b924cx10:ffff98b8ed3b924c
x9 :ffffc5c76525c9c4x8 : 0000000000000000
x7 : 0000000000000001 x6 :ffff98b8ed3b924c
x5 :ffff3f460f3b29c0x4 :dfffa00000000000
x3 :ffffc5c765000000x2 : 0000000000000000
x1 : 0000000000000000 x0 :ffff3f460f3b29c0Call trace: netif_get_rxqueue net/core/dev.c:4611 [inline] netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 do_xdp_generic net/core/dev.c:4777 [inline] do_xdp_generic+0x9c/0x190 net/core/dev.c:4770 tun_get_user+0xd94/0x2010 drivers/net/tun.c:1938 tun_chr_write_iter+0x98/0x100 drivers/net/tun.c:2036 call_write_iter include/linux/fs.h:1960 [inline] new_sync_write+0x260/0x370 fs/read_write.c:515 vfs_write+0x51c/0x61c fs/read_write.c:602 ksys_write+0xfc/0x200 fs/read_write.c:655 __do_sys_write fs/read_write.c:667 [inline] __se_sys_write fs/read_write.c:664 [inline] __arm64_sys_write+0x50/0x60 fs/read_write.c:664 __invoke_syscall arch/arm64/kernel/syscall.c:36 [inline] invoke_syscall arch/arm64/kernel/syscall.c:48 [inline] el0_svc_common.constprop.0+0xf4/0x414 arch/arm64/kernel/syscall.c:155 do_el0_svc+0x50/0x11c arch/arm64/kernel/syscall.c:217 el0_svc+0x20/0x30 arch/arm64/kernel/entry-common.c:353 el0_sync_handler+0xe4/0x1e0 arch/arm64/kernel/entry-common.c:369 el0_sync+0x148/0x180 arch/arm64/kernel/entry.S:683
Quoted 4 lines
This is because the detached queue is used to send data. Therefore, we need to check the queue status in the
tun_chr_write_iterfunction.Fixes cde8b15f1aab ("tuntap: add ioctl to attach or detach a file form tuntap device")
Not sure this deserves a stable.
Quoted 11 lines
Signed-off-by Liu Jian <[email protected]>---
v1->v2: add fixes tagdrivers/net/tun.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/tun.c +0
-0
drivers/net/tun.c static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 2022
Quoted 4 lines
drivers/net/tun.c +1
-0@@ -2019,6 +2019,11 @@ static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from)if (!tun)return -EBADFD ; +if (tfile->detached) {
tfile->detached is synchronized through rtnl_lock which is probably not suitable for the datapath. We probably need to rcuify this.
drivers/net/tun.c static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 2024
Quoted 2 lines
drivers/net/tun.c +2
-0+tun_put (tun); +return -ENETDOWN ;
Another question is that can some user space depend on this behaviour? I wonder if it's more safe to pretend the packet was received here?
Thanks
Quoted 8 lines
drivers/net/tun.c +2
-1+ } +if ((file->f_flags &O_NONBLOCK ) || (iocb->ki_flags &IOCB_NOWAIT )) noblock =1 ; --2.17.1
Quoted 95 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Friday, September 16, 2022 9:57 AM
To: liujian (CE) <[email protected]>
Cc: davem <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Alexei Starovoitov <[email protected]>; Daniel Borkmann <[email protected]>; Jesper Dangaard Brouer <[email protected]>; John Fastabend <[email protected]>; netdev <[email protected]>
Subject: Re: [PATCH net v2] tun: Check tun device queue status intun_chr_write_iterQuoted 9 lines · Liu Jian
syzbot found below warning:
------------[ cut here ]------------ geneve0 received packet on queue 3, but number of RX queues is 3 WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_get_rxqueue net/core/dev.c:4611 [inline] WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 Moduleslinked in:
Quoted 44 lines
CPU: 1 PID: 29734 Comm: syz-executor.0 Not tainted 5.10.0 #5 Hardware name: linux,dummy-virt (DT) pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--) pc : netif_get_rxqueue net/core/dev.c:4611 [inline] pc : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 lr : netif_get_rxqueue net/core/dev.c:4611 [inline] lr : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 sp :
ffffa00016127770
x29:ffffa00016127770x28:ffff3f4607d6acb4
x27:ffff3f4607d6acb0x26:ffff3f4607d6ad20
x25:ffff3f461de3c000x24:ffff3f4607d6ad28
x23:ffffa00010059000x22:ffff3f4608719100
x21: 0000000000000003 x20:ffffa000161278a0
x19:ffff3f4607d6ac40x18: 0000000000000000
x17: 0000000000000000 x16:00000000f2f2f204
x15:00000000f2f20000x14: 6465766965636572
x13:20306576656e6567x12:ffff98b8ed3b924d
x11:1ffff8b8ed3b924cx10:ffff98b8ed3b924c
x9 :ffffc5c76525c9c4x8 : 0000000000000000
x7 : 0000000000000001 x6 :ffff98b8ed3b924c
x5 :ffff3f460f3b29c0x4 :dfffa00000000000
x3 :ffffc5c765000000x2 : 0000000000000000
x1 : 0000000000000000 x0 :ffff3f460f3b29c0Call trace:netif_get_rxqueue net/core/dev.c:4611 [inline] netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 do_xdp_generic net/core/dev.c:4777 [inline] do_xdp_generic+0x9c/0x190 net/core/dev.c:4770 tun_get_user+0xd94/0x2010 drivers/net/tun.c:1938 tun_chr_write_iter+0x98/0x100 drivers/net/tun.c:2036 call_write_iter
include/linux/fs.h:1960[inline]
new_sync_write+0x260/0x370fs/read_write.c:515vfs_write+0x51c/0x61cfs/read_write.c:602
ksys_write+0xfc/0x200fs/read_write.c:655__do_sys_writefs/read_write.c:667[inline]__se_sys_writefs/read_write.c:664[inline]
__arm64_sys_write+0x50/0x60fs/read_write.c:664__invoke_syscallarch/arm64/kernel/syscall.c:36[inline]invoke_syscallarch/arm64/kernel/syscall.c:48[inline]el0_svc_common.constprop.0+0xf4/0x414 arch/arm64/kernel/syscall.c:155 do_el0_svc+0x50/0x11c arch/arm64/kernel/syscall.c:217 el0_svc+0x20/0x30 arch/arm64/kernel/entry-common.c:353 el0_sync_handler+0xe4/0x1e0 arch/arm64/kernel/entry-common.c:369 el0_sync+0x148/0x180 arch/arm64/kernel/entry.S:683Quoted 5 lines
This is because the detached queue is used to send data. Therefore, we need to check the queue status in the
tun_chr_write_iterfunction.Fixes cde8b15f1aab ("tuntap: add ioctl to attach or detach a fileform tuntap device")
Not sure this deserves a stable.
drivers/net/tun.c static ssize_t tun_chr_write_iter(struct kiocb
Quoted 11 lines
Signed-off-by Liu Jian <[email protected]>---
v1->v2: add fixes tagdrivers/net/tun.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/tun.c index renamed from drivers/net/tun.c +0
-0
259b2b84b2b3..261411c1a6bb100644drivers/net/tun.c +0
-0@@ -2019,6 +2019,11 @@ static ssize_t tun_chr_write_iter(struct kiocb*iocb, struct
iov_iter*from)drivers/net/tun.c static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 2022
Quoted 4 lines
drivers/net/tun.c +1
-0if (!tun)return -EBADFD ; +if (tfile->detached) {
Quoted 9 lines
tfile->detachedis synchronized throughrtnl_lockwhich is probably not suitable for the datapath. We probably need to rcuify this.drivers/net/tun.c static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 2024
Quoted 2 lines
drivers/net/tun.c +2
-0+tun_put (tun); +return -ENETDOWN ;Another question is that can some user space depend on this behaviour? I wonder if it's more safe to pretend the packet was received here?
Thanks for your review. I don't know whether there was any depend on this behavior. If that's the case, I think it's better to keep this warning.
What is your opinion on this warning?
Quoted 10 lines
Thanks
Quoted 8 lines
drivers/net/tun.c +2
-1+ } +if ((file->f_flags &O_NONBLOCK ) || (iocb->ki_flags &IOCB_NOWAIT )) noblock =1 ; --2.17.1
Quoted 22 lines
-----Original Message-----
From: liujian (CE)
Sent: Friday, September 16, 2022 3:05 PM
To: 'Jason Wang' <[email protected]>
Cc: davem <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Alexei Starovoitov <[email protected]>; Daniel Borkmann <[email protected]>; Jesper Dangaard Brouer <[email protected]>; John Fastabend <[email protected]>; netdev <[email protected]>
Subject: RE: [PATCH net v2] tun: Check tun device queue status intun_chr_write_iterQuoted 5 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Friday, September 16, 2022 9:57 AM
To: liujian (CE) <[email protected]>
Cc: davem <[email protected]>; Eric Dumazet
Quoted 75 lines
Quoted 3 lines
Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Alexei Starovoitov <[email protected]>; Daniel Borkmann <[email protected]>; Jesper Dangaard Brouer <[email protected]>;
John
Quoted 1 line
Fastabend <[email protected]>; netdev
Quoted 68 lines
Subject: Re: [PATCH net v2] tun: Check tun device queue status in
tun_chr_write_iterQuoted 9 lines · Liu Jian
syzbot found below warning:
------------[ cut here ]------------ geneve0 received packet on queue 3, but number of RX queues is 3 WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_get_rxqueue net/core/dev.c:4611 [inline] WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 Moduleslinked in:
Quoted 53 lines
CPU: 1 PID: 29734 Comm: syz-executor.0 Not tainted 5.10.0 #5 Hardware name: linux,dummy-virt (DT) pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--) pc : netif_get_rxqueue net/core/dev.c:4611 [inline] pc : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 lr : netif_get_rxqueue net/core/dev.c:4611 [inline] lr : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 sp :
ffffa00016127770
x29:ffffa00016127770x28:ffff3f4607d6acb4
x27:ffff3f4607d6acb0x26:ffff3f4607d6ad20
x25:ffff3f461de3c000x24:ffff3f4607d6ad28
x23:ffffa00010059000x22:ffff3f4608719100
x21: 0000000000000003 x20:ffffa000161278a0
x19:ffff3f4607d6ac40x18: 0000000000000000
x17: 0000000000000000 x16:00000000f2f2f204
x15:00000000f2f20000x14: 6465766965636572
x13:20306576656e6567x12:ffff98b8ed3b924d
x11:1ffff8b8ed3b924cx10:ffff98b8ed3b924c
x9 :ffffc5c76525c9c4x8 : 0000000000000000
x7 : 0000000000000001 x6 :ffff98b8ed3b924c
x5 :ffff3f460f3b29c0x4 :dfffa00000000000
x3 :ffffc5c765000000x2 : 0000000000000000
x1 : 0000000000000000 x0 :ffff3f460f3b29c0Call trace:netif_get_rxqueue net/core/dev.c:4611 [inline] netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 do_xdp_generic net/core/dev.c:4777 [inline] do_xdp_generic+0x9c/0x190 net/core/dev.c:4770 tun_get_user+0xd94/0x2010 drivers/net/tun.c:1938 tun_chr_write_iter+0x98/0x100 drivers/net/tun.c:2036 call_write_iter include/linux/fs.h:1960 [inline] new_sync_write+0x260/0x370 fs/read_write.c:515 vfs_write+0x51c/0x61c
fs/read_write.c:602
ksys_write+0xfc/0x200fs/read_write.c:655__do_sys_writefs/read_write.c:667[inline]__se_sys_writefs/read_write.c:664[inline]
__arm64_sys_write+0x50/0x60fs/read_write.c:664__invoke_syscallarch/arm64/kernel/syscall.c:36[inline]invoke_syscallarch/arm64/kernel/syscall.c:48[inline]el0_svc_common.constprop.0+0xf4/0x414 arch/arm64/kernel/syscall.c:155 do_el0_svc+0x50/0x11c arch/arm64/kernel/syscall.c:217 el0_svc+0x20/0x30 arch/arm64/kernel/entry-common.c:353 el0_sync_handler+0xe4/0x1e0 arch/arm64/kernel/entry-common.c:369 el0_sync+0x148/0x180 arch/arm64/kernel/entry.S:683This is because the detached queue is used to send data. Therefore, we need to check the queue status in the
tun_chr_write_iterfunction.Fixes cde8b15f1aab ("tuntap: add ioctl to attach or detach a fileform tuntap device")
Hello,
Sorry, fixes tag is wrong. The warning should be introduced by commit 3fe260e00cd0 (" net: tun: record RX queue in skb before do_xdp_generic() "). Before this, do_xdp_generic always uses queue0. Therefore, when the warning is generated due to detached, queue0 is used and is printed only once, which is harmless. So it's not a problem. What do you think about this warning?
Quoted 44 lines
Quoted 20 lines
Not sure this deserves a stable.
Quoted 11 lines
Signed-off-by Liu Jian <[email protected]>---
v1->v2: add fixes tagdrivers/net/tun.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/tun.c index renamed from drivers/net/tun.c +0
-0
259b2b84b2b3..261411c1a6bb100644drivers/net/tun.c +0
-0@@ -2019,6 +2019,11 @@ static ssize_t tun_chr_write_iter(structQuoted 1 line
kiocb
*iocb, struct
iov_iter*from)Quoted 4 lines
if (!tun) return -EBADFD;+ if (
tfile->detached) {Quoted 9 lines
tfile->detachedis synchronized throughrtnl_lockwhich is probably not suitable for the datapath. We probably need to rcuify this.drivers/net/tun.c static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 2024
Quoted 2 lines
drivers/net/tun.c +2
-0+tun_put (tun); +return -ENETDOWN ;Another question is that can some user space depend on this behaviour? I wonder if it's more safe to pretend the packet was received here?
Thanks for your review. I don't know whether there was any depend on this behavior.
If that's the case, I think it's better to keep this warning. What is your opinion on this warning?Quoted 10 lines
Thanks
Quoted 8 lines
drivers/net/tun.c +2
-1+ } +if ((file->f_flags &O_NONBLOCK ) || (iocb->ki_flags &IOCB_NOWAIT )) noblock =1 ; --2.17.1
Quoted 95 lines · liujian (CE)
Quoted 95 lines
-----Original Message-----
From: liujian (CE)
Sent: Friday, September 16, 2022 3:05 PM
To: 'Jason Wang' <[email protected]>
Cc: davem <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Alexei Starovoitov <[email protected]>; Daniel Borkmann <[email protected]>; Jesper Dangaard Brouer <[email protected]>; John Fastabend <[email protected]>; netdev <[email protected]>
Subject: RE: [PATCH net v2] tun: Check tun device queue status intun_chr_write_iterQuoted 5 lines
-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Friday, September 16, 2022 9:57 AM
To: liujian (CE) <[email protected]>
Cc: davem <[email protected]>; Eric DumazetQuoted 3 lines
Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Alexei Starovoitov <[email protected]>; Daniel Borkmann <[email protected]>; Jesper Dangaard Brouer <[email protected]>;
John
Quoted 1 line
Fastabend <[email protected]>; netdev
Quoted 65 lines
Subject: Re: [PATCH net v2] tun: Check tun device queue status in
tun_chr_write_iterQuoted 9 lines · Liu Jian
syzbot found below warning:
------------[ cut here ]------------ geneve0 received packet on queue 3, but number of RX queues is 3 WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_get_rxqueue net/core/dev.c:4611 [inline] WARNING: CPU: 1 PID: 29734 at net/core/dev.c:4611 netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 Moduleslinked in:
Quoted 51 lines
CPU: 1 PID: 29734 Comm: syz-executor.0 Not tainted 5.10.0 #5 Hardware name: linux,dummy-virt (DT) pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--) pc : netif_get_rxqueue net/core/dev.c:4611 [inline] pc : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 lr : netif_get_rxqueue net/core/dev.c:4611 [inline] lr : netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 sp :
ffffa00016127770
x29:ffffa00016127770x28:ffff3f4607d6acb4
x27:ffff3f4607d6acb0x26:ffff3f4607d6ad20
x25:ffff3f461de3c000x24:ffff3f4607d6ad28
x23:ffffa00010059000x22:ffff3f4608719100
x21: 0000000000000003 x20:ffffa000161278a0
x19:ffff3f4607d6ac40x18: 0000000000000000
x17: 0000000000000000 x16:00000000f2f2f204
x15:00000000f2f20000x14: 6465766965636572
x13:20306576656e6567x12:ffff98b8ed3b924d
x11:1ffff8b8ed3b924cx10:ffff98b8ed3b924c
x9 :ffffc5c76525c9c4x8 : 0000000000000000
x7 : 0000000000000001 x6 :ffff98b8ed3b924c
x5 :ffff3f460f3b29c0x4 :dfffa00000000000
x3 :ffffc5c765000000x2 : 0000000000000000
x1 : 0000000000000000 x0 :ffff3f460f3b29c0Call trace:netif_get_rxqueue net/core/dev.c:4611 [inline] netif_receive_generic_xdp+0xb10/0xb50 net/core/dev.c:4683 do_xdp_generic net/core/dev.c:4777 [inline] do_xdp_generic+0x9c/0x190 net/core/dev.c:4770 tun_get_user+0xd94/0x2010 drivers/net/tun.c:1938 tun_chr_write_iter+0x98/0x100 drivers/net/tun.c:2036 call_write_iter include/linux/fs.h:1960 [inline] new_sync_write+0x260/0x370 fs/read_write.c:515 vfs_write+0x51c/0x61c
fs/read_write.c:602
ksys_write+0xfc/0x200fs/read_write.c:655__do_sys_writefs/read_write.c:667[inline]__se_sys_writefs/read_write.c:664[inline]
__arm64_sys_write+0x50/0x60fs/read_write.c:664__invoke_syscallarch/arm64/kernel/syscall.c:36[inline]invoke_syscallarch/arm64/kernel/syscall.c:48[inline]el0_svc_common.constprop.0+0xf4/0x414 arch/arm64/kernel/syscall.c:155 do_el0_svc+0x50/0x11c arch/arm64/kernel/syscall.c:217 el0_svc+0x20/0x30 arch/arm64/kernel/entry-common.c:353 el0_sync_handler+0xe4/0x1e0 arch/arm64/kernel/entry-common.c:369 el0_sync+0x148/0x180 arch/arm64/kernel/entry.S:683This is because the detached queue is used to send data. Therefore, we need to check the queue status in the
tun_chr_write_iterfunction.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Fixes cde8b15f1aab ("tuntap: add ioctl to attach or detach a fileform tuntap device")
Hello,
Sorry, fixes tag is wrong. The warning should be introduced by commit3fe260e00cd0(" net: tun: record RX queue in skb beforedo_xdp_generic()"). Before this,do_xdp_genericalways uses queue0. Therefore, when the warning is generated due to detached, queue0 is used and is printed only once, which is harmless. So it's not a problem. What do you think about this warning?
I tend to keep this warning (it might be too late to fix).
Thanks
Quoted 46 lines
Quoted 45 lines
Quoted 21 lines
Not sure this deserves a stable.
Quoted 11 lines
Signed-off-by Liu Jian <[email protected]>---
v1->v2: add fixes tagdrivers/net/tun.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/tun.c index renamed from drivers/net/tun.c +0
-0
259b2b84b2b3..261411c1a6bb100644drivers/net/tun.c +0
-0@@ -2019,6 +2019,11 @@ static ssize_t tun_chr_write_iter(structQuoted 1 line
kiocb
*iocb, struct
iov_iter*from)Quoted 4 lines
if (!tun) return -EBADFD;+ if (
tfile->detached) {Quoted 9 lines
tfile->detachedis synchronized throughrtnl_lockwhich is probably not suitable for the datapath. We probably need to rcuify this.drivers/net/tun.c static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from) · line 2024
Quoted 2 lines
drivers/net/tun.c +2
-0+tun_put (tun); +return -ENETDOWN ;Another question is that can some user space depend on this behaviour? I wonder if it's more safe to pretend the packet was received here?
Thanks for your review. I don't know whether there was any depend on this behavior.
If that's the case, I think it's better to keep this warning. What is your opinion on this warning?Quoted 10 lines
Thanks
Quoted 8 lines
drivers/net/tun.c +2
-1+ } +if ((file->f_flags &O_NONBLOCK ) || (iocb->ki_flags &IOCB_NOWAIT )) noblock =1 ; --2.17.1