summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorchunx <chunx@nvidia.com>2013-07-05 11:42:05 +0800
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 13:40:37 -0700
commitdb969bbf31dbb79c0f06497f083b4bad16ad88c7 (patch)
tree79b3f7b9091cbb454e70b1b0e28585175daa904c /fs
parentd8461f401990820027131da3ec597361d8906cb8 (diff)
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 <chunx@nvidia.com> Reviewed-on: http://git-master/r/253458 (cherry picked from commit 5dcfe4f561bd8d1767e0938dfd7565b2b7718478) Reviewed-on: http://git-master/r/260013 Reviewed-by: Simone Willett <swillett@nvidia.com> Tested-by: Simone Willett <swillett@nvidia.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/eventpoll.c35
-rw-r--r--fs/proc/base.c9
-rw-r--r--fs/select.c5
3 files changed, 46 insertions, 3 deletions
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 <davidel@xmailserver.org>
*
+ * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
+ *
*/
#include <linux/init.h>
@@ -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 <paul.mundt@nokia.com>:
* Overall revision about smaps.
+ *
+ * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
*/
#include <asm/uaccess.h>
@@ -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 <linux/kernel.h>
@@ -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,