ethtool: Compat handling for struct ethtool_rxnfc
Subsystems (4)
PATCH 1/1 ethtool: Compat handling for struct ethtool_rxnfc
This structure was accidentally defined such that its layout can differ between 32-bit and 64-bit processes. Add compat structure definitions and an ioctl wrapper function.
---
David,
I still haven't received any response on whether the ETHTOOL_GRXCLSRLALL wrapping works with a real driver, but perhaps you could test it against niu? I think sparc32 and sparc64 have the same alignment for u64 so this wrapper isn't strictly necessary, but it would still be used. (Or we can arrange to disable the conversion when compat_ethtool_rxnfc is equivalent to ethtool_rxnfc.)
Ben.
include/linux/ethtool.h | 34 ++++++++++++++ net/socket.c | 114 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 141 insertions(+), 7 deletions(-)
include/linux/ethtool.h +34 -0
@@ -13,6 +13,9 @@#ifndef _LINUX_ETHTOOL_H#define _LINUX_ETHTOOL_H +#ifdef __KERNEL__ +#include <linux/compat.h> +#endif #include <linux/types.h> #include <linux/if_ether.h>
@@ -450,6 +453,37 @@ struct ethtool_rxnfc {__u32 rule_locs[0 ]; }; +#ifdef __KERNEL__ +#ifdef CONFIG_COMPAT + +struct compat_ethtool_rx_flow_spec { +u32 flow_type; +union { +struct ethtool_tcpip4_spec tcp_ip4_spec; +struct ethtool_tcpip4_spec udp_ip4_spec; +struct ethtool_tcpip4_spec sctp_ip4_spec; +struct ethtool_ah_espip4_spec ah_ip4_spec; +struct ethtool_ah_espip4_spec esp_ip4_spec; +struct ethtool_usrip4_spec usr_ip4_spec; +struct ethhdr ether_spec; +u8 hdata[72 ]; + } h_u, m_u; +compat_u64 ring_cookie; +u32 location; +}; + +struct compat_ethtool_rxnfc { +u32 cmd; +u32 flow_type; +compat_u64 data; +struct compat_ethtool_rx_flow_spec fs; +u32 rule_cnt; +u32 rule_locs[0 ]; +}; + +#endif /* CONFIG_COMPAT */ +#endif /* __KERNEL__ */ +/** * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
net/socket.c +107 -7
130 lines not on this page · raw message
Signature · 7 lines
1.7.4 -- Ben Hutchings, Senior Software Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 9 lines · Ben Hutchings
This structure was accidentally defined such that its layout can differ between 32-bit and 64-bit processes. Add compat structure definitions and an ioctl wrapper function.
Signed-off-by Ben Hutchings<[email protected]>Cc [email protected] [2.6.30+]---
David,
Quoted 8 lines
I still haven't received any response on whether the
ETHTOOL_GRXCLSRLALLwrapping works with a real driver, but perhaps you could test it against niu? I think sparc32 and sparc64 have the same alignment for u64 so this wrapper isn't strictly necessary, but it would still be used. (Or we can arrange to disable the conversion whencompat_ethtool_rxnfcis equivalent toethtool_rxnfc.)Ben.
I'll try to pull this into my current development tree and test it while working on the next set of RFC patches for ixgbe w/ updated flow director. I probably won't have it done until the middle of next week though.
Thanks,
Alex
Quoted 9 lines · Ben Hutchings
This structure was accidentally defined such that its layout can differ between 32-bit and 64-bit processes. Add compat structure definitions and an ioctl wrapper function.
Signed-off-by Ben Hutchings<[email protected]>Cc [email protected] [2.6.30+]---
David,
Quoted 8 lines
I still haven't received any response on whether the
ETHTOOL_GRXCLSRLALLwrapping works with a real driver, but perhaps you could test it against niu? I think sparc32 and sparc64 have the same alignment for u64 so this wrapper isn't strictly necessary, but it would still be used. (Or we can arrange to disable the conversion whencompat_ethtool_rxnfcis equivalent toethtool_rxnfc.)Ben.
I've done a bit of testing this morning and verified GRXRINGS, GRCLSRLCNT, GRXCLSRULE, SRXCLSRLDEL, and SRXCLSRLINS all seem to be working for 32bit and 64bit ethtool user space on a x86_64 kernel with the patch. I also verified the original issue was present by running 32bit ethtool on a x86_64 kernel without the patch applied.
In order to support flow extensions there will end up being a couple of minor changes needed to the patch but I will just make sure to add them when flow extensions are added.
Thanks,
Alex
From: Alexander Duyck <[email protected]>
Date: Fri, 18 Mar 2011 13:01:58 -0700
Quoted 27 lines · Ben Hutchings
Quoted 19 lines
This structure was accidentally defined such that its layout can differ between 32-bit and 64-bit processes. Add compat structure definitions and an ioctl wrapper function.
Signed-off-by Ben Hutchings<[email protected]>Cc [email protected] [2.6.30+]---
David,I still haven't received any response on whether the
ETHTOOL_GRXCLSRLALL
wrapping works with a real driver, but perhaps you could test it against
niu? I think sparc32 and sparc64 have the same alignment for u64 so this wrapper isn't strictly necessary, but it would still be used. (Or
we can arrange to disable the conversion whencompat_ethtool_rxnfcis equivalent toethtool_rxnfc.)Quoted 1 line
Ben.
I've done a bit of testing this morning and verified GRXRINGS, GRCLSRLCNT, GRXCLSRULE, SRXCLSRLDEL, and SRXCLSRLINS all seem to be working for 32bit and 64bit ethtool user space on a
x86_64kernel with the patch. I also verified the original issue was present by running 32bit ethtool on ax86_64kernel without the patch applied.
...
Quoted 1 line
Acked-by Alexander Duyck <[email protected]>
Applied, thanks.