From 859dc4e658ca320eed4e8c23cd10328567b399f9 Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Mon, 25 Apr 2016 17:00:08 +0530 Subject: [PATCH 1/2] Revert "misc seq_printf fixes for 4.4" This reverts commit 5c7566a29bff14166d952f2ea525d5231546f821. This patch revert some changes in net/netfilter/xt_qtaguid.c as well. I'll submit another patch to restore those changes. Change-Id: I2d9251867235a6566b4c676de0546ce046848c91 CRs-Fixed: 1035969 Signed-off-by: Amit Pundir Git-commit: cdb6973ae15c5f62947ea7afc29fc1175ecb3172 Git-repo: https://android.googlesource.com/kernel/common/ Signed-off-by: Bryse Flowers --- drivers/misc/uid_stat.c | 3 +-- net/activity_stats.c | 7 ++++--- net/netfilter/xt_qtaguid.c | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/misc/uid_stat.c b/drivers/misc/uid_stat.c index 8b8c9a22360b..4766c1f83b94 100644 --- a/drivers/misc/uid_stat.c +++ b/drivers/misc/uid_stat.c @@ -55,8 +55,7 @@ static int uid_stat_atomic_int_show(struct seq_file *m, void *v) atomic_t *counter = m->private; bytes = (unsigned int) (atomic_read(counter) + INT_MIN); - seq_printf(m, "%u\n", bytes); - return seq_has_overflowed(m) ? -ENOSPC : 0; + return seq_printf(m, "%u\n", bytes); } static int uid_stat_read_atomic_int_open(struct inode *inode, struct file *file) diff --git a/net/activity_stats.c b/net/activity_stats.c index 3bf92d80b8b9..4609ce2043eb 100644 --- a/net/activity_stats.c +++ b/net/activity_stats.c @@ -63,13 +63,14 @@ void activity_stats_update(void) static int activity_stats_show(struct seq_file *m, void *v) { int i; + int ret; seq_printf(m, "Min Bucket(sec) Count\n"); for (i = 0; i < BUCKET_MAX; i++) { - seq_printf(m, "%15d %lu\n", 1 << i, activity_stats[i]); - if (seq_has_overflowed(m)) - return -ENOSPC; + ret = seq_printf(m, "%15d %lu\n", 1 << i, activity_stats[i]); + if (ret) + return ret; } return 0; diff --git a/net/netfilter/xt_qtaguid.c b/net/netfilter/xt_qtaguid.c index e1442bfb668d..04bb081adde8 100644 --- a/net/netfilter/xt_qtaguid.c +++ b/net/netfilter/xt_qtaguid.c @@ -2543,6 +2543,7 @@ static void pp_stats_header(struct seq_file *m) static int pp_stats_line(struct seq_file *m, struct tag_stat *ts_entry, int cnt_set) { + int ret; struct data_counters *cnts; tag_t tag = ts_entry->tn.tag; uid_t stat_uid = get_uid_from_tag(tag); @@ -2561,7 +2562,7 @@ static int pp_stats_line(struct seq_file *m, struct tag_stat *ts_entry, } ppi->item_index++; cnts = &ts_entry->counters; - seq_printf(m, "%d %s 0x%llx %u %u " + ret = seq_printf(m, "%d %s 0x%llx %u %u " "%llu %llu " "%llu %llu " "%llu %llu " @@ -2591,7 +2592,7 @@ static int pp_stats_line(struct seq_file *m, struct tag_stat *ts_entry, cnts->bpc[cnt_set][IFS_TX][IFS_UDP].packets, cnts->bpc[cnt_set][IFS_TX][IFS_PROTO_OTHER].bytes, cnts->bpc[cnt_set][IFS_TX][IFS_PROTO_OTHER].packets); - return seq_has_overflowed(m) ? -ENOSPC : 1; + return ret ?: 1; } static bool pp_sets(struct seq_file *m, struct tag_stat *ts_entry) From ef8f8484c1b6444e7d87b78a49787f28bddd3143 Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Mon, 25 Apr 2016 17:00:31 +0530 Subject: [PATCH 2/2] Revert "misc: uidstat: Remove use of obsolete create_proc_read_entry api" This reverts commit fccab646d33381af63e4f4c0d4f309a1d2b4b0c3. Change-Id: I48bee6e92e4210059aa6e82db4badf24c1cb1546 CRs-Fixed: 1035969 Signed-off-by: Amit Pundir Git-commit: 1ada37dc073ab6e49fd71d2fdc2be2e4f87c56cd Git-repo: https://android.googlesource.com/kernel/common/ Signed-off-by: Bryse Flowers --- drivers/misc/uid_stat.c | 50 ++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/drivers/misc/uid_stat.c b/drivers/misc/uid_stat.c index 4766c1f83b94..509822c81e97 100644 --- a/drivers/misc/uid_stat.c +++ b/drivers/misc/uid_stat.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -49,26 +48,41 @@ static struct uid_stat *find_uid_stat(uid_t uid) { return NULL; } -static int uid_stat_atomic_int_show(struct seq_file *m, void *v) +static int tcp_snd_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) { + int len; unsigned int bytes; - atomic_t *counter = m->private; + char *p = page; + struct uid_stat *uid_entry = (struct uid_stat *) data; + if (!data) + return 0; - bytes = (unsigned int) (atomic_read(counter) + INT_MIN); - return seq_printf(m, "%u\n", bytes); + bytes = (unsigned int) (atomic_read(&uid_entry->tcp_snd) + INT_MIN); + p += sprintf(p, "%u\n", bytes); + len = (p - page) - off; + *eof = (len <= count) ? 1 : 0; + *start = page + off; + return len; } -static int uid_stat_read_atomic_int_open(struct inode *inode, struct file *file) +static int tcp_rcv_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) { - return single_open(file, uid_stat_atomic_int_show, PDE_DATA(inode)); -} + int len; + unsigned int bytes; + char *p = page; + struct uid_stat *uid_entry = (struct uid_stat *) data; + if (!data) + return 0; -static const struct file_operations uid_stat_read_atomic_int_fops = { - .open = uid_stat_read_atomic_int_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; + bytes = (unsigned int) (atomic_read(&uid_entry->tcp_rcv) + INT_MIN); + p += sprintf(p, "%u\n", bytes); + len = (p - page) - off; + *eof = (len <= count) ? 1 : 0; + *start = page + off; + return len; +} /* Create a new entry for tracking the specified uid. */ static struct uid_stat *create_stat(uid_t uid) { @@ -95,11 +109,11 @@ static void create_stat_proc(struct uid_stat *new_uid) entry = proc_mkdir(uid_s, parent); /* Keep reference to uid_stat so we know what uid to read stats from. */ - proc_create_data("tcp_snd", S_IRUGO, entry, - &uid_stat_read_atomic_int_fops, &new_uid->tcp_snd); + create_proc_read_entry("tcp_snd", S_IRUGO, entry , tcp_snd_read_proc, + (void *) new_uid); - proc_create_data("tcp_rcv", S_IRUGO, entry, - &uid_stat_read_atomic_int_fops, &new_uid->tcp_rcv); + create_proc_read_entry("tcp_rcv", S_IRUGO, entry, tcp_rcv_read_proc, + (void *) new_uid); } static struct uid_stat *find_or_create_uid_stat(uid_t uid)