From: ChenXiaoSong <chenxiaosong2@huawei.com>
To: <trond.myklebust@hammerspace.com>, <anna@kernel.org>,
<bjschuma@netapp.com>
Cc: <linux-nfs@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chenxiaosong2@huawei.com>, <liuyongqiang13@huawei.com>,
<yi.zhang@huawei.com>, <zhangxiaoxu5@huawei.com>,
<tao.lyu@epfl.ch>
Subject: [PATCH -next 1/2] Revert "NFSv4: Handle the special Linux file open access mode"
Date: Tue, 29 Mar 2022 19:32:07 +0800 [thread overview]
Message-ID: <20220329113208.2466000-2-chenxiaosong2@huawei.com> (raw)
In-Reply-To: <20220329113208.2466000-1-chenxiaosong2@huawei.com>
This reverts commit 44942b4e457beda00981f616402a1a791e8c616e.
After secondly opening a file with O_ACCMODE|O_DIRECT flags,
nfs4_valid_open_stateid() will dereference NULL nfs4_state when lseek().
Reproducer:
1. mount -t nfs -o vers=4.2 $server_ip:/ /mnt/
2. fd = open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT)
3. close(fd)
4. fd = open("/mnt/file", O_ACCMODE|O_DIRECT)
5. lseek(fd)
Reported-by: Lyu Tao <tao.lyu@epfl.ch>
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
---
fs/nfs/inode.c | 1 -
fs/nfs/nfs4file.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 3351c2de3e08..bb91b228f1e5 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp)
nfs_fscache_open_file(inode, filp);
return 0;
}
-EXPORT_SYMBOL_GPL(nfs_open);
/*
* This function is called whenever some part of NFS notices that
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index e79ae4cbc395..c178db86a6e8 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -51,7 +51,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
return err;
if ((openflags & O_ACCMODE) == 3)
- return nfs_open(inode, filp);
+ openflags--;
/* We can't create new files here */
openflags &= ~(O_CREAT|O_EXCL);
--
2.31.1
next prev parent reply other threads:[~2022-03-29 11:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-29 11:32 [PATCH -next 0/2] fix nfsv4 bugs of opening with O_ACCMODE flag ChenXiaoSong
2022-03-29 11:32 ` ChenXiaoSong [this message]
2022-03-29 11:32 ` [PATCH -next 2/2] NFSv4: fix open failure " ChenXiaoSong
2022-03-29 13:05 ` Trond Myklebust
2022-03-29 13:44 ` chenxiaosong (A)
2022-03-29 13:56 ` Trond Myklebust
2022-03-29 14:32 ` [PATCH -next 0/2] fix nfsv4 bugs of opening " chenxiaosong (A)
[not found] ` <e0c2d7ec62b447cabddbc8a9274be955@epfl.ch>
2022-04-13 13:42 ` chenxiaosong (A)
2022-04-13 14:05 ` chenxiaosong (A)
2022-04-13 14:34 ` chenxiaosong (A)
[not found] ` <3ee78045f18b4932b1651de776ee73c4@epfl.ch>
2022-04-13 14:42 ` chenxiaosong (A)
[not found] ` <55415e44b4b04bbfa66c42d5f2788384@epfl.ch>
2022-04-14 2:41 ` chenxiaosong (A)
2022-04-14 7:33 ` Lyu Tao
2022-05-05 2:48 ` chenxiaosong (A)
2022-05-06 7:40 ` Lyu Tao
2022-05-31 6:40 ` chenxiaosong (A)
2022-05-31 8:16 ` Lyu Tao
2022-05-31 8:47 ` chenxiaosong (A)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220329113208.2466000-2-chenxiaosong2@huawei.com \
--to=chenxiaosong2@huawei.com \
--cc=anna@kernel.org \
--cc=bjschuma@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=liuyongqiang13@huawei.com \
--cc=tao.lyu@epfl.ch \
--cc=trond.myklebust@hammerspace.com \
--cc=yi.zhang@huawei.com \
--cc=zhangxiaoxu5@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox