diff options
| author | Hengyu Liang <hengyul@cs.unc.edu> | 2026-10-09 13:33:59 -0400 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-10-12 19:18:05 +0200 |
| commit | 9985f1643ac3f8595862e2f82108f0ccae4cf959 (patch) | |
| tree | 0323c560c92cf6e67b2f1bc62942f16bc36bbdc7 /scripts/Makefile.thinlto | |
| parent | eb55bc2bfe204e6bfccfe179226d7fb5024cb010 (diff) | |
| download | linux-9985f1643ac3f8595862e2f82108f0ccae4cf959.tar.gz linux-9985f1643ac3f8595862e2f82108f0ccae4cf959.zip | |
btrfs: return -ENOTTY for unknown ioctls on the control device
Commit 5ab2b180884c ("btrfs: factor out validation of
btrfs_ioctl_vol_args::name") made btrfs_control_ioctl() store the result
of btrfs_check_ioctl_vol_args_path() in ret before it looks at the
command.
However, ret is initialized to -ENOTTY and the switch has no default
case, so this initial value was what an unknown command returned. As of
now, every unknown ioctl on /dev/btrfs-control returns 0. A tool that
tries a control ioctl which the running kernel does not have is told
that the ioctl succeeded.
The issue can be reproduced with a simple C program, run as root:
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
int main(void)
{
static char buf[4096];
int fd = open("/dev/btrfs-control", O_RDWR);
if (ioctl(fd, TCGETS, buf) < 0)
perror("ioctl");
else
printf("ioctl succeeded\n");
return 0;
}
Before commit 5ab2b180884c ("btrfs: factor out validation of
btrfs_ioctl_vol_args::name"), the result is:
ioctl: Inappropriate ioctl for device
After that commit, the result is:
ioctl succeeded
This patch will add a default case that returns -ENOTTY.
Fixes: 5ab2b180884c ("btrfs: factor out validation of btrfs_ioctl_vol_args::name")
CC: stable@vger.kernel.org
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
