From patchwork Wed Oct 19 08:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp203253wrs; Wed, 19 Oct 2022 01:42:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM69WllS2cXWdqpURgNCd8ywIrAwt1nSIYuiKMALkQhjQYaMM7aXld28UKnDvAb0vxo2QZdt X-Received: by 2002:a17:907:7606:b0:78e:61d:757e with SMTP id jx6-20020a170907760600b0078e061d757emr5464540ejc.690.1666168959559; Wed, 19 Oct 2022 01:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168959; cv=none; d=google.com; s=arc-20160816; b=RQ8NT+aqra06pkoI5DxseG4MXYvHBtb4ihJoxWeRbHXDkOXVoVqLg/o68AIvsRRJrX npl2QyuzFNm4VXklIBS5waIzwHbKpJT8kOAmOw2hvmcOOh+RiqDPv3oPrW+q0EGmqPqa 9LyTJHbSSBYMaJKjIu50BIyrPaXJ0nN5/lXT92ZGAhiPAvkGKGT1dUd4ODMFc9iXgcKr 1GdXB3cW8J8QQPfHAXnfyUOQUlpgSrALFe4dcTNhgNeIJS1pLj8FXWNv5t8iqRzhNgte EYPnQuRM37tg1vmGYnvE+7EGnMs1YfDK5PuAD32x3QJSY95TI5WqXmLxt+lji8zNWX8R f7HQ== 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=rkf5vDjaDmMsbeKKzd8lQpYwPy8z86ajz3rfzikKGpo=; b=ujNkHpWFv9v3pClcltbkXuPE8vR4ljX5l/O+pX0uK3Db6vgTXE/Z/HsuIF9DSJ7h1B ymTOhey4mX94cFITfBl0LuQle7NBXgDGJwFXl5nr6No2Tm9k1DViwY4jn6a7dksr5qa2 fC60hxud7XEWhQ1weQNAcqNB5kaGl71fAoNsmVyThEzdAgeV6ECFObr6JWUTAEwKY2D3 xi0GCFwo0E7TKVB3gjCSoDeLUIQwtoh+5EsqhazvI/aeSs5/FujEpab8s2WJ28lYtYkT lZSKgyuulvNzgZEnU5vR4DG/40/unvlBo7TZ+EFBo5YIVpejgIG7IM3w7lf+M+J8C7CE BBcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FpMVnUa5; 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 q20-20020a1709060e5400b007835e4733cbsi10655299eji.201.2022.10.19.01.42.13; Wed, 19 Oct 2022 01:42:39 -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=FpMVnUa5; 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 S230361AbiJSIlr (ORCPT + 99 others); Wed, 19 Oct 2022 04:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230346AbiJSIkc (ORCPT ); Wed, 19 Oct 2022 04:40:32 -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 1F19C814D7; Wed, 19 Oct 2022 01:39:11 -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 CA5D5617DF; Wed, 19 Oct 2022 08:39:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD127C433C1; Wed, 19 Oct 2022 08:39:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168750; bh=hO1PLpSoAE8YIp/WBagL/lFkvdLXZQq7FOg+I9oQ/K0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FpMVnUa58hcP6KVkEEdbYHG9wpLb5h8I094Jx+Db3nnWIagZK+zx1F70j1L9tr+Iv F0+TkF0kBkPOvS2m0izX73ffh2WDb4OTngaZpYPZ2RWAyoNicP2j1RclkPyUsZqDt8 RNd3GN93Hf5lYDDCvjFT12VIP6ki39x3aYrMUxcE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Aring , David Teigland Subject: [PATCH 6.0 042/862] fs: dlm: handle -EBUSY first in lock arg validation Date: Wed, 19 Oct 2022 10:22:09 +0200 Message-Id: <20221019083251.859555995@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104783244353863?= X-GMAIL-MSGID: =?utf-8?q?1747104783244353863?= 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -2864,17 +2864,9 @@ 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) - goto out; - - if (args->flags & DLM_LKF_QUECVT && - !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1]) - goto out; - - rv = -EBUSY; if (lkb->lkb_status != DLM_LKSTS_GRANTED) goto out; @@ -2884,6 +2876,14 @@ static int validate_lock_args(struct dlm if (is_overlap(lkb)) goto out; + + rv = -EINVAL; + if (lkb->lkb_flags & DLM_IFL_MSTCPY) + goto out; + + if (args->flags & DLM_LKF_QUECVT && + !__quecvt_compat_matrix[lkb->lkb_grmode+1][args->mode+1]) + goto out; } lkb->lkb_exflags = args->flags;