Hubert Kario
2012-Feb-20 23:33 UTC
[PATCH 1/2] btrfs: ensure null-termination of string copied from userspace
Signed-off-by: Hubert Kario <kario@wit.edu.pl> --- fs/btrfs/ioctl.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index dae5dfe..3dede5c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2121,6 +2121,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) di_args->total_bytes = dev->total_bytes; memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); strncpy(di_args->path, dev->name, sizeof(di_args->path)); + di_args->path[BTRFS_DEVICE_PATH_NAME_MAX-1] = ''\0''; out: if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args))) -- 1.7.9 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hubert Kario
2012-Feb-20 23:33 UTC
[PATCH 2/2] btrfs: handle dev info ioctl on degraded mount
Signed-off-by: Hubert Kario <kario@wit.edu.pl> --- fs/btrfs/ioctl.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 3dede5c..d536816 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2120,7 +2120,10 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) di_args->bytes_used = dev->bytes_used; di_args->total_bytes = dev->total_bytes; memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); - strncpy(di_args->path, dev->name, sizeof(di_args->path)); + if (dev->name) + strncpy(di_args->path, dev->name, sizeof(di_args->path)); + else + di_args->path[0] = ''\0''; di_args->path[BTRFS_DEVICE_PATH_NAME_MAX-1] = ''\0''; out: -- 1.7.9 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html