sd-device: refuse opening device mit major/minor of zero early
device nodes with 0 dev_t are not real (and for that reason such inodes are used as whiteouts in overlayfs, for example), hence refuse them early. It seems wrong going to sysfs for something we know can't exist anyway.
This commit is contained in:
@@ -248,6 +248,10 @@ _public_ int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum)
|
||||
assert_return(ret, -EINVAL);
|
||||
assert_return(IN_SET(type, 'b', 'c'), -EINVAL);
|
||||
|
||||
if (devnum == 0)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENODEV),
|
||||
"sd-device: Attempted to allocate device by zero major/minor, refusing.");
|
||||
|
||||
/* use /sys/dev/{block,char}/<maj>:<min> link */
|
||||
xsprintf(id, "%u:%u", major(devnum), minor(devnum));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user