From patchwork Sat Oct 22 07:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7179 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1088795wrr; Sat, 22 Oct 2022 00:41:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4x87N98ObvV3NL44xNO+UxkQ06U7Q9oJqbhEzFnGvPkMRVa2HeNC9PgWjsHt/b40PePAPq X-Received: by 2002:a65:6e82:0:b0:41a:9b73:f0e6 with SMTP id bm2-20020a656e82000000b0041a9b73f0e6mr19928513pgb.371.1666424475181; Sat, 22 Oct 2022 00:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424475; cv=none; d=google.com; s=arc-20160816; b=zvBVtwv09fifUK9o5cvsykJj45RgusaEgmZyLUfvfHr3xEzLnJFkr0xHjSzWO398RG L0wYNN9MW3mh+VNLcmrbTVWeXUMCY/fcs2XGy12NKrvLRdSFB80nnXsmrGsxjI2GqxuA 2bzi8k1MVaQjfTuyn9gQYEWyFJ6Q0MV+gRLx92AE1ReuiisIZrogunk4aLH+a/Em6C0v DLIaZ9CMQQekuWREiXnmwGHWbF4Q/1ljTlO1QD6Upyw+9hNBPzPpyrU2pRDqicACh5gG IU/vLgnPl+oZSpzkmBRlhhNDZvQBPja+gF0wFXi/prljfqZlBfcaymfvgL77MS40nSYn Bqxg== 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=ZqGnEI4Jq7R6voxy/Op05zxw4aJDgL6TrVylHwgeCw0=; b=rVpx+TBk5ooYPW0ycqZjtr1/m64fxHcCaPwf0+BG7CdeWoaFAOhjzr39RIvsgYeTbu sj9kkZaSwrYg1vhPkJRAXeDgh55RhAXaw1NiJ8QCnsuw0WHAciH0MqKcZsULmB+j1Wjx p7vzlygirk/yY4AaQJy48vSbiDi/gu8AjMrwPCDITgJb+drV+cFPqgQhT9LCs9wewvvC GDg+CTrx9HwYDIbwL1MmEa1mNenHFgnaWHD67hPyLLaV+GD3QsdGTdl1exporzrWJPou 71JXsIVZ5ihFgBBIex+iYMoLdEOTz2HLJiEp1Z06VgyN6aywz9e+v8cq5Bxj6g1LeslN a5ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jrnuaAKw; 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 y65-20020a17090a53c700b00205ef38b646si8708592pjh.80.2022.10.22.00.41.03; Sat, 22 Oct 2022 00:41: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=jrnuaAKw; 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 S230148AbiJVHko (ORCPT + 99 others); Sat, 22 Oct 2022 03:40:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230328AbiJVHjl (ORCPT ); Sat, 22 Oct 2022 03:39:41 -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 B46C92BE883; Sat, 22 Oct 2022 00:37:04 -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 21F6FB82D9F; Sat, 22 Oct 2022 07:37:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74775C433D6; Sat, 22 Oct 2022 07:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424222; bh=armA+utm4/fRQ9XPab00JtG4j1S4Qjzm6rdXp+Ft1Gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jrnuaAKwKnmFiXEGjzDI7hlIBBON1kEW1LAUHickutdSRUhdavq2ZHXw038g8jvgc 5ve65IAOtR0Q/7NyBLwFm7u3R6PJfr4lv4DpSgRFvHnlEprCbd9uJz5Ry0Dz2qygEL Bskp/frFfa4EjnUspUcnCwKEZwAfAqOsR/9YikVo= 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.19 037/717] fs: dlm: handle -EBUSY first in lock arg validation Date: Sat, 22 Oct 2022 09:18:36 +0200 Message-Id: <20221022072421.703068835@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747372710537495652?= X-GMAIL-MSGID: =?utf-8?q?1747372710537495652?= 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 @@ -2920,17 +2920,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; @@ -2940,6 +2932,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;