Skip to content

Commit 3ee4c0a

Browse files
committed
Add: KSU Next & Droidspace config files & patches directory
1 parent 57f89ff commit 3ee4c0a

6 files changed

Lines changed: 442 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Kernel configurations for full DroidSpaces support
2+
# Copyright (C) 2026 ravindu644 <droidcasts@protonmail.com>
3+
# Required configuration for Droidspace to work. Merge it to nemo_defconfig
4+
5+
# IPC mechanisms
6+
CONFIG_SYSCTL=y
7+
CONFIG_SYSVIPC=y
8+
CONFIG_POSIX_MQUEUE=y
9+
10+
# Sandboxing support
11+
CONFIG_USER_NS=y
12+
13+
# Core namespace support
14+
CONFIG_NAMESPACES=y
15+
CONFIG_PID_NS=y
16+
CONFIG_UTS_NS=y
17+
CONFIG_IPC_NS=y
18+
19+
# Seccomp support
20+
CONFIG_SECCOMP=y
21+
CONFIG_SECCOMP_FILTER=y
22+
23+
# Control groups support
24+
CONFIG_CGROUPS=y
25+
CONFIG_CGROUP_DEVICE=y
26+
CONFIG_CGROUP_PIDS=y
27+
28+
# Device filesystem support
29+
CONFIG_DEVTMPFS=y
30+
31+
# Overlay filesystem support (required for volatile mode)
32+
CONFIG_OVERLAY_FS=y
33+
34+
# Firmware loading support
35+
CONFIG_FW_LOADER=y
36+
CONFIG_FW_LOADER_USER_HELPER=y
37+
CONFIG_FW_LOADER_COMPRESS=y
38+
39+
# Droidspaces Network Isolation Support - NAT/none modes
40+
CONFIG_NET_NS=y
41+
CONFIG_VETH=y
42+
CONFIG_BRIDGE=y
43+
CONFIG_NETFILTER=y
44+
CONFIG_BRIDGE_NETFILTER=y
45+
CONFIG_NETFILTER_ADVANCED=y
46+
CONFIG_NF_CONNTRACK=y
47+
CONFIG_IP_NF_IPTABLES=y
48+
CONFIG_IP_NF_FILTER=y
49+
CONFIG_NF_NAT=y
50+
CONFIG_NF_TABLES=y
51+
CONFIG_IP_NF_TARGET_MASQUERADE=y
52+
CONFIG_NETFILTER_XT_TARGET_MASQUERADE=y
53+
CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
54+
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
55+
CONFIG_NF_CONNTRACK_NETLINK=y
56+
CONFIG_NF_NAT_REDIRECT=y
57+
CONFIG_IP_ADVANCED_ROUTER=y
58+
CONFIG_IP_MULTIPLE_TABLES=y
59+
60+
# legacy compat
61+
CONFIG_NF_CONNTRACK_IPV4=y
62+
CONFIG_NF_NAT_IPV4=y
63+
CONFIG_IP_NF_NAT=y
64+
65+
# Disable this on older kernels to make internet work
66+
CONFIG_ANDROID_PARANOID_NETWORK=n
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# These options are only required:
2+
# if you want to run UFW or Fail2ban inside the container.
3+
4+
5+
# UFW & FAIL2BAN CORE
6+
CONFIG_NETFILTER_XT_MATCH_COMMENT=y
7+
CONFIG_NETFILTER_XT_MATCH_STATE=y
8+
CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
9+
CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
10+
CONFIG_NETFILTER_XT_MATCH_HL=y
11+
CONFIG_NETFILTER_XT_TARGET_REJECT=y
12+
CONFIG_IP_NF_TARGET_REJECT=y
13+
CONFIG_NETFILTER_XT_TARGET_LOG=y
14+
CONFIG_IP_NF_TARGET_ULOG=y
15+
CONFIG_NETFILTER_XT_MATCH_RECENT=y
16+
CONFIG_NETFILTER_XT_MATCH_LIMIT=y
17+
CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=y
18+
CONFIG_NETFILTER_XT_MATCH_OWNER=y
19+
CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
20+
CONFIG_NETFILTER_XT_MATCH_MARK=y
21+
CONFIG_NETFILTER_XT_TARGET_MARK=y
22+
CONFIG_IP_SET=y
23+
CONFIG_IP_SET_HASH_IP=y
24+
CONFIG_IP_SET_HASH_NET=y
25+
CONFIG_NETFILTER_XT_SET=y
26+
CONFIG_NETFILTER_NETLINK_QUEUE=y
27+
CONFIG_NETFILTER_NETLINK_LOG=y
28+
CONFIG_NETFILTER_XT_TARGET_NFLOG=y

build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
# Tips for beginners
4+
# Modify the script as your needs
5+
# Use nemo_defconfig as base
6+
# After integrating and applying patches of KSU:
7+
# Running `make mrproper` will say KSU Hooks are not included, ignore that, and compile your kernel
8+
39
function compile()
410
{
511
rm -rf AnyKernel

ksu_next_setup.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
GKI_ROOT=$(pwd)
5+
OWNER="KernelSU-Next"
6+
REPO="$OWNER"
7+
8+
display_usage() {
9+
echo "Usage: $0 [--cleanup | <commit-or-tag>]"
10+
echo " --cleanup: Cleans up previous modifications made by the script."
11+
echo " <commit-or-tag>: Sets up or updates the KernelSU-Next to specified tag or commit."
12+
echo " -h, --help: Displays this usage information."
13+
echo " (no args): Sets up or updates the KernelSU-Next environment to the latest tagged version."
14+
}
15+
16+
initialize_variables() {
17+
if test -d "$GKI_ROOT/common/drivers"; then
18+
DRIVER_DIR="$GKI_ROOT/common/drivers"
19+
elif test -d "$GKI_ROOT/drivers"; then
20+
DRIVER_DIR="$GKI_ROOT/drivers"
21+
else
22+
echo '[ERROR] "drivers/" directory not found.'
23+
exit 127
24+
fi
25+
26+
DRIVER_MAKEFILE=$DRIVER_DIR/Makefile
27+
DRIVER_KCONFIG=$DRIVER_DIR/Kconfig
28+
}
29+
30+
# Reverts modifications made by this script
31+
perform_cleanup() {
32+
echo "[+] Cleaning up..."
33+
[ -L "$DRIVER_DIR/kernelsu" ] && rm "$DRIVER_DIR/kernelsu" && echo "[-] Symlink removed."
34+
grep -q "kernelsu" "$DRIVER_MAKEFILE" && sed -i '/kernelsu/d' "$DRIVER_MAKEFILE" && echo "[-] Makefile reverted."
35+
grep -q "drivers/kernelsu/Kconfig" "$DRIVER_KCONFIG" && sed -i '/drivers\/kernelsu\/Kconfig/d' "$DRIVER_KCONFIG" && echo "[-] Kconfig reverted."
36+
if [ -d "$GKI_ROOT/$REPO" ]; then
37+
rm -rf "$GKI_ROOT/$REPO" && echo "[-] $REPO directory deleted."
38+
fi
39+
}
40+
41+
# Sets up or update KernelSU-Next environment
42+
setup_kernelsu() {
43+
echo "[+] Setting up $REPO..."
44+
test -d "$GKI_ROOT/$REPO" || git clone "https://github.com/$OWNER/$REPO" && echo "[+] Repository cloned."
45+
cd "$GKI_ROOT/$REPO"
46+
git stash && echo "[-] Stashed current changes."
47+
48+
BRANCH="$(git rev-parse --abbrev-ref origin/HEAD | sed 's@^origin/@@')"
49+
if [ "$(git status | grep -Po 'v\d+(\.\d+)*' | head -n1)" ]; then
50+
git checkout $BRANCH && echo "[-] Switched to $BRANCH branch."
51+
fi
52+
53+
git pull && echo "[+] Repository updated."
54+
if [ -z "${1-}" ]; then
55+
git checkout legacy && echo "[-] Checked out legacy branch."
56+
else
57+
git checkout "$1" && echo "[-] Checked out $1." || echo "[-] Checkout default branch"
58+
fi
59+
cd "$DRIVER_DIR"
60+
ln -sf "$(realpath --relative-to="$DRIVER_DIR" "$GKI_ROOT/$REPO/kernel")" "kernelsu" && echo "[+] Symlink created."
61+
62+
# Add entries in Makefile and Kconfig if not already existing
63+
grep -q "kernelsu" "$DRIVER_MAKEFILE" || printf "\nobj-\$(CONFIG_KSU) += kernelsu/\n" >> "$DRIVER_MAKEFILE" && echo "[+] Modified Makefile."
64+
grep -q "source \"drivers/kernelsu/Kconfig\"" "$DRIVER_KCONFIG" || sed -i "/endmenu/i\source \"drivers/kernelsu/Kconfig\"" "$DRIVER_KCONFIG" && echo "[+] Modified Kconfig."
65+
echo '[+] Done.'
66+
}
67+
68+
# Process command-line arguments
69+
if [ "$#" -eq 0 ]; then
70+
initialize_variables
71+
setup_kernelsu
72+
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
73+
display_usage
74+
elif [ "$1" = "--cleanup" ]; then
75+
initialize_variables
76+
perform_cleanup
77+
else
78+
initialize_variables
79+
setup_kernelsu "$@"
80+
fi
81+
82+
echo 'CONFIG_KSU=y' >> arch/arm64/configs/nemo_defconfig
83+
echo 'CONFIG_KSU_MANUAL_HOOK=y' >> arch/arm64/configs/nemo_defconfig
84+
85+
echo "Done, now apply the ksu hooks from root/patches/ksu_next_hooks/* while being in the kernel root directory"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From 50cb2ccbef7d84852f2600bb4d3e69f6bd736561 Mon Sep 17 00:00:00 2001
2+
From: ravindu644 <droidcasts@protonmail.com>
3+
Date: Sun, 22 Feb 2026 22:27:15 +0530
4+
Subject: [PATCH] [PATCH 2/2] Droidspaces/LXC: fix: restore cgroup file prefix
5+
handling for Droidspaces/LXC compatibility
6+
7+
Signed-off-by: ravindu644 <droidcasts@protonmail.com>
8+
---
9+
kernel/cgroup/cgroup.c | 5 +++++
10+
1 file changed, 5 insertions(+)
11+
12+
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
13+
index 694b1cc8d..d0d04bff1 100755
14+
--- a/kernel/cgroup/cgroup.c
15+
+++ b/kernel/cgroup/cgroup.c
16+
@@ -3496,6 +3496,11 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp,
17+
spin_unlock_irq(&cgroup_file_kn_lock);
18+
}
19+
20+
+ if (cft->ss && (cgrp->root->flags & CGRP_ROOT_NOPREFIX) && !(cft->flags & CFTYPE_NO_PREFIX)) {
21+
+ snprintf(name, CGROUP_FILE_NAME_MAX, "%s.%s", cft->ss->name, cft->name);
22+
+ kernfs_create_link(cgrp->kn, name, kn);
23+
+ }
24+
+
25+
return 0;
26+
}
27+

0 commit comments

Comments
 (0)