From patchwork Tue Jan 12 21:38:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schumaker, Anna" X-Patchwork-Id: 8021101 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4486DBEEE5 for ; Tue, 12 Jan 2016 21:38:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AC60203B7 for ; Tue, 12 Jan 2016 21:38:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E55FE2041B for ; Tue, 12 Jan 2016 21:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753127AbcALVii (ORCPT ); Tue, 12 Jan 2016 16:38:38 -0500 Received: from mx143.netapp.com ([216.240.21.24]:22492 "EHLO mx143.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752873AbcALViW (ORCPT ); Tue, 12 Jan 2016 16:38:22 -0500 X-IronPort-AV: E=Sophos;i="5.22,285,1449561600"; d="scan'208";a="90492216" Received: from vmwexchts03-prd.hq.netapp.com ([10.122.105.31]) by mx143-out.netapp.com with ESMTP; 12 Jan 2016 13:38:22 -0800 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS03-PRD.hq.netapp.com (10.122.105.31) with Microsoft SMTP Server id 15.0.1130.7; Tue, 12 Jan 2016 13:38:22 -0800 Received: from davros.com ([10.63.231.95]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id u0CLcKmD000200; Tue, 12 Jan 2016 13:38:21 -0800 (PST) From: Anna Schumaker To: , CC: Subject: [PATCH] NFS: Close a race in nfs42_proc_deallocate() Date: Tue, 12 Jan 2016 16:38:18 -0500 Message-ID: <1452634698-16619-1-git-send-email-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.7.0 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to take the i_mutex before writing back the inode to ensure that the file doesn't change before calling DEALLOCATE. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 6e81749..10d8eb4 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -122,8 +122,8 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len) if (!nfs_server_capable(inode, NFS_CAP_DEALLOCATE)) return -EOPNOTSUPP; - nfs_wb_all(inode); mutex_lock(&inode->i_mutex); + nfs_wb_all(inode); err = nfs42_proc_fallocate(&msg, filep, offset, len); if (err == 0)