* [PATCH] packet_sendmsg_spkt incorrectly truncates an interface name
@ 2004-02-10 7:30 MAEDA Naoaki
2004-02-10 7:43 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: MAEDA Naoaki @ 2004-02-10 7:30 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, maeda.naoaki
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.
Obviously, max name length of a network interface name is IFNAMESIZ-1,
which is 15. 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.
The following patch fix the problem.
Thanks,
Naoaki
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] packet_sendmsg_spkt incorrectly truncates an interface name
2004-02-10 7:30 [PATCH] packet_sendmsg_spkt incorrectly truncates an interface name MAEDA Naoaki
@ 2004-02-10 7:43 ` Andrew Morton
2004-02-10 7:52 ` MAEDA Naoaki
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2004-02-10 7:43 UTC (permalink / raw)
To: MAEDA Naoaki; +Cc: linux-kernel
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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] packet_sendmsg_spkt incorrectly truncates an interface name
2004-02-10 7:43 ` Andrew Morton
@ 2004-02-10 7:52 ` MAEDA Naoaki
2004-02-10 8:25 ` Raj
0 siblings, 1 reply; 4+ messages in thread
From: MAEDA Naoaki @ 2004-02-10 7:52 UTC (permalink / raw)
To: akpm; +Cc: maeda.naoaki, linux-kernel
Hi,
> > 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.
Oops! I have not checked it.
Does anybody know the reason why it is only 14 bytes?
Thanks,
Naoaki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] packet_sendmsg_spkt incorrectly truncates an interface name
2004-02-10 7:52 ` MAEDA Naoaki
@ 2004-02-10 8:25 ` Raj
0 siblings, 0 replies; 4+ messages in thread
From: Raj @ 2004-02-10 8:25 UTC (permalink / raw)
To: MAEDA Naoaki; +Cc: akpm, linux-kernel
On Tue, 10 Feb 2004, MAEDA Naoaki wrote:
> Hi,
>
> > > 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.
>
> Oops! I have not checked it.
> Does anybody know the reason why it is only 14 bytes?
>
include/linux/socket.h
struct sockaddr {
...
char sa_data[14]; /* 14 bytes of protocol address */
};
A 14 byte field here too !. Maybe there is an explanation.
/Raj
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-10 8:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-10 7:30 [PATCH] packet_sendmsg_spkt incorrectly truncates an interface name MAEDA Naoaki
2004-02-10 7:43 ` Andrew Morton
2004-02-10 7:52 ` MAEDA Naoaki
2004-02-10 8:25 ` Raj
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®