aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-07-13 13:26:37 +0400
committerMoyster <oysterized@gmail.com>2019-05-02 15:51:22 +0200
commit4580b5fb67ef2544f0bc391418f762dc62086306 (patch)
tree5abd5b1bfb38f089631aaf16d0b696a16f793fa5 /fs
parent31ac5eeaf0a60910c149731deb4b568b384d7e63 (diff)
Safer ABI for O_TMPFILE
[suggested by Rasmus Villemoes] make O_DIRECTORY | O_RDWR part of O_TMPFILE; that will fail on old kernels in a lot more cases than what I came up with. And make sure O_CREAT doesn't get there... Change-Id: Iaa3c8b487d44515b539150bdb5d0b749b87d3ea2 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c2
-rw-r--r--fs/open.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 36728a45b..c856b49cf 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3075,7 +3075,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
file->f_flags = op->open_flag;
- if (unlikely(file->f_flags & O_TMPFILE)) {
+ if (unlikely(file->f_flags & __O_TMPFILE)) {
error = do_tmpfile(dfd, pathname, nd, flags, op, file, &opened);
goto out;
}
diff --git a/fs/open.c b/fs/open.c
index 39f70342f..c0be2b1d0 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -843,8 +843,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
if (flags & __O_SYNC)
flags |= O_DSYNC;
- if (flags & O_TMPFILE) {
- if (!(flags & O_CREAT))
+ if (flags & __O_TMPFILE) {
+ if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
return -EINVAL;
acc_mode = MAY_OPEN | ACC_MODE(flags);
} else if (flags & O_PATH) {