From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH 0/3] dev: Fix network device ifindex allocation
Date: Fri, 16 Jun 2017 17:23:50 +0300 [thread overview]
Message-ID: <cover.1497621810.git.serhe.popovych@gmail.com> (raw)
There are some problems with network device ifindex handling in
the core and veth driver.
* Network device index (ifindex) is signed int, but only values > 0
consodered to be valid. However it is possible for userspace
to supply negative ifindex value using following command:
# ip link add dev dummy2 index -100 up type dummy
# ip link sh dev dummy2
Device "dummy2" does not exist.
# ip li sh |tail -n2
-100: dummy2: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue \
state UNKNOWN mode DEFAULT group default
link/ether 7e:77:1b:49:50:de brd ff:ff:ff:ff:ff:ff
* It is possible to hit infinite loop when number of ifindex in
some network namespace get exchausted.
# There should be plenty of RAM to create INT_MAX netdev.
# Hitting OOM is much likely with such huge number, but anyway.
for ((i = 1; i <= 0x7fffffff; i++)); do
ifname="dummy$i";
[ ! -d "/sys/class/net/$ifname" ] || continue
ip link add dev "$ifname" index "$i" type dummy
done
* (minor) check for dev->ifindex being greater than zero.
Patches in this series tries to address these problems.
Serhey Popovych (3):
dev: Prevent creating network devices with negative ifindex
dev: Avoid infinite loop on network device index exhaustion
veth: Set ifindex only if given and not negative
drivers/net/veth.c | 2 +-
net/core/dev.c | 30 ++++++++++++++++++++++--------
2 files changed, 23 insertions(+), 9 deletions(-)
--
1.8.3.1
next reply other threads:[~2017-06-16 14:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-16 14:23 Serhey Popovych [this message]
2017-06-16 14:23 ` [PATCH 1/3] dev: Prevent creating network devices with negative ifindex Serhey Popovych
2017-06-16 16:18 ` Stephen Hemminger
2017-06-16 16:44 ` Serhey Popovych
2017-06-16 17:25 ` Stephen Hemminger
2017-06-16 18:14 ` Serhey Popovych
2017-06-16 14:23 ` [PATCH 2/3] dev: Avoid infinite loop on network device index exhaustion Serhey Popovych
2017-06-16 16:16 ` Stephen Hemminger
2017-06-16 16:32 ` Serhey Popovych
2017-06-16 16:39 ` dev: Reclaim network device indexes Serhey Popovych
2017-06-20 16:42 ` David Miller
2017-06-16 14:23 ` [PATCH 3/3] veth: Set ifindex only if given and not negative Serhey Popovych
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=cover.1497621810.git.serhe.popovych@gmail.com \
--to=serhe.popovych@gmail.com \
--cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.