From patchwork Mon Oct 24 11:29:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8855 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp432984wru; Mon, 24 Oct 2022 05:48:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CKzAsXLdCYJsP9XovLnZUSK9APPbXKaiGlIsIRKVWNCqimDXW8/u9zjaj2O2ot2KdrY8c X-Received: by 2002:a17:903:11c3:b0:17a:e62:16e8 with SMTP id q3-20020a17090311c300b0017a0e6216e8mr34718798plh.137.1666615695511; Mon, 24 Oct 2022 05:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615695; cv=none; d=google.com; s=arc-20160816; b=ScjC9TsaUFU9G9eoaZhTP+CtwIhdT7xvQzOsUBX2waNCx6fPfzOKsYBSaNO1348i/k UqSxMWtGc6VDAT6bjkicGNdQR/v5vjrIphWMg4gyhHrdTwX3SaWSflYAjg79glCd0Y24 X1WQPpf4QFxtTLNGGCmfV6eLHdpoqFRP/nKubbThDfxRNycHeip0bo6ZzBnTw2chxlGd dwehaplTG67iezK/T4sN5wJF/RNuO0bcrXYfNb8dLyp1YThZkXKnjC4Yf9NKK8tIPcFH N3pC11DN88SIbVTRLtHnSP99jv9Fg3frxOSRyXlGto4a0HQGr73r+SNV+ZSAg0dUEDds RKFQ== 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=OIw9Vi02JKjELh8Dryxwq3cawlZHQhyImfU86v1c1eo=; b=QT+fMDpofPrDwkgHoik+0Yn4SLrV0q21rRyc1Jmq7+pvv5eHvHkVL7di6gvRNaYzXi y005/gapvCZDrK388QV1am2NW5xVuA3vai0zLa65wOGILxJp3Fhrl56PD6I8dtPMrKkq 8OJEfdq8hV69D33BUB3K9MwBTd8cA+apmMkYFYi4b4TBRcY0eOUehMxgfjGct/1b9EMn lnWfHug92ZwP6o1sfwURZfCHd3ejGRXMp9V8ymt2TeEyOgdczaNVLVHedtk+mok8DBdN sEJoCACxx4UKVh7L5639L7LTZVdVgs49xnrjblKm00KYZQUPBHdOSCmuaZ6zlruwR2ji CVvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1QVbDz6t; 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 n15-20020a6546cf000000b0046b2ec0de65si34522887pgr.789.2022.10.24.05.48.01; Mon, 24 Oct 2022 05:48:15 -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=1QVbDz6t; 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 S232790AbiJXMhG (ORCPT + 99 others); Mon, 24 Oct 2022 08:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234463AbiJXMaY (ORCPT ); Mon, 24 Oct 2022 08:30:24 -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 EA9C19FE7; Mon, 24 Oct 2022 05:04:36 -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 2CA70B810F5; Mon, 24 Oct 2022 11:47:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CFFFC433D6; Mon, 24 Oct 2022 11:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612064; bh=Yje59W4irP4MXC+axArm1788mYfHlGMWTgOhxOqxDr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1QVbDz6tO6OCFJUwoQolPrbbgzKBnrxXm4oVImiqSuyynLafl3S2irgz3fjR9LsFG gpskkYjYbkfgxHu/c24T3EQ5cmJi3cLS72H0p8/pVgxGsnxs2DxHwbxiUDeU2y5FR/ PxjNpkAD3T8+qJglfC/dRAzoMUnsAmGzz8+Y11GE= 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.14 056/210] fs: dlm: handle -EBUSY first in lock arg validation Date: Mon, 24 Oct 2022 13:29:33 +0200 Message-Id: <20221024112958.837223820@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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?1747573219909611904?= X-GMAIL-MSGID: =?utf-8?q?1747573219909611904?= 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 @@ -2887,24 +2887,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; }