net: make struct tun_struct private to tun.c
Subsystems (3)
PATCH 1/2 net: make struct tun_struct private to tun.c
There's no reason for this to be in the header, and it just hurts recompile time.
drivers/net/tun.c +33 -0
@@ -67,9 +67,42 @@#include <asm/system.h> #include <asm/uaccess.h> +/* Uncomment to enable debugging */ +/* #define TUN_DEBUG 1 */ +#ifdef TUN_DEBUG static int debug; + +#define DBG if(tun->debug)printk +#define DBG1 if(debug==2)printk +#else +#define DBG( a... ) +#define DBG1( a... )#endif + +struct tun_struct { +struct list_head list; +unsigned long flags; +int attached; +uid_t owner; +gid_t group; + +wait_queue_head_t read_wait; +struct sk_buff_head readq; + +struct net_device *dev; + +struct fasync_struct *fasync; + +unsigned long if_flags; +u8 dev_addr[ETH_ALEN ]; +u32 chr_filter[2 ]; +u32 net_filter[2 ]; + +#ifdef TUN_DEBUG +int debug; +#endif +};/* Network device part of the driver */
include/linux/Kbuild +1 -1
@@ -86,6 +86,7 @@ header-y += if_ppp.h header-y += if_ppp.h header-y += if_slip.h header-y += if_strip.h +header-y += if_tun.h header-y += if_tunnel.h header-y += in6.h header-y += in_route.h
@@ -229,7 +230,6 @@ unifdef-y += if_pppol2tp.h unifdef-y += if_pppol2tp.h unifdef-y += if_pppox.h unifdef-y += if_tr.h -unifdef-y += if_tun.h unifdef-y += if_vlan.h unifdef-y += if_wanpipe.h unifdef-y += igmp.h
include/linux/if_tun.h +0 -39
@@ -18,46 +18,7 @@#ifndef __IF_TUN_H#define __IF_TUN_H -/* Uncomment to enable debugging */ -/* #define TUN_DEBUG 1 */ -#include <linux/types.h> - -#ifdef __KERNEL__ - -#ifdef TUN_DEBUG -#define DBG if(tun->debug)printk -#define DBG1 if(debug==2)printk -#else -#define DBG( a... ) -#define DBG1( a... ) -#endif - -struct tun_struct { -struct list_head list; -unsigned long flags; -int attached; -uid_t owner; -gid_t group; - -wait_queue_head_t read_wait; -struct sk_buff_head readq; - -struct net_device *dev; - -struct fasync_struct *fasync; - -unsigned long if_flags; -u8 dev_addr[ETH_ALEN ]; -u32 chr_filter[2 ]; -u32 net_filter[2 ]; - -#ifdef TUN_DEBUG -int debug; -#endif -}; - -#endif /* __KERNEL__ */ /* Read queue size */ #define TUN_READQ_SIZE 500
PATCH 2/2 net: check for underlength tap writes
If the user gives a packet under 14 bytes, we'll end up reading off the end of the skb (not oopsing, just reading off the end).
drivers/net/tun.c +4 -1
@@ -286,8 +286,11 @@ static __inline__ ssize_t tun_get_user(sreturn -EFAULT ; } -if ((tun->flags &TUN_TYPE_MASK ) ==TUN_TAP_DEV ) +if ((tun->flags &TUN_TYPE_MASK ) ==TUN_TAP_DEV ) { align =NET_IP_ALIGN ; +if (unlikely (len <ETH_HLEN )) +return -EINVAL ; + }if (!(skb =alloc_skb (len + align,GFP_KERNEL ))) { tun->dev->stats.rx_dropped++;
Re: [PATCH 2/2] net: check for underlength tap writes
Ack. I've been meaning to fix this as well.
Dave, can please merge it.
Thanx
Max
Quoted 22 lines · Rusty Russell
If the user gives a packet under 14 bytes, we'll end up reading off the end of the skb (not oopsing, just reading off the end).
Signed-off-by Rusty Russell <[email protected]>diff -r
99132ad16999drivers/net/tun.cdrivers/net/tun.c +4
-1@@ -286,8 +286,11 @@ static __inline__ ssize_t tun_get_user(sreturn -EFAULT ; } -if ((tun->flags &TUN_TYPE_MASK ) ==TUN_TAP_DEV ) +if ((tun->flags &TUN_TYPE_MASK ) ==TUN_TAP_DEV ) { align =NET_IP_ALIGN ; +if (unlikely (len <ETH_HLEN )) +return -EINVAL ; + }if (!(skb =alloc_skb (len + align,GFP_KERNEL ))) { tun->dev->stats.rx_dropped++;
Re: [PATCH 2/2] net: check for underlength tap writes
From: Max Krasnyanskiy <[email protected]>
Date: Thu, 10 Apr 2008 11:19:38 -0700
Quoted 2 lines
Ack. I've been meaning to fix this as well.
Dave, can please merge it.
Applied, thanks.
Ack.
Dave, can you please take this patch.
Max
Quoted 125 lines · Rusty Russell
There's no reason for this to be in the header, and it just hurts recompile time.
Signed-off-by Rusty Russell <[email protected]>diff -r
f657af5295eedrivers/net/tun.cdrivers/net/tun.c +33
-0@@ -67,9 +67,42 @@#include <asm/system.h> #include <asm/uaccess.h> +/* Uncomment to enable debugging */ +/* #define TUN_DEBUG 1 */ +#ifdef TUN_DEBUG static int debug; + +#define DBG if(tun->debug)printk +#define DBG1 if(debug==2)printk +#else +#define DBG( a... ) +#define DBG1( a... )#endif + +struct tun_struct { +struct list_head list; +unsigned long flags; +int attached; +uid_t owner; +gid_t group; + +wait_queue_head_t read_wait; +struct sk_buff_head readq; + +struct net_device *dev; + +struct fasync_struct *fasync; + +unsigned long if_flags; +u8 dev_addr[ETH_ALEN ]; +u32 chr_filter[2 ]; +u32 net_filter[2 ]; + +#ifdef TUN_DEBUG +int debug; +#endif +};/* Network device part of the driver */ diff -r
f657af5295eeinclude/linux/Kbuildinclude/linux/Kbuild +1
-1@@ -86,6 +86,7 @@ header-y += if_ppp.h header-y += if_ppp.h header-y += if_slip.h header-y += if_strip.h +header-y += if_tun.h header-y += if_tunnel.h header-y += in6.h header-y += in_route.h@@ -229,7 +230,6 @@ unifdef-y += if_pppol2tp.h unifdef-y += if_pppol2tp.h unifdef-y += if_pppox.h unifdef-y += if_tr.h -unifdef-y += if_tun.h unifdef-y += if_vlan.h unifdef-y += if_wanpipe.h unifdef-y += igmp.hdiff -r
f657af5295eeinclude/linux/if_tun.hinclude/linux/if_tun.h +0
-40@@ -18,46 +18,7 @@#ifndef __IF_TUN_H#define __IF_TUN_H -/* Uncomment to enable debugging */ -/* #define TUN_DEBUG 1 */ -#include <linux/types.h> - -#ifdef __KERNEL__ - -#ifdef TUN_DEBUG -#define DBG if(tun->debug)printk -#define DBG1 if(debug==2)printk -#else -#define DBG( a... ) -#define DBG1( a... ) -#endif - -struct tun_struct { -struct list_head list; -unsigned long flags; -int attached; -uid_t owner; -gid_t group; - -wait_queue_head_t read_wait; -struct sk_buff_head readq; - -struct net_device *dev; - -struct fasync_struct *fasync; - -unsigned long if_flags; -u8 dev_addr[ETH_ALEN ]; -u32 chr_filter[2 ]; -u32 net_filter[2 ]; - -#ifdef TUN_DEBUG -int debug; -#endif -}; - -#endif /* __KERNEL__ */ /* Read queue size */ #define TUN_READQ_SIZE 500 --To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Max Krasnyanskiy <[email protected]>
Date: Thu, 10 Apr 2008 11:18:04 -0700
Quoted 2 lines
Ack.
Dave, can you please take this patch.
Applied.