From patchwork Mon Oct 24 11:28:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp642785wru; Mon, 24 Oct 2022 13:39:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6E0wCC2sPhVPjHm+Pe2cdbi/CEmQt9QPtGCi8XO1LcQPLgTLPS8sJukZWDlSpeUDur0yLj X-Received: by 2002:a17:90b:4f4d:b0:20d:a08e:3876 with SMTP id pj13-20020a17090b4f4d00b0020da08e3876mr70425446pjb.0.1666643974681; Mon, 24 Oct 2022 13:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643974; cv=none; d=google.com; s=arc-20160816; b=BdXvj1gFLQSA55VRVRT0OiNRu4Br35yyBufv5iweZGB4JVIBH8q+6XVjrqcFFVykpt bMWFmCWF3DRtrbuhAOTpCVFQ3FK0n2NaVqX5a4Auz9mQSDVFCpsODCIsSayvrQnOwJj5 eoymBJjv2nf1gmmCh072C1b977bnX/cmxhSJYzlyVqrz/cZPBSI5yDAizbkgCJ3ihVLf hTc9nDalsui46saS2hWi+asanYK8pv+4OBZsPbB+79UBMAN6aYnlm2dFaN3HjMMH5oXC X17MaAxWyhOeGuynQaqwh9htYZNP5z+lAeO924dO5s6qS5H0VIwVNWESGAkhWXYmYi5U f1ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zoLsly3rSX2k+tJrefEqaG3ZAdumxmHDrsw1ro01eYY=; b=n+9PyJl7XcOUpKImyHJFCmeltSrmbk2KUOhbtMVNDgBT3No0HtSGCFqnHgrl5rWIgd o6z5bvkI7e4AZ47DCCnuZ0v+Sfqqku9d/i+Fqc3WCaeXj2lkwrb2TDSlhIWW22dxQ0zT nsYpa92bYhpdh4T6eQ2vbqTUJYH6Zz2Ok2cFDn3e4OhphXCDMgODCSyEameb8Yhj+NUD 7C7TBnJOTMSV0fskEcfYaIzpXOqYIeYdn4gBsgkZuvWzGotnkeT9BHtaMQRG4t+O/NEf gixt+Xg/OxG7M4yDoRjlhE3ZE1E3I7S8XR9khrevtE2U8N0Zb2Vezxb8/YcM4UwTpBmB XBzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KN/C7Au1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a63f112000000b00434e297a5ccsi553062pgi.142.2022.10.24.13.39.20; Mon, 24 Oct 2022 13:39:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KN/C7Au1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234533AbiJXUh5 (ORCPT + 99 others); Mon, 24 Oct 2022 16:37:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234527AbiJXUhW (ORCPT ); Mon, 24 Oct 2022 16:37:22 -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 B34BC1D818B; Mon, 24 Oct 2022 11:48:38 -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 BBFAAB81252; Mon, 24 Oct 2022 12:05:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21AE5C433D7; Mon, 24 Oct 2022 12:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613137; bh=HyQXrJH1l3T0A4SR0/zGg1i70pBwz1wEYQUnliiTFqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KN/C7Au1S/hQU+SmL4GQjC5c26LoJdEqnL+BfdWIokRZS1/TQ92yTMT8O8IWluwIL /ZBBaGnEGW/wYEb7T0TxfEvbb8Nb9fanoT05WMwJS/5z4q5ECh7sFRG4yMK1yrliiH Omt4toLM4YhOETvKBoQbUdThnGrnzMBr7XJgTs9Q= 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.4 022/255] fs: dlm: handle -EBUSY first in lock arg validation Date: Mon, 24 Oct 2022 13:28:52 +0200 Message-Id: <20221024113003.179425329@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747602872588716346?= X-GMAIL-MSGID: =?utf-8?q?1747602872588716346?= 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 = -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; }