linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Aloni <da-x@gmx.net>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>, Patrick Mochel <mochel@osdl.org>
Subject: [TRIVIAL] avoid Oops in net/core/dev.c
Date: Sat, 28 Jun 2003 11:38:10 +0300	[thread overview]
Message-ID: <20030628083810.GA2793@callisto.yi.org> (raw)

Linus, please apply.
Patrick, please read on.

This fixes the kernel crash in the case when we do an SIOCSIFNAME
ioctl on /proc/net/dev to rename a network interface, and
we supply a string such as "foo%sbar".

BTW, I've seen more places of this phenomenon, but they
are not with strings that come right from userspace like
this one.

BTW2, the attempt to rename the device here doesn't affect
sysfs. Patrick, we need a class_device_* interface that does 
this.

--- linux-2.5.73/net/core/dev.c	2003-06-27 10:46:59.000000000 +0300
+++ linux-2.5.73/net/core/dev.c	2003-06-28 10:10:39.000000000 +0300
@@ -2346,7 +2346,7 @@
 				return -EEXIST;
 			memcpy(dev->name, ifr->ifr_newname, IFNAMSIZ);
 			dev->name[IFNAMSIZ - 1] = 0;
-			snprintf(dev->class_dev.class_id, BUS_ID_SIZE, dev->name);
+			strlcpy(dev->class_dev.class_id, dev->name, BUS_ID_SIZE);
 			notifier_call_chain(&netdev_chain,
 					    NETDEV_CHANGENAME, dev);
 			return 0;



-- 
Dan Aloni
da-x@gmx.net

             reply	other threads:[~2003-06-28  8:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-28  8:38 Dan Aloni [this message]
2003-06-28 19:41 ` [TRIVIAL] avoid Oops in net/core/dev.c Greg KH
2003-06-28 20:07   ` Dan Aloni

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=20030628083810.GA2793@callisto.yi.org \
    --to=da-x@gmx.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    --cc=torvalds@transmeta.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).