From patchwork Mon Oct 24 11:30:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8429 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp400833wru; Mon, 24 Oct 2022 04:47:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5xXgW3ZS8Jzrf2IDjbAxqCeQDlblSfvUvjaPaVnPTyEANiQ89x5ttwZ7Ujzx9irWV0hlR8 X-Received: by 2002:a05:6402:448c:b0:457:52eb:b57e with SMTP id er12-20020a056402448c00b0045752ebb57emr30859297edb.178.1666612068006; Mon, 24 Oct 2022 04:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612068; cv=none; d=google.com; s=arc-20160816; b=g8cObh/j+8LOSoJAmZXm8uQ0aAMfwkwsite63iOTgSoZvognS/bNzRIw74cgp0iZeX ectOvNIdzPU3a+UTosoU50tMgbkGAwNfIWlaw+EW9BHps51Wt8pkiqrLGY3jpapYovQ7 GMW9NCQXkS4t7fHMDU7ZQ6BnYtL16X8VSpQBvr6YpsDQuAIHx3M+lrBrzkUQJJk0qtVX Rmg/jjlnPh6PyLqMGuyghPwzmF5JSR6VANxllHWjNRkOB7GGA4NVSj1NxEytJEKgs9/L q1TFonyr+QSBfGZ0kaB7U1d+L8pqs2/hXGENuINVD2l4TjJ2ceTIZh8bYVsJIBkTmUV/ UiMg== 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=KEOQoWmlyTJw2KfYMMvoRF97w9CtanEIO9TQ2nKg7jxzfsBEMU191AmDiJR9M3WkAt ByDEIODlVlr5/ro9Kr5zRGIxCeC52W/jXUJ85NtnmGPZPJtpblbNrEoBg05jAir8ycG8 2LliBTkSqMA/Y1dEeBNdG1teXaJo2Pyt/wZolIoksfqEbbFSUgi4S1N2sbHOTfVkf+Lo NHXeWxME25b6D/VDwN3nqVEskTx0zv0uzROZJ4ZTNL1vhGGsTOtU/UH/BZI0AHg3yj81 t9QJfMTpow/9Uc4csikpGhI3w3fW2EegY+Q0nNysBeXedmUIFlVHe2RadKijO26ktdwE aOqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tDysg+kz; 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 s17-20020aa7c551000000b0045c9dbe290csi24368931edr.406.2022.10.24.04.47.24; Mon, 24 Oct 2022 04:47:47 -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=tDysg+kz; 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 S231611AbiJXLq1 (ORCPT + 99 others); Mon, 24 Oct 2022 07:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbiJXLob (ORCPT ); Mon, 24 Oct 2022 07:44:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0404574CDC; Mon, 24 Oct 2022 04:41:58 -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 9B6D4B8117E; Mon, 24 Oct 2022 11:40:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBD26C433C1; Mon, 24 Oct 2022 11:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611623; bh=HyQXrJH1l3T0A4SR0/zGg1i70pBwz1wEYQUnliiTFqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tDysg+kzw6SbyYmIweEkjiKR3EhzymMZwxFLc6SqF+tU1RuofV6SdGRb8ICbXBE1n pd8hqB7Zsom8a/tIVL3qIgFAAOMeJ0pl7i2Qo64dmQuD6h++Th7jQvbrf/Jj/CyaJm Qn+RO8uMoIPcTgDuLNEYS6PZ+jgo+cBtMjN4nrO0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland Subject: [PATCH 4.9 047/159] fs: dlm: handle -EBUSY first in lock arg validation Date: Mon, 24 Oct 2022 13:30:01 +0200 Message-Id: <20221024112951.127474701@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747569415926718678?= X-GMAIL-MSGID: =?utf-8?q?1747569415926718678?= 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; }