Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp642952rwb; Sun, 6 Nov 2022 11:17:54 -0800 (PST) X-Google-Smtp-Source: AMsMyM6P0kvyqiWiReAzQbx1Qn0Q2hkBpAm94FfOHIyW/n7Oc+HY+z8LWrVdPCaWwi45bg4q1VlZ X-Received: by 2002:a17:90b:1c11:b0:213:2253:fa7a with SMTP id oc17-20020a17090b1c1100b002132253fa7amr48741231pjb.111.1667762273960; Sun, 06 Nov 2022 11:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667762273; cv=none; d=google.com; s=arc-20160816; b=sVNe5Of+H9zrppEUTdKvuJJzBAazk65YH/BxRbuzgswEOTBe661wD0wy/dlkBpQPp4 MhRIpKENzyU+ABxREd+gs2pbshg9grZJMPq2kQ6Kqzild9fARuVh00NvdTE5NQhcG3uH qcoMDWPxsGuvISBiaFiOoukQ9J2O/fGQuyzZPG/N/qxaNmPS/g8dnyuL3BmWF8DOPykZ L4206DaBEt9J8w3KPW+wEBfrSOqICR8eJ4uC4Mr0iA351ZBqL7hOcTOgWjDV0aMuwdQm wEVVOLmlEgMzZ94bSk2Fikpvuwv2vDOOt24Lwc+jSUro77SEhstTgqUeQUwjw1HJR0TB ectw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=FJOAjX9rnRmeo2wXM2sCiKZhTSjqhqp8Faugkt7ehMU=; b=b+4meZPPIWTHyRO36SMmz9PlIn8HwSaiQenIWclOvypr42lWeXOKAQoM8FaHJTdJTg HhGVOs5JcXB4yIpwUkcoBjU3qHqoyJJ3ZCcfMD1ap6FAmVoStfXU5lG1ywgiPHxC27rv xY8XJuKS4BnKWo2xyGC4GmPKMDMpZTI4YuoIUQVWx2nAqn2Bi9s2uUgEISqHUIAqCKPH cBr1ep+fSUXlHJKGf7i56IAnfQ/xbnvj7GW630cW7h1G1tn1Y1Hep2W9CFXeg9zP7WSS I1hq1LFAv7QuYevyOq05ZQs1Z+oRXkZBQPyzGGJ+6nVxJMpGlMw/MRCIEzpsaFQxvZqG eZuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AmvB2Okb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020aa79548000000b00542f9f272ffsi6697462pfq.18.2022.11.06.11.17.24; Sun, 06 Nov 2022 11:17:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@kernel.org header.s=k20201202 header.b=AmvB2Okb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbiKFTJI (ORCPT + 99 others); Sun, 6 Nov 2022 14:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbiKFTJI (ORCPT ); Sun, 6 Nov 2022 14:09:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 295206464 for ; Sun, 6 Nov 2022 11:09:07 -0800 (PST) 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 B5C5460CF5 for ; Sun, 6 Nov 2022 19:09:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C106CC433D6; Sun, 6 Nov 2022 19:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667761746; bh=QunM5lI6lxdAhZd95G3NK9COwpbDdh+RMwxj3rOUJwg=; h=From:To:Cc:Subject:Date:From; b=AmvB2OkbuSVezfseVmd/2dVOVAHx/xvBg8h071tzpnnXbLjuWCeoIvD1gZAUFD2gM RvoBAWTmQlx6hLFBDDdQgQBr/3Dpf0cqukCDfRUYFiptlVOOjFjCfd4Z33pgTcCfKO rfcKrD/2xWDUkuh2zDf9P8Iuw3Pnhvvcpk/+YsUuJ+DG2KnVlaqxuZBhQr4uSvOTQW 1pY2Fvz4EvkOUmhqd8pSROHGbzVmbmoalcccaW3yUxNpemK8BYrKYPcl2QdnVIBmVA g9qHwOXilYHM0G2/W8DVWEJpeE5FJCmhbQskZMNkuaKjtsXQhx3j6jN2J2j2g2wULc e6qGsrfoQ6/Fg== From: trondmy@kernel.org To: Chuck Lever Cc: Jeff Layton , linux-nfs@vger.kernel.org Subject: [PATCH] lockd: set other missing fields when unlocking files Date: Sun, 6 Nov 2022 14:02:39 -0500 Message-Id: <20221106190239.404803-1-trondmy@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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-nfs@vger.kernel.org From: Trond Myklebust vfs_lock_file() expects the struct file_lock to be fully initialised by the caller. Re-exported NFSv3 has been seen to Oops if the fl_file field is NULL. Fixes: aec158242b87 ("lockd: set fl_owner when unlocking files") Signed-off-by: Trond Myklebust --- fs/lockd/svcsubs.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index e1c4617de771..3515f17eaf3f 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -176,7 +176,7 @@ nlm_delete_file(struct nlm_file *file) } } -static int nlm_unlock_files(struct nlm_file *file, fl_owner_t owner) +static int nlm_unlock_files(struct nlm_file *file, const struct file_lock *fl) { struct file_lock lock; @@ -184,12 +184,15 @@ static int nlm_unlock_files(struct nlm_file *file, fl_owner_t owner) lock.fl_type = F_UNLCK; lock.fl_start = 0; lock.fl_end = OFFSET_MAX; - lock.fl_owner = owner; - if (file->f_file[O_RDONLY] && - vfs_lock_file(file->f_file[O_RDONLY], F_SETLK, &lock, NULL)) + lock.fl_owner = fl->fl_owner; + lock.fl_pid = fl->fl_pid; + lock.fl_flags = FL_POSIX; + + lock.fl_file = file->f_file[O_RDONLY]; + if (lock.fl_file && vfs_lock_file(lock.fl_file, F_SETLK, &lock, NULL)) goto out_err; - if (file->f_file[O_WRONLY] && - vfs_lock_file(file->f_file[O_WRONLY], F_SETLK, &lock, NULL)) + lock.fl_file = file->f_file[O_WRONLY]; + if (lock.fl_file && vfs_lock_file(lock.fl_file, F_SETLK, &lock, NULL)) goto out_err; return 0; out_err: @@ -226,7 +229,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file, if (match(lockhost, host)) { spin_unlock(&flctx->flc_lock); - if (nlm_unlock_files(file, fl->fl_owner)) + if (nlm_unlock_files(file, fl)) return 1; goto again; } -- 2.38.1