vfs: canonicalize create mode in build_open_flags()
authorMiklos Szeredi <mszeredi@suse.cz>
Wed, 15 Aug 2012 11:01:24 +0000 (13:01 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 12 Sep 2012 02:37:03 +0000 (03:37 +0100)
commit8dd138a98241fc7be5d89950e6e09bbc18024a53
treefeb5548ccc04acb54d635bfb29f8b3c7ae49bc78
parentc2cc94c67ca8e3c496a790d631fd1ac38d31d522
vfs: canonicalize create mode in build_open_flags()

commit e68726ff72cf7ba5e7d789857fcd9a75ca573f03 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: Miklos Szeredi <mszeredi@suse.cz>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/open.c