Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c985722 authored by Alexander Aring's avatar Alexander Aring Committed by Greg Kroah-Hartman
Browse files

fs: dlm: handle -EBUSY first in lock arg validation



commit 44637ca41d551d409a481117b07fa209b330fca9 upstream.

During lock arg validation, first check for -EBUSY cases, then for
-EINVAL cases. The -EINVAL checks look at lkb state variables
which are not stable when an lkb is busy and would cause an
-EBUSY result, e.g. lkb->lkb_grmode.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d1ae006b
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -2890,24 +2890,24 @@ static int set_unlock_args(uint32_t flags, void *astarg, struct dlm_args *args)
static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
			      struct dlm_args *args)
{
	int rv = -EINVAL;
	int rv = -EBUSY;

	if (args->flags & DLM_LKF_CONVERT) {
		if (lkb->lkb_flags & DLM_IFL_MSTCPY)
		if (lkb->lkb_status != DLM_LKSTS_GRANTED)
			goto out;

		if (args->flags & DLM_LKF_QUECVT &&
		    !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1])
		if (lkb->lkb_wait_type)
			goto out;

		rv = -EBUSY;
		if (lkb->lkb_status != DLM_LKSTS_GRANTED)
		if (is_overlap(lkb))
			goto out;

		if (lkb->lkb_wait_type)
		rv = -EINVAL;
		if (lkb->lkb_flags & DLM_IFL_MSTCPY)
			goto out;

		if (is_overlap(lkb))
		if (args->flags & DLM_LKF_QUECVT &&
		    !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1])
			goto out;
	}