>>> /* We can't create new files, or truncate existing ones here */
What about this one?
--
Regards
Bian Naimeng
-------------------------------------------------------------------------------------
We we open a positive file just with O_EXCL but no O_CREAT, may cause kernel crash.
Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>
---
fs/namei.c | 7 +++----
fs/nfs/dir.c | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/namei.c b/fs/namei.c
index 17ea76b..6680a38 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1813,11 +1813,10 @@ reval:
nd.intent.open.create_mode = mode;
nd.flags &= ‾LOOKUP_PARENT;
nd.flags |= LOOKUP_OPEN;
- if (open_flag & O_CREAT) {
+ if (open_flag & O_CREAT)
nd.flags |= LOOKUP_CREATE;
- if (open_flag & O_EXCL)
- nd.flags |= LOOKUP_EXCL;
- }
+ if (open_flag & O_EXCL)
+ nd.flags |= LOOKUP_EXCL;
if (open_flag & O_DIRECTORY)
nd.flags |= LOOKUP_DIRECTORY;
if (!(open_flag & O_NOFOLLOW))
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 29539ce..bc25da9 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1100,7 +1100,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
goto no_open_dput;
openflags = nd->intent.open.flags;
/* We cannot do exclusive creation on a positive dentry */
- if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
+ if (nd->flags & LOOKUP_EXCL)
goto no_open_dput;
/* We can't create new files, or truncate existing ones here */
openflags &= ‾(O_CREAT|O_TRUNC);
--
1.7.0
--