mirror of
https://github.com/systemd/systemd.git
synced 2025-03-24 14:50:17 +03:00
udev: filter out non-sensically high onboard indexes reported by the kernel
Let's not accept onboard interface indexes, that are so high that they are obviously non-sensical. Fixes: #2407
This commit is contained in:
parent
4cb94977ed
commit
6c1e69f945
@ -106,6 +106,8 @@
|
||||
#include "string-util.h"
|
||||
#include "udev.h"
|
||||
|
||||
#define ONBOARD_INDEX_MAX (16*1024-1)
|
||||
|
||||
enum netname_type{
|
||||
NET_UNDEF,
|
||||
NET_PCI,
|
||||
@ -152,6 +154,13 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
|
||||
if (idx <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* Some BIOSes report rubbish indexes that are excessively high (2^24-1 is an index VMware likes to report for
|
||||
* example). Let's define a cut-off where we don't consider the index reliable anymore. We pick some arbitrary
|
||||
* cut-off, which is somewhere beyond the realistic number of physical network interface a system might
|
||||
* have. Ideally the kernel would already filter his crap for us, but it doesn't currently. */
|
||||
if (idx > ONBOARD_INDEX_MAX)
|
||||
return -ENOENT;
|
||||
|
||||
/* kernel provided port index for multiple ports on a single PCI function */
|
||||
attr = udev_device_get_sysattr_value(dev, "dev_port");
|
||||
if (attr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user