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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1418786123.6058.1@smtp.corp.redhat.com>
Date:	Wed, 17 Dec 2014 03:23:23 +0008
From:	Jason Wang <jasowang@...hat.com>
To:	"Michael S. Tsirkin" <mst@...hat.com>
Cc:	linux-kernel@...r.kernel.org, David Miller <davem@...emloft.net>,
	netdev@...r.kernel.org, Dan Carpenter <dan.carpenter@...cle.com>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	Tom Herbert <therbert@...gle.com>,
	Ben Hutchings <ben@...adent.org.uk>, Xi Wang <xii@...gle.com>,
	Masatake YAMATO <yamato@...hat.com>
Subject: Re: [PATCH 3/5] tun: drop broken IFF_VNET_LE



On Tue, Dec 16, 2014 at 9:05 PM, Michael S. Tsirkin <mst@...hat.com> 
wrote:
> Use TUNSETVNETLE/TUNGETVNETLE instead.
> 
> Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
> ---
>  drivers/net/tun.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index c052bd6b..e3e8a0e 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -109,9 +109,11 @@ do {								\
>   * overload it to mean fasync when stored there.
>   */
>  #define TUN_FASYNC	IFF_ATTACH_QUEUE
> +/* High bits in flags field are unused. */
> +#define TUN_VNET_LE     0x80000000
>  
>  #define TUN_FEATURES (IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR | \
> -		      IFF_VNET_LE | IFF_MULTI_QUEUE)
> +		      IFF_MULTI_QUEUE)
>  #define GOODCOPY_LEN 128
>  
>  #define FLT_EXACT_COUNT 8
> @@ -207,12 +209,12 @@ struct tun_struct {
>  
>  static inline u16 tun16_to_cpu(struct tun_struct *tun, __virtio16 
> val)
>  {
> -	return __virtio16_to_cpu(tun->flags & IFF_VNET_LE, val);
> +	return __virtio16_to_cpu(tun->flags & TUN_VNET_LE, val);
>  }
>  
>  static inline __virtio16 cpu_to_tun16(struct tun_struct *tun, u16 
> val)
>  {
> -	return __cpu_to_virtio16(tun->flags & IFF_VNET_LE, val);
> +	return __cpu_to_virtio16(tun->flags & TUN_VNET_LE, val);
>  }
>  
>  static inline u32 tun_hashfn(u32 rxhash)
> @@ -1853,6 +1855,7 @@ static long __tun_chr_ioctl(struct file *file, 
> unsigned int cmd,
>  	int sndbuf;
>  	int vnet_hdr_sz;
>  	unsigned int ifindex;
> +	int le;
>  	int ret;
>  
>  	if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 
> 0x89) {
> @@ -2052,6 +2055,23 @@ static long __tun_chr_ioctl(struct file *file, 
> unsigned int cmd,
>  		tun->vnet_hdr_sz = vnet_hdr_sz;
>  		break;
>  
> +	case TUNGETVNETLE:
> +		le = !!(tun->flags & TUN_VNET_LE);
> +		if (put_user(le, (int __user *)argp))
> +			ret = -EFAULT;
> +		break;
> +
> +	case TUNSETVNETLE:
> +		if (get_user(le, (int __user *)argp)) {
> +			ret = -EFAULT;
> +			break;
> +		}
> +		if (le)
> +			tun->flags |= TUN_VNET_LE;
> +		else
> +			tun->flags &= ~TUN_VNET_LE;
> +		break;
> +

A little bit different from persistent devices:

- TUNSETPERSIST check argp instead
- Userspace may check persist flags through TUNGETIFF

Probably this patch may needs more modifications on userspace.
> 
>  	case TUNATTACHFILTER:
>  		/* Can be set only for TAPs */
>  		ret = -EINVAL;
> -- 
> MST
> 
> --
> 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/

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ