Bug 303536

Summary: [PATCH] ioctl for SIOCETHTOOL (ethtool(8)) isn't wrapped
Product: [Developer tools] valgrind Reporter: nick black <nick.black>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: gharris, mark, nick.black, tom
Priority: NOR    
Version: 3.7 SVN   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: patch, believed to be correct but incomplet

Description nick black 2012-07-15 05:40:29 UTC
Howdy. Here's another ioctl wrapper, this one for linux's SIOCETHTOOL. It's not complete, due to the complexity of SIOCETHTOOL, but it's a start. Applies to 3.8.0 SVN. Thanks!

Reproducible: Always

Steps to Reproduce:
1.Run program using SIOCETHTOOL (ox8946)
2.Observe warning.
3.
Actual Results:  
==3814== 
==3814== Warning: noted but unhandled ioctl 0x8946 with no size/direction hints
==3814==    This could cause spurious value errors to appear.
==3814==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.


Expected Results:  
Handling of SIOCETHTOOL.

[skynet](0) $ svn diff
Index: include/vki/vki-linux.h
===================================================================
--- include/vki/vki-linux.h	(revision 12749)
+++ include/vki/vki-linux.h	(working copy)
@@ -1607,6 +1607,7 @@
 #define VKI_SIOCGIFTXQLEN	0x8942	/* Get the tx queue length	*/
 #define VKI_SIOCSIFTXQLEN	0x8943	/* Set the tx queue length 	*/
 
+#define VKI_SIOCETHTOOL         0x8946  /* Ethtool(8) interface         */
 #define VKI_SIOCGMIIPHY		0x8947	/* Get address of MII PHY in use. */
 #define VKI_SIOCGMIIREG		0x8948	/* Read MII PHY register.	*/
 #define VKI_SIOCSMIIREG		0x8949	/* Write MII PHY register.	*/
Index: coregrind/m_syswrap/syswrap-linux.c
===================================================================
--- coregrind/m_syswrap/syswrap-linux.c	(revision 12749)
+++ coregrind/m_syswrap/syswrap-linux.c	(working copy)
@@ -4423,6 +4423,10 @@
                      sizeof(((struct vki_ifreq *)ARG3)->vki_ifr_ifindex) );
       PRE_MEM_WRITE( "ioctl(SIOCGIFNAME)", ARG3, sizeof(struct vki_ifreq));
       break;
+   case VKI_SIOCETHTOOL:         /* ethtool(8) interface         */
+      PRE_MEM_RASCIIZ( "ioctl(SIOCETHTOOL)",
+                     (Addr)((struct vki_ifreq *)ARG3)->vki_ifr_name );
+      break;
    case VKI_SIOCGMIIPHY:         /* get hardware entry           */
       PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMIIPHY)",
                      (Addr)((struct vki_ifreq *)ARG3)->vki_ifr_name );
@@ -5738,6 +5742,13 @@
                 (Addr)&((struct vki_ifreq *)ARG3)->vki_ifr_name,
                 sizeof(((struct vki_ifreq *)ARG3)->vki_ifr_name) );
       break;
+   case VKI_SIOCETHTOOL:         /* ethtool(8) interface         */
+      /* FIXME there's no way the size here is generally correct; it's
+         interpreted based off the command sent via SIOCETHTOOL */
+      POST_MEM_WRITE(
+                (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)ARG3)->vki_ifr_data),
+                sizeof(((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)ARG3)->vki_ifr_data)) );
+      break;
    case VKI_SIOCGMIIPHY:         /* get hardware entry           */
       POST_MEM_WRITE(
                 (Addr)&((struct vki_mii_ioctl_data *)&((struct vki_ifreq *)ARG3)->vki_ifr_data)->phy_id,
[skynet](0) $ 

[skynet](0) $ svn info
Path: .
Working Copy Root Path: /home/dank/valgrind
URL: svn://svn.valgrind.org/valgrind/trunk
Repository Root: svn://svn.valgrind.org/valgrind
Repository UUID: a5019735-40e9-0310-863c-91ae7b9d1cf9
Revision: 12749
Node Kind: directory
Schedule: normal
Last Changed Author: florian
Last Changed Rev: 12749
Last Changed Date: 2012-07-14 21:31:45 -0400 (Sat, 14 Jul 2012)

[skynet](0) $
Comment 1 nick black 2012-07-15 05:48:31 UTC
Created attachment 72530 [details]
patch, believed to be correct but incomplet

This invalidates the patch I provided inline in my initial report (which doesn't even compile).
Comment 2 Tom Hughes 2014-06-27 10:00:43 UTC
I've committed support for a wide range of SIOCETHOOL operations as r14114. There are a few things missing, either because they are pretty much impossible to do right or because they were hard to test as my ethernet card didn't support them.