From: "Patrick R. McManus" <mcmanus@ducksong.com>
To: netdev@oss.sgi.com
Subject: SIOCETHTOOL ioctl() and a corrupted cmd argument
Date: Wed, 5 Mar 2003 16:00:48 -0500 [thread overview]
Message-ID: <20030305210047.GA10824@ducksong.com> (raw)
Hello,
this is odd.
My problem is with the cmd argument to a driver's ioctl() handler
getting modified when the caller is non root.
I have a 2.4.19era kernel and am running the e1000 driver, as a
module, from the 2.4.20 kernel. (drivers previous to 4.4.12 tended to
keep resetting themselves on me.)
my userspace code make a call that looks like this
struct ethtool_cmd ec;
int fd;
int rv = -1;
memset (&ifr,0,sizeof(ifr));
strncpy (ifr.ifr_name, getName(),IFNAMSIZ);
fd = socket (PF_INET,SOCK_DGRAM,0);
ifr.ifr_data = (char *) &ec;
ec.cmd = ETHTOOL_GSET;
fprintf (stderr,"SIOCETHTOOL is %X\n",SIOCETHTOOL);
if (ioctl(fd, SIOCETHTOOL, &ifr) >=0)
stderr always prints: SIOCETHTOOL is 8946
when I run the userspace code as root the ioctl succeeds, when I run
it as an unpriv'd user it fails.
So I annotated the driver by adding to e1000_ioctl:
printk(KERN_INFO "general ioctl cmd %X, magic %X\n",cmd,SIOCETHTOOL);
as root I get the expected
Mar 5 15:53:33 mcmanus kernel: general ioctl cmd 8946, magic 8946
as a regular user I get
Mar 5 15:46:57 mcmanus kernel: general ioctl cmd 89F0, magic 8946
can someone help me with the chain to look at for why the cmd value
might be getting modified?
-Patrick
next reply other threads:[~2003-03-05 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-05 21:00 Patrick R. McManus [this message]
2003-03-05 21:32 ` SIOCETHTOOL ioctl() and a corrupted cmd argument Patrick R. McManus
2003-03-05 21:41 ` Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030305210047.GA10824@ducksong.com \
--to=mcmanus@ducksong.com \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).