bcachefs: Enforce SYS_CAP_ADMIN within ioctls
authorTobias Geerinckx-Rice <me@tobias.gr>
Sun, 4 Jul 2021 19:35:32 +0000 (21:35 +0200)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:07 +0000 (17:09 -0400)
commita515d0a50c6e8bb9b8ce58d6e396b4c5eeea6905
tree91a12d28b422f1318c5591dffcd25440bc6a93af
parent508b1f71396486648e3d42d1814e7f148fbb7751
bcachefs: Enforce SYS_CAP_ADMIN within ioctls

bch2_fs_ioctl() didn't distinguish between unsupported ioctls and those
which the current user is unauthorised to perform.  That kept the code
simple but meant that, for example, an unprivileged TIOCGWINSZ ioctl on
a bcachefs file would return -EPERM instead of the expected -ENOTTY.
The same call made by a privileged user would correctly return -ENOTTY.

Fix this discrepancy by moving the check for CAP_SYS_ADMIN into each
privileged ioctl function.

Signed-off-by: Tobias Geerinckx-Rice <me@tobias.gr>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/chardev.c