Commit 1e8c813b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

PM: hibernate: don't use early_lookup_bdev in resume_store

resume_store is a sysfs attribute written during normal kernel runtime,
and it should not use the early_lookup_bdev API that bypasses all normal
path based permission checking, and might cause problems with certain
container environments renaming devices.

Switch to lookup_bdev, which does a normal path lookup instead, and fall
back to trying to parse a numeric dev_t just like early_lookup_bdev did.

Note that this strictly speaking changes the kernel ABI as the PARTUUID=
and PARTLABEL= style syntax is now not available during a running
systems.  They never were intended for that, but this breaks things
we'll have to figure out a way to make them available again.  But if
avoidable in any way I'd rather avoid that.

Fixes: 421a5fa1 ("PM / hibernate: use name_to_dev_t to parse resume")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230531125535.676098-22-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7a126d5b
...@@ -1178,7 +1178,23 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, ...@@ -1178,7 +1178,23 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
if (!name) if (!name)
return -ENOMEM; return -ENOMEM;
error = early_lookup_bdev(name, &dev); error = lookup_bdev(name, &dev);
if (error) {
unsigned maj, min, offset;
char *p, dummy;
if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2 ||
sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset,
&dummy) == 3) {
dev = MKDEV(maj, min);
if (maj != MAJOR(dev) || min != MINOR(dev))
error = -EINVAL;
} else {
dev = new_decode_dev(simple_strtoul(name, &p, 16));
if (*p)
error = -EINVAL;
}
}
kfree(name); kfree(name);
if (error) if (error)
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment