DivestOS/Patches/LineageOS-14.1/android_system_core/0001-Harden.patch

54 lines
2.3 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2017-05-30 00:19:40 +00:00
From: Daniel Micay <danielmicay@gmail.com>
2017-06-28 12:20:24 +00:00
Date: Wed, 28 Jun 2017 07:54:49 -0400
2019-07-05 20:47:59 +00:00
Subject: [PATCH] Harden
2016-12-27 18:37:38 +00:00
2017-06-28 12:20:24 +00:00
Change-Id: I46e3fc4ac896a509ab8ca90ae4ce09b820da434b
[tad@spotco.us]: added protected fifos and regular from newer GrapheneOS patches
[tad@spotco.us]: added IPv6 privacy options TODO split into another patch
2016-12-27 18:37:38 +00:00
---
2020-07-14 01:28:17 +00:00
init/init.cpp | 6 +++---
rootdir/init.rc | 11 +++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
2016-12-27 18:37:38 +00:00
diff --git a/init/init.cpp b/init/init.cpp
2017-05-30 00:19:40 +00:00
index 7a370596e..35bf44a7b 100755
2016-12-27 18:37:38 +00:00
--- a/init/init.cpp
+++ b/init/init.cpp
2017-05-30 00:19:40 +00:00
@@ -579,10 +579,10 @@ int main(int argc, char** argv) {
2016-12-27 18:37:38 +00:00
mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755");
mkdir("/dev/pts", 0755);
mkdir("/dev/socket", 0755);
- mount("devpts", "/dev/pts", "devpts", 0, NULL);
+ mount("devpts", "/dev/pts", "devpts", MS_NOSUID|MS_NOEXEC, NULL);
#define MAKE_STR(x) __STRING(x)
- mount("proc", "/proc", "proc", 0, "hidepid=2,gid=" MAKE_STR(AID_READPROC));
- mount("sysfs", "/sys", "sysfs", 0, NULL);
+ mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, "hidepid=2,gid=" MAKE_STR(AID_READPROC));
+ mount("sysfs", "/sys", "sysfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL);
}
// We must have some place other than / to create the device nodes for
2020-07-14 01:28:17 +00:00
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 40a36402e..4abc6d1a8 100644
2016-12-27 18:37:38 +00:00
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -126,6 +126,17 @@ on init
2016-12-27 18:37:38 +00:00
write /proc/sys/kernel/sched_child_runs_first 0
write /proc/sys/kernel/randomize_va_space 2
2020-05-13 21:25:52 +00:00
+ write /proc/sys/kernel/dmesg_restrict 1
+ write /proc/sys/fs/protected_hardlinks 1
+ write /proc/sys/fs/protected_symlinks 1
+ write /proc/sys/fs/protected_fifos 1
+ write /proc/sys/fs/protected_regular 1
2019-07-05 20:47:59 +00:00
+ write /proc/sys/net/ipv6/conf/all/use_tempaddr 2
2020-05-13 21:25:52 +00:00
+ write /proc/sys/net/ipv6/conf/all/max_addresses 128
+ write /proc/sys/net/ipv6/conf/all/temp_prefered_lft 21600
2019-07-05 20:47:59 +00:00
+ write /proc/sys/net/ipv6/conf/default/use_tempaddr 2
2020-05-13 21:25:52 +00:00
+ write /proc/sys/net/ipv6/conf/default/max_addresses 128
+ write /proc/sys/net/ipv6/conf/default/temp_prefered_lft 21600
2016-12-27 18:37:38 +00:00
write /proc/sys/kernel/kptr_restrict 2
write /proc/sys/vm/mmap_min_addr 32768
write /proc/sys/net/ipv4/ping_group_range "0 2147483647"