diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2020-05-14 16:44:23 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2020-05-14 16:44:23 +0200 |
commit | a3c751a50fe6bbe50eb7622a14b18b361804ee0c (patch) | |
tree | c06d4a05f89fea5d5ea3f4729ab6748140bbb77a /fs/char_dev.c | |
parent | 0e698dfa282211e414076f9dc7e83c1c288314fd (diff) | |
download | linux-a3c751a50fe6bbe50eb7622a14b18b361804ee0c.tar.gz linux-a3c751a50fe6bbe50eb7622a14b18b361804ee0c.tar.bz2 linux-a3c751a50fe6bbe50eb7622a14b18b361804ee0c.zip |
vfs: allow unprivileged whiteout creation
Whiteouts, unlike real device node should not require privileges to create.
The general concern with device nodes is that opening them can have side
effects. The kernel already avoids zero major (see
Documentation/admin-guide/devices.txt). To be on the safe side the patch
explicitly forbids registering a char device with 0/0 number (see
cdev_add()).
This guarantees that a non-O_PATH open on a whiteout will fail with ENODEV;
i.e. it won't have any side effect.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/char_dev.c')
-rw-r--r-- | fs/char_dev.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/char_dev.c b/fs/char_dev.c index c5e6eff5a381..ba0ded7842a7 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -483,6 +483,9 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count) p->dev = dev; p->count = count; + if (WARN_ON(dev == WHITEOUT_DEV)) + return -EBUSY; + error = kobj_map(cdev_map, dev, count, NULL, exact_match, exact_lock, p); if (error) |