From nobody Fri Dec 19 16:01:18 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9722AC67871 for ; Mon, 24 Oct 2022 19:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233866AbiJXTz1 (ORCPT ); Mon, 24 Oct 2022 15:55:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233948AbiJXTyL (ORCPT ); Mon, 24 Oct 2022 15:54:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0643916085F; Mon, 24 Oct 2022 11:18:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 18599B811EF; Mon, 24 Oct 2022 12:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B6BAC433D6; Mon, 24 Oct 2022 12:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614856; bh=HyQXrJH1l3T0A4SR0/zGg1i70pBwz1wEYQUnliiTFqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pV6sdF+F9QEyxa/hJtZX5dpQlW88GRk99GW53XJ72VVkVQYrQFzl4en10mq7xHkz6 HFLd1S7N6t306zZfojHP6bDAZBcKGitvow0vzpHIW0oj886iJRLUTzY6/I6AK5DyTt p+nHTNhqukNYbnhPhqHZ/MsIr7pxpFd2bPgOYy+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland Subject: [PATCH 5.15 029/530] fs: dlm: handle -EBUSY first in lock arg validation Date: Mon, 24 Oct 2022 13:26:13 +0200 Message-Id: <20221024113046.331299531@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Aring 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: Alexander Aring Signed-off-by: David Teigland Signed-off-by: Greg Kroah-Hartman --- fs/dlm/lock.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -2888,24 +2888,24 @@ static int set_unlock_args(uint32_t flag static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, struct dlm_args *args) { - int rv =3D -EINVAL; + int rv =3D -EBUSY; =20 if (args->flags & DLM_LKF_CONVERT) { - if (lkb->lkb_flags & DLM_IFL_MSTCPY) + if (lkb->lkb_status !=3D DLM_LKSTS_GRANTED) goto out; =20 - if (args->flags & DLM_LKF_QUECVT && - !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1]) + if (lkb->lkb_wait_type) goto out; =20 - rv =3D -EBUSY; - if (lkb->lkb_status !=3D DLM_LKSTS_GRANTED) + if (is_overlap(lkb)) goto out; =20 - if (lkb->lkb_wait_type) + rv =3D -EINVAL; + if (lkb->lkb_flags & DLM_IFL_MSTCPY) goto out; =20 - if (is_overlap(lkb)) + if (args->flags & DLM_LKF_QUECVT && + !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1]) goto out; }