From: Jason Wang <hidden> Date: 2016-05-18 10:58:25
We used to check dev->reg_state against NETREG_REGISTERED after each
time we are woke up. But after commit 9e641bdcfa4e ("net-tun:
restructure tun_do_read for better sleep/wakeup efficiency"), it uses
skb_recv_datagram() which does not check dev->reg_state. This will
result if we delete a tun/tap device after a process is blocked in the
reading. The device will wait for the reference count which was held
by that process for ever.
Fixes this by using RCV_SHUTDOWN which will be checked during
sk_recv_datagram() before trying to wake up the process during uninit.
Fixes: 9e641bdcfa4e ("net-tun: restructure tun_do_read for better
sleep/wakeup efficiency")
Cc: Eric Dumazet <edumazet@google.com>
Cc: Xi Wang <redacted>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <redacted>
---
The patch is needed for -stable.
---
drivers/net/tun.c | 3 +++
1 file changed, 3 insertions(+)
From: "Michael S. Tsirkin" <mst@redhat.com> Date: 2016-05-18 12:41:18
On Wed, May 18, 2016 at 06:58:17PM +0800, Jason Wang wrote:
We used to check dev->reg_state against NETREG_REGISTERED after each
time we are woke up. But after commit 9e641bdcfa4e ("net-tun:
restructure tun_do_read for better sleep/wakeup efficiency"), it uses
skb_recv_datagram() which does not check dev->reg_state. This will
result if we delete a tun/tap device after a process is blocked in the
reading. The device will wait for the reference count which was held
by that process for ever.
Fixes this by using RCV_SHUTDOWN which will be checked during
sk_recv_datagram() before trying to wake up the process during uninit.
Fixes: 9e641bdcfa4e ("net-tun: restructure tun_do_read for better
sleep/wakeup efficiency")
Cc: Eric Dumazet <edumazet@google.com>
Cc: Xi Wang <redacted>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <redacted>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
quoted hunk
---
The patch is needed for -stable.
---
drivers/net/tun.c | 3 +++
1 file changed, 3 insertions(+)
By the way I wonder: at the moment interface goes down
each time userspace disconnects, even if it was persistent
and brought up manually (as opposed to on file open).
Should we maybe track manual link up status and keep
persistent device up on userspace disconnect?
From: Eric Dumazet <hidden> Date: 2016-05-18 13:01:39
On Wed, 2016-05-18 at 18:58 +0800, Jason Wang wrote:
We used to check dev->reg_state against NETREG_REGISTERED after each
time we are woke up. But after commit 9e641bdcfa4e ("net-tun:
restructure tun_do_read for better sleep/wakeup efficiency"), it uses
skb_recv_datagram() which does not check dev->reg_state. This will
result if we delete a tun/tap device after a process is blocked in the
reading. The device will wait for the reference count which was held
by that process for ever.
Fixes this by using RCV_SHUTDOWN which will be checked during
sk_recv_datagram() before trying to wake up the process during uninit.
Fixes: 9e641bdcfa4e ("net-tun: restructure tun_do_read for better
sleep/wakeup efficiency")
<nit : no newline before Fixes: and other parts>
quoted hunk
Cc: Eric Dumazet <edumazet@google.com>
Cc: Xi Wang <redacted>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <redacted>
---
The patch is needed for -stable.
---
drivers/net/tun.c | 3 +++
1 file changed, 3 insertions(+)
From: Jason Wang <hidden> Date: 2016-05-19 05:35:12
On 2016年05月18日 21:01, Eric Dumazet wrote:
On Wed, 2016-05-18 at 18:58 +0800, Jason Wang wrote:
quoted
We used to check dev->reg_state against NETREG_REGISTERED after each
time we are woke up. But after commit 9e641bdcfa4e ("net-tun:
restructure tun_do_read for better sleep/wakeup efficiency"), it uses
skb_recv_datagram() which does not check dev->reg_state. This will
result if we delete a tun/tap device after a process is blocked in the
reading. The device will wait for the reference count which was held
by that process for ever.
Fixes this by using RCV_SHUTDOWN which will be checked during
sk_recv_datagram() before trying to wake up the process during uninit.
Fixes: 9e641bdcfa4e ("net-tun: restructure tun_do_read for better
sleep/wakeup efficiency")
<nit : no newline before Fixes: and other parts>
Ok.
quoted hunk
Cc: Eric Dumazet <edumazet@google.com>
Cc: Xi Wang <redacted>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <redacted>
---
The patch is needed for -stable.
---
drivers/net/tun.c | 3 +++
1 file changed, 3 insertions(+)