|
|
1abbee |
From 0fa424a08a31af512a698b60b497cfc0cf0554e0 Mon Sep 17 00:00:00 2001
|
|
|
1abbee |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
1abbee |
Date: Mon, 25 Jan 2016 17:16:27 +0100
|
|
|
1abbee |
Subject: [PATCH] udev: filter out non-sensically high onboard indexes reported
|
|
|
1abbee |
by the kernel
|
|
|
1abbee |
|
|
|
1abbee |
Let's not accept onboard interface indexes, that are so high that they are obviously non-sensical.
|
|
|
1abbee |
|
|
|
1abbee |
Fixes: #2407
|
|
|
1abbee |
|
|
|
1abbee |
Cherry-picked from: 6c1e69f9456d022f14dd00737126cfa4d9cca10
|
|
|
1abbee |
Resolves: #1230210
|
|
|
1abbee |
---
|
|
|
1abbee |
src/udev/udev-builtin-net_id.c | 9 +++++++++
|
|
|
1abbee |
1 file changed, 9 insertions(+)
|
|
|
1abbee |
|
|
|
1abbee |
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
|
|
|
181b3f |
index ffd6ea416..19e1f2631 100644
|
|
|
1abbee |
--- a/src/udev/udev-builtin-net_id.c
|
|
|
1abbee |
+++ b/src/udev/udev-builtin-net_id.c
|
|
|
1abbee |
@@ -101,6 +101,8 @@
|
|
|
1abbee |
#include "udev.h"
|
|
|
1abbee |
#include "fileio.h"
|
|
|
1abbee |
|
|
|
1abbee |
+#define ONBOARD_INDEX_MAX (16*1024-1)
|
|
|
1abbee |
+
|
|
|
1abbee |
enum netname_type{
|
|
|
1abbee |
NET_UNDEF,
|
|
|
1abbee |
NET_PCI,
|
|
|
1abbee |
@@ -147,6 +149,13 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
|
|
|
1abbee |
if (idx <= 0)
|
|
|
1abbee |
return -EINVAL;
|
|
|
1abbee |
|
|
|
1abbee |
+ /* Some BIOSes report rubbish indexes that are excessively high (2^24-1 is an index VMware likes to report for
|
|
|
1abbee |
+ * example). Let's define a cut-off where we don't consider the index reliable anymore. We pick some arbitrary
|
|
|
1abbee |
+ * cut-off, which is somewhere beyond the realistic number of physical network interface a system might
|
|
|
1abbee |
+ * have. Ideally the kernel would already filter his crap for us, but it doesn't currently. */
|
|
|
1abbee |
+ if (idx > ONBOARD_INDEX_MAX)
|
|
|
1abbee |
+ return -ENOENT;
|
|
|
1abbee |
+
|
|
|
1abbee |
/* kernel provided port index for multiple ports on a single PCI function */
|
|
|
1abbee |
attr = udev_device_get_sysattr_value(dev, "dev_port");
|
|
|
1abbee |
if (attr)
|