fs: completely ignore unknown open flags
authorChristoph Hellwig <hch@lst.de>
Thu, 27 Apr 2017 07:42:25 +0000 (09:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Jul 2017 09:57:44 +0000 (11:57 +0200)
commit 629e014bb8349fcf7c1e4df19a842652ece1c945 upstream.

Currently we just stash anything we got into file->f_flags, and the
report it in fcntl(F_GETFD).  This patch just clears out all unknown
flags so that we don't pass them to the fs or report them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/open.c

index 157b9940dd733b50b0ffe528e2e8c94fe4796ec3..fbc5c7b230b3b6c13560394764af445e1c798513 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -885,6 +885,12 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
        int lookup_flags = 0;
        int acc_mode;
 
+       /*
+        * Clear out all open flags we don't know about so that we don't report
+        * them in fcntl(F_GETFD) or similar interfaces.
+        */
+       flags &= VALID_OPEN_FLAGS;
+
        if (flags & (O_CREAT | __O_TMPFILE))
                op->mode = (mode & S_IALLUGO) | S_IFREG;
        else