Commit 41a5e877 authored by Dmitry Antipov's avatar Dmitry Antipov Committed by Andrew Morton
Browse files

ocfs2: add extra flags check in ocfs2_ioctl_move_extents()

In 'ocfs2_ioctl_move_extents()', add extra check whether only actually
supported flags are passed via 'ioctl(..., OCFS2_IOC_MOVE_EXT, ...)',
and reject anything beyond OCFS2_MOVE_EXT_FL_AUTO_DEFRAG and
OCFS2_MOVE_EXT_FL_PART_DEFRAG with -EINVAL. In particular,
OCFS2_MOVE_EXT_FL_COMPLETE may be set by the kernel only and
should never be passed from userspace.

Link: https://lkml.kernel.org/r/20251009102349.181126-1-dmantipov@yandex.ru


Signed-off-by: default avatarDmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mark@fasheh.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 55b453ed
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1036,6 +1036,12 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
	if (range.me_threshold > i_size_read(inode))
		range.me_threshold = i_size_read(inode);

	if (range.me_flags & ~(OCFS2_MOVE_EXT_FL_AUTO_DEFRAG |
			       OCFS2_MOVE_EXT_FL_PART_DEFRAG)) {
		status = -EINVAL;
		goto out_free;
	}

	if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) {
		context->auto_defrag = 1;