[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_44CA0665C9836EF9EEC80CB9E7E206DF5206@qq.com>
Date: Tue, 19 Dec 2023 18:19:10 +0800
From: Edward Adam Davis <eadavis@...com>
To: syzbot+33f23b49ac24f986c9e8@...kaller.appspotmail.com
Cc: clm@...com,
daniel@...earbox.net,
dsterba@...e.com,
john.fastabend@...il.com,
josef@...icpanda.com,
linux-btrfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
liujian56@...wei.com,
syzkaller-bugs@...glegroups.com
Subject: [PATCH] btrfs: fix oob Read in getname_kernel
If ioctl does not pass in the correct tgtdev_name string, oob will occur because
"\0" cannot be found.
Reported-and-tested-by: syzbot+33f23b49ac24f986c9e8@...kaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@...com>
---
fs/btrfs/dev-replace.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index f9544fda38e9..e7e96e57f682 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -730,7 +730,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
struct btrfs_ioctl_dev_replace_args *args)
{
- int ret;
+ int ret, len;
switch (args->start.cont_reading_from_srcdev_mode) {
case BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS:
@@ -740,8 +740,10 @@ int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
return -EINVAL;
}
+ len = strnlen(args->start.tgtdev_name, BTRFS_DEVICE_PATH_NAME_MAX + 1);
if ((args->start.srcdevid == 0 && args->start.srcdev_name[0] == '\0') ||
- args->start.tgtdev_name[0] == '\0')
+ args->start.tgtdev_name[0] == '\0' ||
+ len == BTRFS_DEVICE_PATH_NAME_MAX + 1)
return -EINVAL;
ret = btrfs_dev_replace_start(fs_info, args->start.tgtdev_name,
--
2.43.0
Powered by blists - more mailing lists