lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 08 Oct 2013 10:50:23 +0800
From:	Jason Wang <jasowang@...hat.com>
To:	"Michael S. Tsirkin" <mst@...hat.com>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
CC:	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Pavel Emelyanov <xemul@...allels.com>
Subject: Re: [PATCH] tun: don't look at current when non-blocking

On 10/07/2013 02:25 AM, Michael S. Tsirkin wrote:
> We play with a wait queue even if socket is
> non blocking. This is an obvious waste.
> Besides, it will prevent calling the non blocking
> variant when current is not valid.
>
> Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
> ---

Acked-by: Jason Wang <jasowang@...hat.com>
>  drivers/net/tun.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 807815f..7cb105c 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1293,7 +1293,8 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
>  	if (unlikely(!noblock))
>  		add_wait_queue(&tfile->wq.wait, &wait);
>  	while (len) {
> -		current->state = TASK_INTERRUPTIBLE;
> +		if (unlikely(!noblock))
> +			current->state = TASK_INTERRUPTIBLE;
>  
>  		/* Read frames from the queue */
>  		if (!(skb = skb_dequeue(&tfile->socket.sk->sk_receive_queue))) {
> @@ -1320,9 +1321,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
>  		break;
>  	}
>  
> -	current->state = TASK_RUNNING;
> -	if (unlikely(!noblock))
> +	if (unlikely(!noblock)) {
> +		current->state = TASK_RUNNING;
>  		remove_wait_queue(&tfile->wq.wait, &wait);
> +	}
>  
>  	return ret;
>  }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists