From f9b4646c47caf5c123a32d24cf3d84bb2928771b Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Wed, 28 Aug 2019 11:19:47 +0200 Subject: block: loop: fix initialization issue in loop_set_status* The loop_info structure is not initialized correctly if an old losetup utility without file format support is used. In that case, the file format type is not initalized and the LOOP_SET_STATUS* ioctl calls always fails. This patch initalizes the loop file format in the backward compatibility mode to the default RAW file format type and prevents the failing of the LOOP_SET_STATUS* ioctl calls. Signed-off-by: Manuel Bentele --- drivers/block/loop/loop_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/block/loop/loop_main.c b/drivers/block/loop/loop_main.c index f37ed6e51a45..7c1bb19a1cf1 100644 --- a/drivers/block/loop/loop_main.c +++ b/drivers/block/loop/loop_main.c @@ -1160,6 +1160,8 @@ loop_set_status_old(struct loop_device *lo, const struct loop_info __user *arg) err = copy_from_user(&info, arg, sizeof(info)); if (err) return -EFAULT; + } else { + info64.lo_file_fmt_type = LO_FILE_FMT_RAW; } loop_info64_from_old(&info, &info64); @@ -1184,6 +1186,8 @@ loop_set_status64(struct loop_device *lo, const struct loop_info64 __user *arg) err = copy_from_user(&info64, arg, sizeof(info64)); if (err) return -EFAULT; + } else { + info64.lo_file_fmt_type = LO_FILE_FMT_RAW; } return loop_set_status(lo, &info64); @@ -1435,6 +1439,8 @@ loop_info64_from_compat(const struct compat_loop_info __user *arg, err = copy_from_user(&info, arg, sizeof(info)); if (err) return -EFAULT; + } else { + info.lo_file_fmt_type = LO_FILE_FMT_RAW; } memset(info64, 0, sizeof(*info64)); -- cgit v1.2.3-55-g7522