Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1702811pxb; Thu, 16 Sep 2021 13:24:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2LMQv8hcY/oMg6KJMi0PSqbw94GOl1DqKrhqME41IWomBcIkDL/qcZLll2x8tbv8WizP+ X-Received: by 2002:a5d:9693:: with SMTP id m19mr5876452ion.72.1631823882577; Thu, 16 Sep 2021 13:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823882; cv=none; d=google.com; s=arc-20160816; b=sBRUDM41EiFd8oP6QH7OaGx2R1oNQWLveVLJ0hGgaDkHR5bLyzhyDX6qJEQ59m5t6m 57pL8Faw+CfcSG++jouBxuCF8GFcWBbywOkO0PGTQ8rqrs3dNDxIFNMXt9EwF+966Wvm PaUBsPFYTKG2vx4qo5RekSvO6Jii3kFpZDneetQour6i2mn6jC3CwQTzblCYg0EmqjKq obUjlBZRJ96dvzIV8FrZ42962jyQ9ylDxw6F0Umc7Bt+3BaU6KI4unpTKj+UlMLzkwp4 iEVNukvnOwU8K2q45QoCtqqXRHZwiWTAtXOmNc9IUA7H5A11SzCCyJ7P7PwF8ama80WT Ydew== 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=npPUwgTUrC1HlpTDYu0fv6HK06AjO/T6q7lw1QRSgOE=; b=lA8pqpE3jr9g3BzbVz4cswORIkbaYAYHdRJsLYH5KtdiVtDOVyrCvPB5c3qq3V57w2 3720aPNUSzYLy1gsmIkVjq42MO22ar/LJoVYCj36FDP4e7vVQ2aInQeFwuMyeTTyylVl gnotYPMe3CvA0APPpKGXtAjy2Eh2CNxmlYdVPu1hVyJHnbRifGVrxM8IBYC4gAlIqP9X r5eiIMw1eDZJ8TZBIP4oFsPcX/6ExOCLx/A9vLckTZ8+H4MFW8OTwVvAH7JbpjarhlvI yegSomPpxPRHN+2ULsWuNPpy/wkc6O95urx5M7l49Gf61bcAJK95XPWUVkNToi1Yfx5b jDWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tp7bZBg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si332060jal.61.2021.09.16.13.24.29; Thu, 16 Sep 2021 13:24:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tp7bZBg7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S241600AbhIPQ14 (ORCPT + 99 others); Thu, 16 Sep 2021 12:27:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:55356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241513AbhIPQTm (ORCPT ); Thu, 16 Sep 2021 12:19:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3DD556139D; Thu, 16 Sep 2021 16:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808820; bh=6LOksXce/k5HvDLNXSjLG9Te585jaGoi0SD0jX9pYW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tp7bZBg7VooBOUSU3EW1o/RtZx2mOjdpCUK57kwAkDQehOPsT82IeQdWUqWkAZdU0 LA9KCVdMIFSpE2juZNbN+tvUGgO095M8Gk5dSPJS7MEkYhkHn1yt1AqPuNBWQC+BIW QPY7J2r9Q6fGzgl0tBfMsq6FlNTpesb8+D4o1/tU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daire Byrne , "J. Bruce Fields" , Chuck Lever , Sasha Levin Subject: [PATCH 5.10 234/306] lockd: lockd server-side shouldnt set fl_ops Date: Thu, 16 Sep 2021 17:59:39 +0200 Message-Id: <20210916155802.026297868@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: J. Bruce Fields [ Upstream commit 7de875b231edb807387a81cde288aa9e1015ef9e ] Locks have two sets of op arrays, fl_lmops for the lock manager (lockd or nfsd), fl_ops for the filesystem. The server-side lockd code has been setting its own fl_ops, which leads to confusion (and crashes) in the reexport case, where the filesystem expects to be the only one setting fl_ops. And there's no reason for it that I can see-the lm_get/put_owner ops do the same job. Reported-by: Daire Byrne Tested-by: Daire Byrne Signed-off-by: J. Bruce Fields Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/lockd/svclock.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 498cb70c2c0d..273a81971ed5 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -395,28 +395,10 @@ nlmsvc_release_lockowner(struct nlm_lock *lock) nlmsvc_put_lockowner(lock->fl.fl_owner); } -static void nlmsvc_locks_copy_lock(struct file_lock *new, struct file_lock *fl) -{ - struct nlm_lockowner *nlm_lo = (struct nlm_lockowner *)fl->fl_owner; - new->fl_owner = nlmsvc_get_lockowner(nlm_lo); -} - -static void nlmsvc_locks_release_private(struct file_lock *fl) -{ - nlmsvc_put_lockowner((struct nlm_lockowner *)fl->fl_owner); -} - -static const struct file_lock_operations nlmsvc_lock_ops = { - .fl_copy_lock = nlmsvc_locks_copy_lock, - .fl_release_private = nlmsvc_locks_release_private, -}; - void nlmsvc_locks_init_private(struct file_lock *fl, struct nlm_host *host, pid_t pid) { fl->fl_owner = nlmsvc_find_lockowner(host, pid); - if (fl->fl_owner != NULL) - fl->fl_ops = &nlmsvc_lock_ops; } /* @@ -788,9 +770,21 @@ nlmsvc_notify_blocked(struct file_lock *fl) printk(KERN_WARNING "lockd: notification for unknown block!\n"); } +static fl_owner_t nlmsvc_get_owner(fl_owner_t owner) +{ + return nlmsvc_get_lockowner(owner); +} + +static void nlmsvc_put_owner(fl_owner_t owner) +{ + nlmsvc_put_lockowner(owner); +} + const struct lock_manager_operations nlmsvc_lock_operations = { .lm_notify = nlmsvc_notify_blocked, .lm_grant = nlmsvc_grant_deferred, + .lm_get_owner = nlmsvc_get_owner, + .lm_put_owner = nlmsvc_put_owner, }; /* -- 2.30.2