1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-15 11:03:37 +03:00
mobile-nixos/devices/asus-z00t/kernel/0001-Revert-misc-uidstat-change-release-handler-for-stat-.patch
Samuel Dionne-Riel fb79113a00 asus-z00t: Fixes compilation with USER_NS
This is dumb... These are all android/google/qualcomm/asus "features"
added to the kernel with no concern about actually being compatible
with the kernel. They all assume no USER_NS stuff.

Fun!
2019-10-09 22:12:48 -04:00

502 lines
14 KiB
Diff

From 01129f192beb09cd31bef20320b10167c10b3a23 Mon Sep 17 00:00:00 2001
From: Samuel Dionne-Riel <samuel@dionne-riel.com>
Date: Wed, 9 Oct 2019 21:04:14 -0400
Subject: [PATCH] Revert "misc: uidstat: change release handler for stat read
operation"
This reverts commit 0dcb3df744e01e8d6588f5eecfe6a510c4ce95d6.
Revert "misc: uidstat: Remove use of obsolete create_proc_read_entry api"
This reverts commit 6908fe248fc3e976363807985478871106b22a19.
Revert "net: activity_stats: Stop using obsolete create_proc_read_entry api"
This reverts commit 4af1c50c2b8d5cb96ee803cc8c8d969708130509.
Revert "misc: uidstat: avoid create_stat() race and blockage."
This reverts commit 760017d10ac80defe7fa9ad12aebf36ced5f3119.
Revert "net: activity_stats: Add statistics for network transmission activity"
This reverts commit 1f65785d2b92ccad4ebab8f0b39c9e232d76946f.
Revert "misc: uidstat: Adding uid stat driver to collect network statistics."
This reverts commit 5a5f2f9219cf1df0cbd14542c5c709e34653d7f9.
---
drivers/misc/Kconfig | 4 -
drivers/misc/Makefile | 1 -
drivers/misc/uid_stat.c | 152 -----------------------------------
include/linux/uid_stat.h | 29 -------
include/net/activity_stats.h | 25 ------
net/Kconfig | 8 --
net/Makefile | 1 -
net/activity_stats.c | 119 ---------------------------
net/ipv4/tcp.c | 10 ---
9 files changed, 349 deletions(-)
delete mode 100644 drivers/misc/uid_stat.c
delete mode 100644 include/linux/uid_stat.h
delete mode 100644 include/net/activity_stats.h
delete mode 100644 net/activity_stats.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index f159fff09bf..803b65906ca 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -434,10 +434,6 @@ config TI_DAC7512
This driver can also be built as a module. If so, the module
will be called ti_dac7512.
-config UID_STAT
- bool "UID based statistics tracking exported to /proc/uid_stat"
- default n
-
config VMWARE_BALLOON
tristate "VMware Balloon Driver"
depends on X86 && HYPERVISOR_GUEST
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index a53a897faab..e4d3c0346a0 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -38,7 +38,6 @@ obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o
obj-$(CONFIG_DS1682) += ds1682.o
obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o
-obj-$(CONFIG_UID_STAT) += uid_stat.o
obj-$(CONFIG_C2PORT) += c2port/
obj-$(CONFIG_HMC6352) += hmc6352.o
obj-y += eeprom/
diff --git a/drivers/misc/uid_stat.c b/drivers/misc/uid_stat.c
deleted file mode 100644
index 27b516b8a90..00000000000
--- a/drivers/misc/uid_stat.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/* drivers/misc/uid_stat.c
- *
- * Copyright (C) 2008 - 2009 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#include <asm/atomic.h>
-
-#include <linux/err.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/stat.h>
-#include <linux/uid_stat.h>
-#include <net/activity_stats.h>
-
-static DEFINE_SPINLOCK(uid_lock);
-static LIST_HEAD(uid_list);
-static struct proc_dir_entry *parent;
-
-struct uid_stat {
- struct list_head link;
- uid_t uid;
- atomic_t tcp_rcv;
- atomic_t tcp_snd;
-};
-
-static struct uid_stat *find_uid_stat(uid_t uid) {
- struct uid_stat *entry;
-
- list_for_each_entry(entry, &uid_list, link) {
- if (entry->uid == uid) {
- return entry;
- }
- }
- return NULL;
-}
-
-static int uid_stat_atomic_int_show(struct seq_file *m, void *v)
-{
- unsigned int bytes;
- atomic_t *counter = m->private;
-
- bytes = (unsigned int) (atomic_read(counter) + INT_MIN);
- return seq_printf(m, "%u\n", bytes);
-}
-
-static int uid_stat_read_atomic_int_open(struct inode *inode, struct file *file)
-{
- return single_open(file, uid_stat_atomic_int_show, PDE_DATA(inode));
-}
-
-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 = single_release,
-};
-
-/* Create a new entry for tracking the specified uid. */
-static struct uid_stat *create_stat(uid_t uid) {
- struct uid_stat *new_uid;
- /* Create the uid stat struct and append it to the list. */
- new_uid = kmalloc(sizeof(struct uid_stat), GFP_ATOMIC);
- if (!new_uid)
- return NULL;
-
- new_uid->uid = uid;
- /* Counters start at INT_MIN, so we can track 4GB of network traffic. */
- atomic_set(&new_uid->tcp_rcv, INT_MIN);
- atomic_set(&new_uid->tcp_snd, INT_MIN);
-
- list_add_tail(&new_uid->link, &uid_list);
- return new_uid;
-}
-
-static void create_stat_proc(struct uid_stat *new_uid)
-{
- char uid_s[32];
- struct proc_dir_entry *entry;
- sprintf(uid_s, "%d", new_uid->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);
-
- proc_create_data("tcp_rcv", S_IRUGO, entry,
- &uid_stat_read_atomic_int_fops, &new_uid->tcp_rcv);
-}
-
-static struct uid_stat *find_or_create_uid_stat(uid_t uid)
-{
- struct uid_stat *entry;
- unsigned long flags;
- spin_lock_irqsave(&uid_lock, flags);
- entry = find_uid_stat(uid);
- if (entry) {
- spin_unlock_irqrestore(&uid_lock, flags);
- return entry;
- }
- entry = create_stat(uid);
- spin_unlock_irqrestore(&uid_lock, flags);
- if (entry)
- create_stat_proc(entry);
- return entry;
-}
-
-int uid_stat_tcp_snd(uid_t uid, int size) {
- struct uid_stat *entry;
- activity_stats_update();
- entry = find_or_create_uid_stat(uid);
- if (!entry)
- return -1;
- atomic_add(size, &entry->tcp_snd);
- return 0;
-}
-
-int uid_stat_tcp_rcv(uid_t uid, int size) {
- struct uid_stat *entry;
- activity_stats_update();
- entry = find_or_create_uid_stat(uid);
- if (!entry)
- return -1;
- atomic_add(size, &entry->tcp_rcv);
- return 0;
-}
-
-static int __init uid_stat_init(void)
-{
- parent = proc_mkdir("uid_stat", NULL);
- if (!parent) {
- pr_err("uid_stat: failed to create proc entry\n");
- return -1;
- }
- return 0;
-}
-
-__initcall(uid_stat_init);
diff --git a/include/linux/uid_stat.h b/include/linux/uid_stat.h
deleted file mode 100644
index 6bd6c4e52d1..00000000000
--- a/include/linux/uid_stat.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* include/linux/uid_stat.h
- *
- * Copyright (C) 2008-2009 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#ifndef __uid_stat_h
-#define __uid_stat_h
-
-/* Contains definitions for resource tracking per uid. */
-
-#ifdef CONFIG_UID_STAT
-int uid_stat_tcp_snd(uid_t uid, int size);
-int uid_stat_tcp_rcv(uid_t uid, int size);
-#else
-#define uid_stat_tcp_snd(uid, size) do {} while (0);
-#define uid_stat_tcp_rcv(uid, size) do {} while (0);
-#endif
-
-#endif /* _LINUX_UID_STAT_H */
diff --git a/include/net/activity_stats.h b/include/net/activity_stats.h
deleted file mode 100644
index 10e4c1506ee..00000000000
--- a/include/net/activity_stats.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2010 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Author: Mike Chan (mike@android.com)
- */
-
-#ifndef __activity_stats_h
-#define __activity_stats_h
-
-#ifdef CONFIG_NET_ACTIVITY_STATS
-void activity_stats_update(void);
-#else
-#define activity_stats_update(void) {}
-#endif
-
-#endif /* _NET_ACTIVITY_STATS_H */
diff --git a/net/Kconfig b/net/Kconfig
index b9d1e6929cd..77d7f381c0a 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -87,14 +87,6 @@ config ANDROID_PARANOID_NETWORK
help
none
-config NET_ACTIVITY_STATS
- bool "Network activity statistics tracking"
- default y
- help
- Network activity statistics are useful for tracking wireless
- modem activity on 2G, 3G, 4G wireless networks. Counts number of
- transmissions and groups them in specified time buckets.
-
config NETWORK_SECMARK
bool "Security Marking"
help
diff --git a/net/Makefile b/net/Makefile
index 7878913abba..27336ffefa7 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -70,6 +70,5 @@ obj-$(CONFIG_BATMAN_ADV) += batman-adv/
obj-$(CONFIG_NFC) += nfc/
obj-$(CONFIG_OPENVSWITCH) += openvswitch/
obj-$(CONFIG_VSOCKETS) += vmw_vsock/
-obj-$(CONFIG_NET_ACTIVITY_STATS) += activity_stats.o
obj-$(CONFIG_RMNET_DATA) += rmnet_data/
obj-$(CONFIG_IPC_ROUTER) += ipc_router/
diff --git a/net/activity_stats.c b/net/activity_stats.c
deleted file mode 100644
index 4609ce2043e..00000000000
--- a/net/activity_stats.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* net/activity_stats.c
- *
- * Copyright (C) 2010 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Author: Mike Chan (mike@android.com)
- */
-
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/suspend.h>
-#include <net/net_namespace.h>
-
-/*
- * Track transmission rates in buckets (power of 2).
- * 1,2,4,8...512 seconds.
- *
- * Buckets represent the count of network transmissions at least
- * N seconds apart, where N is 1 << bucket index.
- */
-#define BUCKET_MAX 10
-
-/* Track network activity frequency */
-static unsigned long activity_stats[BUCKET_MAX];
-static ktime_t last_transmit;
-static ktime_t suspend_time;
-static DEFINE_SPINLOCK(activity_lock);
-
-void activity_stats_update(void)
-{
- int i;
- unsigned long flags;
- ktime_t now;
- s64 delta;
-
- spin_lock_irqsave(&activity_lock, flags);
- now = ktime_get();
- delta = ktime_to_ns(ktime_sub(now, last_transmit));
-
- for (i = BUCKET_MAX - 1; i >= 0; i--) {
- /*
- * Check if the time delta between network activity is within the
- * minimum bucket range.
- */
- if (delta < (1000000000ULL << i))
- continue;
-
- activity_stats[i]++;
- last_transmit = now;
- break;
- }
- spin_unlock_irqrestore(&activity_lock, flags);
-}
-
-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++) {
- ret = seq_printf(m, "%15d %lu\n", 1 << i, activity_stats[i]);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-static int activity_stats_notifier(struct notifier_block *nb,
- unsigned long event, void *dummy)
-{
- switch (event) {
- case PM_SUSPEND_PREPARE:
- suspend_time = ktime_get_real();
- break;
-
- case PM_POST_SUSPEND:
- suspend_time = ktime_sub(ktime_get_real(), suspend_time);
- last_transmit = ktime_sub(last_transmit, suspend_time);
- }
-
- return 0;
-}
-
-static int activity_stats_open(struct inode *inode, struct file *file)
-{
- return single_open(file, activity_stats_show, PDE_DATA(inode));
-}
-
-static const struct file_operations activity_stats_fops = {
- .open = activity_stats_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release,
-};
-
-static struct notifier_block activity_stats_notifier_block = {
- .notifier_call = activity_stats_notifier,
-};
-
-static int __init activity_stats_init(void)
-{
- proc_create("activity", S_IRUGO,
- init_net.proc_net_stat, &activity_stats_fops);
- return register_pm_notifier(&activity_stats_notifier_block);
-}
-
-subsys_initcall(activity_stats_init);
-
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 0fe6968be03..8eb92820588 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -268,7 +268,6 @@
#include <linux/crypto.h>
#include <linux/time.h>
#include <linux/slab.h>
-#include <linux/uid_stat.h>
#include <net/icmp.h>
#include <net/inet_common.h>
@@ -1257,9 +1256,6 @@ out:
tcp_push(sk, flags, mss_now, tp->nonagle);
out_nopush:
release_sock(sk);
-
- if (copied + copied_syn)
- uid_stat_tcp_snd(current_uid(), copied + copied_syn);
return copied + copied_syn;
do_fault:
@@ -1567,7 +1563,6 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
if (copied > 0) {
tcp_recv_skb(sk, seq, &offset);
tcp_cleanup_rbuf(sk, copied);
- uid_stat_tcp_rcv(current_uid(), copied);
}
return copied;
}
@@ -1972,9 +1967,6 @@ skip_copy:
tcp_cleanup_rbuf(sk, copied);
release_sock(sk);
-
- if (copied > 0)
- uid_stat_tcp_rcv(current_uid(), copied);
return copied;
out:
@@ -1983,8 +1975,6 @@ out:
recv_urg:
err = tcp_recv_urg(sk, msg, len, flags);
- if (err > 0)
- uid_stat_tcp_rcv(current_uid(), err);
goto out;
recv_sndq:
--
2.23.0