Ultralinux archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lennert Buytenhek <buytenh@gnu.org>
To: ultralinux@vger.kernel.org
Subject: Re: [buytenh@gnu.org: [cry for advice] sparc64 bridging troubles]
Date: Wed, 16 Jan 2002 17:46:46 +0000	[thread overview]
Message-ID: <marc-linux-ultrasparc-101120329132208@msgid-missing> (raw)
In-Reply-To: <marc-linux-ultrasparc-101068859405697@msgid-missing>


On Fri, Jan 11, 2002 at 12:15:54AM -0800, David S. Miller wrote:

>    This copy_from_user invocation hangs the box solid, every single time.  The
>    arguments it's called with are fffff8001395f910, 00000000effff9f8, 32.  I
>    would think these look OK (and even if they wouldn't I guess they shouldn't
>    hang the box).
> 
> If set_fs(KERNEL_DS) this will hang the box because that means that
> both pointers need to be kernel points.

Whoops, missed that! (I knew it, but didn't realise this could mess
things up)


> The real solution is to move away from SIOCDEVPRIVATE since those
> are deprecated anyways, but you appear to understand this already.
> :-)

Yup.  The attached patch (plus some userspace changes) is what makes
things tick again, but it's not exactly a marvel of beauty.. :(


Thanks a lot!
Lennert


--- linux-2.4.17-br-sparc64/net/bridge/br_device.c.orig	Wed Jan 16 12:36:28 2002
+++ linux-2.4.17-br-sparc64/net/bridge/br_device.c	Wed Jan 16 12:40:22 2002
@@ -23,15 +23,26 @@
 {
 	unsigned long args[4];
 	unsigned long *data;
+	mm_segment_t oldfs = get_fs();
+	int ret;
+	int retval;
 
-	if (cmd != SIOCDEVPRIVATE)
+	if (cmd != SIOCDEVPRIVATE && cmd != SIOCDEVPRIVATE + 3)
 		return -EOPNOTSUPP;
 
 	data = (unsigned long *)rq->ifr_data;
-	if (copy_from_user(args, data, 4*sizeof(unsigned long)))
-		return -EFAULT;
+	set_fs(USER_DS);
+	ret = copy_from_user(args, data, 4*sizeof(unsigned long));
 
-	return br_ioctl(dev->priv, args[0], args[1], args[2], args[3]);
+	retval = -EFAULT;
+	if (ret)
+		goto out;
+
+	retval = br_ioctl(dev->priv, args[0], args[1], args[2], args[3]);
+
+out:
+	set_fs(oldfs);
+	return retval;
 }
 
 static struct net_device_stats *br_dev_get_stats(struct net_device *dev)
--- linux-2.4.17-br-sparc64/arch/sparc64/kernel/ioctl32.c.orig	Wed Jan 16 12:36:05 2002
+++ linux-2.4.17-br-sparc64/arch/sparc64/kernel/ioctl32.c	Wed Jan 16 12:38:07 2002
@@ -472,6 +472,7 @@
 		return -ENODEV;
 
 	strcpy(ifr32.ifr_name, dev->name);
+	dev_put(dev);
 
 	err = copy_to_user((struct ifreq32 *)arg, &ifr32, sizeof(struct ifreq32));
 	return (err ? -EFAULT : 0);
@@ -4605,6 +4606,7 @@
 HANDLE_IOCTL(SIOCGPPPSTATS, dev_ifsioc)
 HANDLE_IOCTL(SIOCGPPPCSTATS, dev_ifsioc)
 HANDLE_IOCTL(SIOCGPPPVER, dev_ifsioc)
+HANDLE_IOCTL(SIOCDEVPRIVATE + 3, dev_ifsioc)
 HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc)
 HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc)
 HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl)

  parent reply	other threads:[~2002-01-16 17:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-10 18:49 [buytenh@gnu.org: [cry for advice] sparc64 bridging troubles] Lennert Buytenhek
2002-01-11  8:15 ` David S. Miller
2002-01-16 17:46 ` Lennert Buytenhek [this message]
2002-01-16 17:54 ` David S. Miller
2002-01-16 17:57 ` Lennert Buytenhek

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=marc-linux-ultrasparc-101120329132208@msgid-missing \
    --to=buytenh@gnu.org \
    --cc=ultralinux@vger.kernel.org \
    /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