From: Al Viro <viro@zeniv.linux.org.uk>
Date: Sun, 26 Aug 2012 15:01:04 +0000 (-0400)
Subject: don't leak O_CLOEXEC into ->f_flags
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c6f3d81115989e274c42a852222b80d2e14ced6f;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git

don't leak O_CLOEXEC into ->f_flags

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---

diff --git a/fs/open.c b/fs/open.c
index 30760017deed..03028d0e7487 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -814,7 +814,7 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
 		op->mode = 0;
 
 	/* Must never be set by userspace */
-	flags &= ~FMODE_NONOTIFY;
+	flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
 
 	/*
 	 * O_SYNC is implemented as __O_SYNC|O_DSYNC.  As many places only
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 9cef449c0f76..f28a875f8779 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -36,7 +36,7 @@ static int seq_show(struct seq_file *m, void *v)
 		if (file) {
 			struct fdtable *fdt = files_fdtable(files);
 
-			f_flags = file->f_flags & ~O_CLOEXEC;
+			f_flags = file->f_flags;
 			if (close_on_exec(fd, fdt))
 				f_flags |= O_CLOEXEC;