From patchwork Mon Oct 24 11:29:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp423069wru; Mon, 24 Oct 2022 05:24:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6E6Dkclm9Rl1ojWNXIkr1sPA8hduXnur+vn4kI89Eu+mUJbY3825LnkM3I+F+W0KRYP7D8 X-Received: by 2002:a62:1490:0:b0:563:51e7:693b with SMTP id 138-20020a621490000000b0056351e7693bmr33462954pfu.39.1666614240845; Mon, 24 Oct 2022 05:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614240; cv=none; d=google.com; s=arc-20160816; b=v9WXwIxBzGFEwm/k1RCh2rWyKa4ORR9NoRCMyeHDWno5GwcVYnAWfZvFJBeeIAoOBp 89ErFMtDK025OsRWuPmuMaCHEEsCHx308hW2fGpqeu/lzpbxckTcGKcP+oQ56cwyJiqH po/RcVAVd5VFTRTz2kch7yLkTQMiqSi2W7ihIIkBUf9oRfkTnRvIDRa5dP6JWDbbWKie sD/ESvQ8BqVfq3HSi07m2I6M8uFmuYq86tKcAVlBOQIpK96Fs6zelAtoOGYiQr0zDy5D oxREYjuVpxp/1SGt4bjPmTajlovxGnJ+5X7p9tKptkaA4SFjJt2aONyxgAXDePVL08oD gVXg== 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=/qr1XI5x/ssc6R3+K1MrePoDoqC3vNojA/TpgfvAm3g=; b=aPbWBqO+ZHCA5eFw7sJsFmG5XsHoNL1Gm7xCeb5VYJrgX7jbcoEnwClR6ga75CxhND 5qGSJlgjgwrIGpNzuDlpzWikkSLMOeIEdmeg2ZaPO9Xza/CRZ2VG0veNsBj86nJYAgk6 dS4rPBMj8xL2KxzN4akYA/0O7dGLhz4kdQje5qajwppakB6rR9NopqN3IA0HVXSxV4LP ss2Bfwpp/i+GmMimKjghDL/qzn27unSqDyJa0XXDf8BDn9kqiIycdOkJ6OL5w07tMr0m EjHFR3oFhjNU0THc7a3QxWbdvndmuYkOjYls44861McfLvCm4wC5gZ72fG6vfXDqlrpO vnlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LFz0445F; 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 y23-20020a056a00181700b0056bcfbc75casi4208379pfa.177.2022.10.24.05.23.46; Mon, 24 Oct 2022 05:24:00 -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=LFz0445F; 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 S233533AbiJXMWs (ORCPT + 99 others); Mon, 24 Oct 2022 08:22:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233301AbiJXMUh (ORCPT ); Mon, 24 Oct 2022 08:20:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C136583236; Mon, 24 Oct 2022 04:58:50 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 683FE612BB; Mon, 24 Oct 2022 11:56:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A895C433C1; Mon, 24 Oct 2022 11:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612592; bh=7zRqFiuFdqs1g1fTMewFg4NAJ0rlLykQuJxkC+KCfFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFz0445FVYz7U9AzR/vpK7so8OjXaqNUjSW3m8Vc18gCnvWjRbMFC4wEa9dd/6FUO PFJrvxF/1UeWGo1IzIIiOgFDfujYMjcbjd3Ui27jQuteg+Fl5ufW8ehBmCHNm/ijKp zmww03ZhSftMBIBucEf/QoIOHDILKgDM9Ic1C2uI= 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.19 045/229] fs: dlm: handle -EBUSY first in lock arg validation Date: Mon, 24 Oct 2022 13:29:24 +0200 Message-Id: <20221024113000.552249834@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747571694568710207?= X-GMAIL-MSGID: =?utf-8?q?1747571694568710207?= 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 @@ -2890,24 +2890,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; }