From patchwork Tue Sep 6 15:12:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9317213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52583607D3 for ; Tue, 6 Sep 2016 15:12:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EA6528DE6 for ; Tue, 6 Sep 2016 15:12:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FF6A28DE7; Tue, 6 Sep 2016 15:12:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D5E328DE5 for ; Tue, 6 Sep 2016 15:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933880AbcIFPMv (ORCPT ); Tue, 6 Sep 2016 11:12:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47404 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933877AbcIFPMu (ORCPT ); Tue, 6 Sep 2016 11:12:50 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F266635D7; Tue, 6 Sep 2016 15:12:45 +0000 (UTC) Received: from tlielax.poochiereds.net (ovpn-116-58.rdu2.redhat.com [10.10.116.58]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u86FCels030277; Tue, 6 Sep 2016 11:12:45 -0400 From: Jeff Layton To: trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 8/9] nfs: ensure that the filehandle in CB_NOTIFY_LOCK request matches the inode Date: Tue, 6 Sep 2016 11:12:39 -0400 Message-Id: <1473174760-29859-9-git-send-email-jlayton@redhat.com> In-Reply-To: <1473174760-29859-1-git-send-email-jlayton@redhat.com> References: <1473174760-29859-1-git-send-email-jlayton@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 06 Sep 2016 15:12:45 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jeff Layton --- fs/nfs/callback_proc.c | 2 +- fs/nfs/nfs4proc.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 4ba6a8763f91..39a34d5083fe 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -645,7 +645,7 @@ __be32 nfs4_callback_notify_lock(struct cb_notify_lock_args *args, void *dummy, fc_tbl = &cps->clp->cl_session->fc_slot_table; status = htonl(NFS4_OK); - __wake_up(&cps->clp->cl_lock_waitq, TASK_NORMAL, 0, &args->cbnl_owner); + __wake_up(&cps->clp->cl_lock_waitq, TASK_NORMAL, 0, args); return status; } #endif /* CONFIG_NFS_V4_1 */ diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3a6669063c44..6829b998776d 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5533,6 +5533,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4 struct nfs4_lock_waiter { struct task_struct *task; + struct inode *inode; struct nfs_lowner *owner; bool notified; }; @@ -5541,8 +5542,10 @@ static int nfs4_wake_lock_waiter(wait_queue_t *wait, unsigned int mode, int flags, void *key) { int ret; + struct cb_notify_lock_args *cbnl = key; struct nfs4_lock_waiter *waiter = wait->private; - struct nfs_lowner *lowner = key, *wowner = waiter->owner; + struct nfs_lowner *lowner = &cbnl->cbnl_owner, + *wowner = waiter->owner; /* Don't wake anybody if the string looked bogus */ if (!lowner->id && !lowner->s_dev) @@ -5554,6 +5557,10 @@ nfs4_wake_lock_waiter(wait_queue_t *wait, unsigned int mode, int flags, void *ke lowner->s_dev != wowner->s_dev) return 0; + /* Make sure it's for the right inode */ + if (nfs_compare_fh(NFS_FH(waiter->inode), &cbnl->cbnl_fh)) + return 0; + waiter->notified = true; /* override "private" so we can use default_wake_function */ @@ -6274,12 +6281,14 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) do { struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner; - struct nfs_server *server = NFS_SERVER(lsp->ls_state->inode); + struct inode *inode = lsp->ls_state->inode; + struct nfs_server *server = NFS_SERVER(inode); struct nfs_client *clp = server->nfs_client; struct nfs_lowner owner = { .clientid = clp->cl_clientid, .id = lsp->ls_seqid.owner_id, .s_dev = server->s_dev }; struct nfs4_lock_waiter waiter = { .task = current, + .inode = inode, .owner = &owner, .notified = false }; wait_queue_t wait;