Opened 10 years ago

Closed 10 years ago

#10183 closed bug (fixed)

Incorrect handling of non-existing network devices

Reported by: jackburton Owned by: axeld
Priority: normal Milestone: R1
Component: Network & Internet/Stack Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

The Network stack handles non-existing network devices incorrectly:

ifconfig /dev/net/foobar auto-config

causes the network stack to allocate resources for the non-existing interface.

The stack or the ethernet module should probably check if a device with the given name exists in allocate_device_interface() or in ethernet_init() respectively. Reproducible under qemu.

Attachments (3)

foo.png (48.1 KB ) - added by jackburton 10 years ago.
0001-Check-if-device-exists-before-creating-ethernet-inte.patch (985 bytes ) - added by jackburton 10 years ago.
Proposed patch
0002-Check-the-given-path-for.patch (1.2 KB ) - added by jackburton 10 years ago.
Avoid creating interface for paths with ".."

Download all attachments as: .zip

Change History (9)

by jackburton, 10 years ago

Attachment: foo.png added

comment:1 by jackburton, 10 years ago

Interestingly, this allows for things like

~/Desktop> ifconfig /dev/net/../zero auto-config
~/Desktop> ifconfig /dev/net/../zero up
ifconfig: Setting flags failed: Operation not allowed

or

~/Desktop> ifconfig /dev/net/../../system auto-config
~/Desktop> ifconfig /dev/net/../../system up
ifconfig: Setting flags failed: Is a directory

But the interface exists, and the net_stack will happily try to assign an address via DHCP.

comment:2 by jackburton, 10 years ago

patch: 01

comment:3 by jackburton, 10 years ago

The attached patch fixes the bug (although not the problem described in comment 1). Is it okay to apply it ? Is there any reason why the ethernet device should be created without the /dev/net/ entry ? I'm not that familiar with our device manager, so...

by jackburton, 10 years ago

Avoid creating interface for paths with ".."

comment:4 by jackburton, 10 years ago

Fixes also the other problem. Any objection if I apply these patches ?

comment:5 by axeld, 10 years ago

While in theory you are allowed to name your interface as you wish, since /dev/net/ is handled by the ethernet device driver, your patches definitely make sense, so please go ahead.

comment:6 by jackburton, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in hrev46340.

Note: See TracTickets for help on using tickets.