From patchwork Fri Sep 9 18:48:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9324155 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 AED59607D3 for ; Fri, 9 Sep 2016 18:48:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A37F629ED4 for ; Fri, 9 Sep 2016 18:48:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9844629EDA; Fri, 9 Sep 2016 18:48:23 +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 464FA29ED4 for ; Fri, 9 Sep 2016 18:48:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754432AbcIISsW (ORCPT ); Fri, 9 Sep 2016 14:48:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44712 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754231AbcIISsW (ORCPT ); Fri, 9 Sep 2016 14:48:22 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 CEFC543A37; Fri, 9 Sep 2016 18:48:21 +0000 (UTC) Received: from tlielax.poochiereds.net (ovpn-116-60.rdu2.redhat.com [10.10.116.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u89ImLBF021438; Fri, 9 Sep 2016 14:48:21 -0400 From: Jeff Layton To: trond.myklebust@primarydata.com, Anna.Schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 10/10] nfs: ensure that the filehandle in CB_NOTIFY_LOCK request matches the inode Date: Fri, 9 Sep 2016 14:48:20 -0400 Message-Id: <1473446900-1897-1-git-send-email-jlayton@redhat.com> In-Reply-To: <1473446870-1831-1-git-send-email-jlayton@redhat.com> References: <1473446870-1831-1-git-send-email-jlayton@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 09 Sep 2016 18:48:21 +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 | 3 +-- fs/nfs/nfs4proc.c | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 590ed26232cc..478636b59d32 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -642,8 +642,7 @@ __be32 nfs4_callback_notify_lock(struct cb_notify_lock_args *args, void *dummy, /* Don't wake anybody if the string looked bogus */ if (lowner->id || lowner->s_dev) - __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 htonl(NFS4_OK); } diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 2271c44aff32..71325fc8c650 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6189,6 +6189,7 @@ nfs4_retry_setlk_simple(struct nfs4_state *state, int cmd, #ifdef CONFIG_NFS_V4_1 struct nfs4_lock_waiter { struct task_struct *task; + struct inode *inode; struct nfs_lowner *owner; bool notified; }; @@ -6197,8 +6198,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; /* Only wake if the callback was for the same owner */ if (lowner->clientid != wowner->clientid || @@ -6206,6 +6209,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 */ @@ -6228,6 +6235,7 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) .id = lsp->ls_seqid.owner_id, .s_dev = server->s_dev }; struct nfs4_lock_waiter waiter = { .task = current, + .inode = state->inode, .owner = &owner, .notified = false }; wait_queue_t wait;