From db969bbf31dbb79c0f06497f083b4bad16ad88c7 Mon Sep 17 00:00:00 2001 From: chunx Date: Fri, 5 Jul 2013 11:42:05 +0800 Subject: net: show cmdline in /proc/net/{tcp udp tcp6 udp6} Get process's cmdline from a sock's corresponding inode pointer, so that cmdline can't be used by Android active-standby app to find the corresponding package name. Bug 1185001 Change-Id: Idc8651e4bb85b8a152dfade9689a719f7d72687d Signed-off-by: Chun Xu Reviewed-on: http://git-master/r/253458 (cherry picked from commit 5dcfe4f561bd8d1767e0938dfd7565b2b7718478) Reviewed-on: http://git-master/r/260013 Reviewed-by: Simone Willett Tested-by: Simone Willett --- fs/eventpoll.c | 35 ++++++++++++++++++++++++++++++++++- fs/proc/base.c | 9 ++++++++- fs/select.c | 5 ++++- 3 files changed, 46 insertions(+), 3 deletions(-) (limited to 'fs') diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 0cff4434880d..e92a15091d80 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -9,6 +9,8 @@ * * Davide Libenzi * + * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. + * */ #include @@ -967,7 +969,7 @@ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd) * mechanism. It is called by the stored file descriptors when they * have events to report. */ -static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *key) +int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *key) { int pwake = 0; unsigned long flags; @@ -1064,6 +1066,7 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, GFP_KERNEL))) { init_waitqueue_func_entry(&pwq->wait, ep_poll_callback); + pwq->wait.private = get_thread_process(current); pwq->whead = whead; pwq->base = epi; add_wait_queue(whead, &pwq->wait); @@ -1287,6 +1290,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, spin_lock(&tfile->f_lock); list_add_tail(&epi->fllink, &tfile->f_ep_links); spin_unlock(&tfile->f_lock); + tfile->f_path.dentry->d_inode->i_private = get_thread_process(current); /* * Add the current item to the RB tree. All RB tree operations are @@ -1728,6 +1732,35 @@ static void clear_tfile_check_list(void) INIT_LIST_HEAD(&tfile_check_list); } +struct task_struct *get_epoll_file_task(struct file *file) +{ + struct list_head *lh; + struct epitem *epi = NULL; + struct eppoll_entry *pwq = NULL; + struct task_struct *task = NULL; + wait_queue_head_t *whead = NULL; + wait_queue_t *wq = NULL; + + lh = &file->f_ep_links; + if (!list_empty(lh)) { + lh = lh->next; + epi = list_entry(lh, struct epitem, fllink); + lh = &epi->pwqlist; + if (!list_empty(lh)) { + lh = lh->next; + pwq = list_entry(lh, struct eppoll_entry, llink); + lh = &pwq->whead->task_list; + if (!list_empty(lh)) { + lh = lh->next; + wq = list_entry(lh, wait_queue_t, task_list); + task = wq->private; + } + } + } + + return task; +} + /* * Open an eventpoll file descriptor. */ diff --git a/fs/proc/base.c b/fs/proc/base.c index 2d00fdde9345..77377014887c 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -45,6 +45,8 @@ * * Paul Mundt : * Overall revision about smaps. + * + * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. */ #include @@ -206,7 +208,12 @@ static int proc_root_link(struct dentry *dentry, struct path *path) return result; } -static int proc_pid_cmdline(struct task_struct *task, char * buffer) +struct mm_struct *mm_for_maps(struct task_struct *task) +{ + return mm_access(task, PTRACE_MODE_READ); +} + +static int proc_pid_cmdline(struct task_struct *task, char *buffer) { int res = 0; unsigned int len; diff --git a/fs/select.c b/fs/select.c index 6b14dc7df3a4..0595305eeb0a 100644 --- a/fs/select.c +++ b/fs/select.c @@ -12,6 +12,8 @@ * 24 January 2000 * Changed sys_poll()/do_poll() to use PAGE_SIZE chunk-based allocation * of fds to overcome nfds < 16390 descriptors limit (Tigran Aivazian). + * + * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. */ #include @@ -204,7 +206,7 @@ static int __pollwake(wait_queue_t *wait, unsigned mode, int sync, void *key) return default_wake_function(&dummy_wait, mode, sync, key); } -static int pollwake(wait_queue_t *wait, unsigned mode, int sync, void *key) +int pollwake(wait_queue_t *wait, unsigned mode, int sync, void *key) { struct poll_table_entry *entry; @@ -213,6 +215,7 @@ static int pollwake(wait_queue_t *wait, unsigned mode, int sync, void *key) return 0; return __pollwake(wait, mode, sync, key); } +EXPORT_SYMBOL(pollwake); /* Add a new entry */ static void __pollwait(struct file *filp, wait_queue_head_t *wait_address, -- cgit v1.2.3