mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: MAEDA Naoaki <maeda.naoaki@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] packet_sendmsg_spkt incorrectly truncates an interface name
Date: Mon, 9 Feb 2004 23:43:41 -0800	[thread overview]
Message-ID: <20040209234341.0075159b.akpm@osdl.org> (raw)
In-Reply-To: <20040210.163023.112606425.maeda@jp.fujitsu.com>

MAEDA Naoaki <maeda.naoaki@jp.fujitsu.com> wrote:
>
> Hi,
> 
> When I renamed a network interface name with long name such as heartbeat.eth1,
> DHCP client failed to assign an IP address to the interface. 
> 
> Problem is that packet_sendmsg_spkt() truncates an interface name 
> by 12 characters. That is why the following dev_get_by_name() fails to find
> the corresponding net_device structure.

You need to use a shorter name, I think.

> Obviously, max name length of a network interface name is IFNAMESIZ-1, 
> which is 15.

Yes, but sockaddr_pkt.spkt_device[] is only 14 bytes for some reason.

> I can not come up with any reasonable reason that
> packet_sendmsg_spkt() should truncate the interface name by 12.
> I guess it is just a trivial bug.

These objects are shared with userspace applications, I believe.  We're
stuck with it.


> diff -Naur linux-2.6.2.org/net/packet/af_packet.c linux-2.6.2/net/packet/af_packet.c
> --- linux-2.6.2.org/net/packet/af_packet.c	2004-02-10 15:29:14.160320269 +0900
> +++ linux-2.6.2/net/packet/af_packet.c	2004-02-10 15:29:52.656413548 +0900
> @@ -311,7 +311,7 @@
>  	 *	Find the device first to size check it 
>  	 */
>  
> -	saddr->spkt_device[13] = 0;
> +	saddr->spkt_device[IFNAMSIZ-1] = 0;
>  	dev = dev_get_by_name(saddr->spkt_device);
>  	err = -ENODEV;
>  	if (dev == NULL)

This scribbles on sockaddr_pkt.spkt_protocol.

Probably what we need to do here is to put a bit of range-checking into the
userspace tool.  Is it nameif?


  reply	other threads:[~2004-02-10  7:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-10  7:30 MAEDA Naoaki
2004-02-10  7:43 ` Andrew Morton [this message]
2004-02-10  7:52   ` MAEDA Naoaki
2004-02-10  8:25     ` Raj

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=20040209234341.0075159b.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maeda.naoaki@jp.fujitsu.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

all inboxes | Powered by JetHome®