2021-10-16 14:05:45 -04:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2017-05-29 20:19:40 -04:00
|
|
|
From: Daniel Micay <danielmicay@gmail.com>
|
2017-06-28 08:20:24 -04:00
|
|
|
Date: Wed, 28 Jun 2017 07:54:49 -0400
|
2019-07-05 16:47:59 -04:00
|
|
|
Subject: [PATCH] Harden
|
2016-12-27 13:37:38 -05:00
|
|
|
|
2017-06-28 08:20:24 -04:00
|
|
|
Change-Id: I46e3fc4ac896a509ab8ca90ae4ce09b820da434b
|
2022-03-05 12:24:18 -05:00
|
|
|
[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 13:37:38 -05:00
|
|
|
---
|
2020-07-13 21:28:17 -04:00
|
|
|
init/init.cpp | 6 +++---
|
2021-10-16 14:05:45 -04:00
|
|
|
rootdir/init.rc | 11 +++++++++++
|
|
|
|
2 files changed, 14 insertions(+), 3 deletions(-)
|
2016-12-27 13:37:38 -05:00
|
|
|
|
|
|
|
diff --git a/init/init.cpp b/init/init.cpp
|
2017-05-29 20:19:40 -04:00
|
|
|
index 7a370596e..35bf44a7b 100755
|
2016-12-27 13:37:38 -05:00
|
|
|
--- a/init/init.cpp
|
|
|
|
+++ b/init/init.cpp
|
2017-05-29 20:19:40 -04:00
|
|
|
@@ -579,10 +579,10 @@ int main(int argc, char** argv) {
|
2016-12-27 13:37:38 -05: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-13 21:28:17 -04:00
|
|
|
diff --git a/rootdir/init.rc b/rootdir/init.rc
|
2021-10-16 14:05:45 -04:00
|
|
|
index 40a36402e..4abc6d1a8 100644
|
2016-12-27 13:37:38 -05:00
|
|
|
--- a/rootdir/init.rc
|
|
|
|
+++ b/rootdir/init.rc
|
2020-10-12 15:19:15 -04:00
|
|
|
@@ -126,6 +126,17 @@ on init
|
2016-12-27 13:37:38 -05:00
|
|
|
write /proc/sys/kernel/sched_child_runs_first 0
|
|
|
|
|
|
|
|
write /proc/sys/kernel/randomize_va_space 2
|
2020-05-13 17:25:52 -04:00
|
|
|
+ write /proc/sys/kernel/dmesg_restrict 1
|
2019-08-28 15:12:42 -04:00
|
|
|
+ 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 16:47:59 -04:00
|
|
|
+ write /proc/sys/net/ipv6/conf/all/use_tempaddr 2
|
2020-05-13 17:25:52 -04: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 16:47:59 -04:00
|
|
|
+ write /proc/sys/net/ipv6/conf/default/use_tempaddr 2
|
2020-05-13 17:25:52 -04: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 13:37:38 -05: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"
|