diff options
| author | Oleg Nesterov <oleg@redhat.com> | 2015-11-06 16:30:06 -0800 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-05-24 02:22:22 +0200 |
| commit | c1a3cb6fad12aca8661ec649de9fec1ee5e6c104 (patch) | |
| tree | 7105c857ac31fbf8717865bea830f897b845d38a /fs/proc | |
| parent | 46dd3cad9b928734e459d5e7c625ab8727b4a39d (diff) | |
UPSTREAM: proc: actually make proc_fd_permission() thread-friendly
(cherry pick from commit 54708d2858e79a2bdda10bf8a20c80eb96c20613)
The commit 96d0df79f264 ("proc: make proc_fd_permission() thread-friendly")
fixed the access to /proc/self/fd from sub-threads, but introduced another
problem: a sub-thread can't access /proc/<tid>/fd/ or /proc/thread-self/fd
if generic_permission() fails.
Change proc_fd_permission() to check same_thread_group(pid_task(), current).
Fixes: 96d0df79f264 ("proc: make proc_fd_permission() thread-friendly")
Reported-by: "Jin, Yihua" <yihua.jin@intel.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Bug: 26016905
Change-Id: I1894c78d0b13f0bde8cde84bd142ba67590dc0f1
Diffstat (limited to 'fs/proc')
| -rw-r--r-- | fs/proc/fd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/proc/fd.c b/fs/proc/fd.c index 7bd032b5b..d8eda9702 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -307,8 +307,11 @@ int proc_fd_permission(struct inode *inode, int mask) rv = generic_permission(inode, mask); if (rv == 0) - return 0; - if (task_tgid(current) == proc_pid(inode)) + return rv; + + rcu_read_lock(); + p = pid_task(proc_pid(inode), PIDTYPE_PID); + if (p && same_thread_group(p, current)) rv = 0; rcu_read_unlock(); |
