Bug 303536 - [PATCH] ioctl for SIOCETHTOOL (ethtool(8)) isn't wrapped
Summary: [PATCH] ioctl for SIOCETHTOOL (ethtool(8)) isn't wrapped
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.7 SVN
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-15 05:40 UTC by nick black
Modified: 2014-06-27 10:00 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch, believed to be correct but incomplet (2.11 KB, patch)
2012-07-15 05:48 UTC, nick black
Details

Note You need to log in before you can comment on or make changes to this bug.
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.