Commit 8dd138a9 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Ben Hutchings

vfs: canonicalize create mode in build_open_flags()

commit e68726ff upstream.

Userspace can pass weird create mode in open(2) that we canonicalize to
"(mode & S_IALLUGO) | S_IFREG" in vfs_create().

The problem is that we use the uncanonicalized mode before calling vfs_create()
with unforseen consequences.

So do the canonicalization early in build_open_flags().
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Tested-by: default avatarRichard W.M. Jones <rjones@redhat.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent c2cc94c6
...@@ -882,9 +882,10 @@ static inline int build_open_flags(int flags, int mode, struct open_flags *op) ...@@ -882,9 +882,10 @@ static inline int build_open_flags(int flags, int mode, struct open_flags *op)
int lookup_flags = 0; int lookup_flags = 0;
int acc_mode; int acc_mode;
if (!(flags & O_CREAT)) if (flags & O_CREAT)
mode = 0; op->mode = (mode & S_IALLUGO) | S_IFREG;
op->mode = mode; else
op->mode = 0;
/* Must never be set by userspace */ /* Must never be set by userspace */
flags &= ~FMODE_NONOTIFY; flags &= ~FMODE_NONOTIFY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment