From patchwork Wed Jun 15 20:05:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9179265 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 CE49960776 for ; Wed, 15 Jun 2016 20:06:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB7FA27DCE for ; Wed, 15 Jun 2016 20:06:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B06C127F07; Wed, 15 Jun 2016 20:06:08 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 34F1027DCE for ; Wed, 15 Jun 2016 20:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933036AbcFOUGG (ORCPT ); Wed, 15 Jun 2016 16:06:06 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:34451 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933028AbcFOUGE (ORCPT ); Wed, 15 Jun 2016 16:06:04 -0400 Received: by mail-it0-f65.google.com with SMTP id d71so4758765ith.1 for ; Wed, 15 Jun 2016 13:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=Q55pfZR3p0HuNp/ik6m1yOcxHKdsytRAR6Q7p8sd7Cc=; b=eihMmAf61D+/TA2V5ZsQhdOoXZq5l1ncW2oPZZrjDO0j0zkznWgfuY9T1eKYIFzyuh jiy3HWsSPz7yPMaRVX0Nx6/kR24f1qtR8hKkJVc/X6EUYvHW+ghBqPBsuxK8XwFv5OYW O0KpH/zvQWQujbx2ewlJ/00hByRkR/xg+0K/7Nb/AW6yFzGxpN/5r8+QEvvWB5lx8WPw YwrWrAhnD7VVhejZ+uwaW93OKxUqshAfJSuUxaFQVzlBNH2eU5FNVnssBzNJ3LGiYzxS UN6QvDRzLsgmQnDJ0dCJ+Mss6G9sOf5bM+DA1KtnUaJTD3UFgQRx/HZWMCnleo+rSodU OhXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=Q55pfZR3p0HuNp/ik6m1yOcxHKdsytRAR6Q7p8sd7Cc=; b=JaDT7NDNp+tGJSEW27ihK6mNyDOAnVJ9xLQffk8Rx28qOoo44QfqLPK2XAD4m+BgTn j9GXA/SO0esWg2961fBRq8ubTm6+/bqEiBciLSDQPP3+8X4fpT7fIv33KOwEHn85CJTa O9Nu2gGJGW7XUuOqxf00ocBGGlLNCj7gtDfRKqygVSZMQmwLF0w9l4qr4GkbcCx1J7kO 7IQlyHevuHnTEED0wGFK1KzYLgBM3la6KY7qJw0zLFxJYN06KlgNHDn1l9qrXq7ReCF4 poZ1AQgeXE4TDhx6flDRBs6vMSQbwSyQwAWU1TtJqiigD5qgz+6Byo6nNB2DPqxiF68R YSig== X-Gm-Message-State: ALyK8tJaRfMcXPhiRjvWfykV4Si7iVQwOQAsRIRLVHJFCDZj3JfX3FSqqgyzhS/I394LiQ== X-Received: by 10.36.10.65 with SMTP id 62mr19676281itw.89.1466021158752; Wed, 15 Jun 2016 13:05:58 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id d200sm17778551ioe.19.2016.06.15.13.05.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jun 2016 13:05:57 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Fix potential race in nfs_fhget() Date: Wed, 15 Jun 2016 16:05:28 -0400 Message-Id: <1466021128-62407-1-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.5.5 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 If we don't set the mode correctly in nfs_init_locked(), then there is potential for a race with a second call to nfs_fhget that will cause inode aliasing. Signed-off-by: Trond Myklebust Reviewed-by: Jeff Layton --- fs/nfs/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 52e7d6869e3b..dda689d7a8a7 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -282,6 +282,7 @@ nfs_init_locked(struct inode *inode, void *opaque) struct nfs_fattr *fattr = desc->fattr; set_nfs_fileid(inode, fattr->fileid); + inode->i_mode = fattr->mode; nfs_copy_fh(NFS_FH(inode), desc->fh); return 0; }