Blame SOURCES/0301-udev-filter-out-non-sensically-high-onboard-indexes-.patch

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