tiann / KernelSU

A Kernel based root solution for Android
https://kernelsu.org
GNU General Public License v3.0
10.47k stars 1.71k forks source link

Running in ChromeOS #637

Closed supechicken closed 1 year ago

supechicken commented 1 year ago

Describe the bug The kernelsu/ksud.c:111:12: error: unused function 'count' error appeared when running build/build.sh, tried export CFLAGS='-Wno-error -Wno-unused-function' but with no luck

*Kernel compiled successfully without KernelSU patch

To Reproduce Steps to reproduce the behavior:

repo init -u https://android.googlesource.com/kernel/manifest -b common-android12-5.10-arcvm-gki-base
repo sync
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -

sed -i "s/check_defconfig//" common/build.config.gki
sed -i "s/DEFCONFIG=gki_defconfig/DEFCONFIG=x86_64_arcvm_defconfig/" common/build.config.gki
cp common/arch/x86/configs/x86_64_arcvm_defconfig common/arch/x86/configs/x86_64_defconfig

LTO=thin CFLAGS='-Wno-error -Wno-unused-function' CXXFLAGS='-Wno-error -Wno-unused-function' BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh

Smartphone (please complete the following information):

EDIT: This error shows after commenting out static int count:

/home/supechicken/android-kernel/common/drivers/kernelsu/ksud.c:87:27: error: unused function 'get_user_arg_ptr' [-Werror,-Wunused-function]
static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
1457384613gh commented 1 year ago

kernel備份也會因為更新而被刪除,

直接变成 官方的 vmlinux了。

Brunch 框架 更换 内核,或者更改其他内核选项,也会造成,vmlinux 自动恢复成官方版的。

supechicken commented 1 year ago
$ sudo fdisk -l -o Device,Size,Type,Name /dev/sdz
Disk /dev/sdz: 128 GiB, 137438953472 bytes, 268435456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5DBAA591-A253-E845-8B2B-299DCB9B971D

Device       Size Type              Name
/dev/sdz1  118.8G Linux filesystem  
/dev/sdz2     32M ChromeOS kernel   KERN-A
/dev/sdz3      4G ChromeOS root fs  ROOT-A
/dev/sdz4     32M ChromeOS kernel   KERN-B
/dev/sdz5      4G ChromeOS root fs  ROOT-B
/dev/sdz6    512B ChromeOS kernel   KERN-C
/dev/sdz7      1G ChromeOS root fs  ROOT-C
/dev/sdz8     16M Linux filesystem  OEM
/dev/sdz9    512B ChromeOS reserved reserved
/dev/sdz10   512B ChromeOS reserved reserved
/dev/sdz11     8M unknown           RWFW
/dev/sdz12    32M EFI System        EFI-SYSTEM

Partition table entries are not in disk order.

*ROOT-C 是 Brunch 在用的(放 kernel 啥的)

supechicken commented 1 year ago

kernel備份也會因為更新而被刪除,

直接变成 官方的 vmlinux了。

Brunch 框架 更换 内核,或者更改其他内核选项,也会造成,vmlinux 自动恢复成官方版的。

可以這麼說。

1457384613gh commented 1 year ago

唯一美中不足的地方,Brunch 框架 只会生成 .img,无法充分利用整个分区。

要是,可以把 chromeOS 安装到 lvm 分区里,就好啦。

lvm 支持,在逻辑卷上建立文件系统。 挂载原理,跟 挂载 .img 有点类似。

要是能用上 lvm 分区,就可以跟 苹果的 Apfs 宗卷 媲美了。

supechicken commented 1 year ago

這也要看 ChromeOS 本身支持才行,不然連系統都進不了

djfaizp commented 1 year ago
 # remove -Werror from all Makefiles
makefiles="$(find . -type f -name Makefile | tr "\n" ' ') $(find . -type f -name Kbuild | tr "\n" ' ')"

for i in $makefiles; do
  sed -i 's/-Werror=/-Wno-error=/g' "$i"
  sed -i 's/-Werror/-w/g' "$i"
  sed -i 's/-Wall/-w/g' "$i"
done

how to apply it ?

1457384613gh commented 1 year ago

這也要看 ChromeOS 本身支持才行,不然連系統都進不了

如果 grub2 能把 逻辑卷 挂载到 相应的路径,应该是可以的。 毕竟,一个卷组就类似于一个物理磁盘,跟 .img 差不多。 区别在于, .img 是个 文件,lvm 是个真实分区。

1457384613gh commented 1 year ago

brunch 框架 的 PWA 可以 通过点击网页上的 按钮,更新 brunch 和 系统啵。 这说明,PWA 可以 调用 shell。

可以制作一个 KernelSU for chromeOS 的 PWA,有

然后……

可以通过 chromeOS 的启动器,打开 PWA,按个小按钮,安装 KernelSU,更方便。

https://github.com/sebanc/brunch-pwa

这个是 brunch-pwa 的源代码,可以参考里面的 调用接口的 方式及其原理啵。

supechicken commented 1 year ago

這個看上去很難, 其實原理很簡單:

我寫過 Websocket server,但不是基於websocketd而是從底層socket寫起,還是挺容易的

supechicken commented 1 year ago

how to apply it ?

Just paste it into bash shell inside the kernel source directory

1457384613gh commented 1 year ago

那 brunch-pwa 是怎么做到 下载好了 brunch.tar.gz 或 rammus.bin 还能够安装的呢?

PWA 是怎么 修改 系统文件的呢?

djfaizp commented 1 year ago

Screenshot 2023-06-17 2 28 38 PM how to activate this i have tried manually but the activation script do not work

supechicken commented 1 year ago

那 brunch-pwa 是怎么做到 下载好了 brunch.tar.gz 或 rammus.bin 还能够安装的呢?

PWA 是怎么 修改 系统文件的呢?

不是 PWA 修改的,是 PWA 叫本地後台進程下載並修改的,PWA 只負責把進度顯示出來:

關鍵不在 PWA 本身,是在那個後台腳本: https://github.com/sebanc/brunch/blob/r113/brunch-patches/99-pwa.sh

supechicken commented 1 year ago

how to activate this i have tried manually but the activation script do not work

@djfaizp Did you enable root for this app (in KernelSU app)?

1457384613gh commented 1 year ago

哇哦,那我们也可以弄个 100-kernelsu-pwa.sh

supechicken commented 1 year ago

你可以試試

對了,那個vmc stop arcvm其實也不太穩定,一換 kernel 就大概率 bootloop,還是老老實實 reboot 算了

1457384613gh commented 1 year ago

编译的 vmlinux 不是有两份吗? 一份是 bootloop 的,体积翻倍; 另一份 是 成功的,体积增一点点。

会不会是换错了?

djfaizp commented 1 year ago

how to activate this i have tried manually but the activation script do not work

@djfaizp Did you enable root for this app (in KernelSU app)? image i have also tried manully activation but it also doesn't work may be due to architecture issue and diffrent path maping yes i tried

djfaizp commented 1 year ago

@1457384613gh @natsumerinchan @supechicken i have read reddit and found that this issue is due to arcvm as Google is planing to move to fuschia os so they have introduced arcvm for flew less migration. But arc++ support is great and it uses chrome os kernel. Can some one compile chrome os kernel i think r90 (or android 9) had arc++ kernel architecture.

1457384613gh commented 1 year ago

Brunch Framework has many kernels built. Ask someone there to help to adapt.

djfaizp commented 1 year ago

I'm currently trying to compile, I will share the results here, I <3 Chrome os

image

is this correct to implement it

supechicken commented 1 year ago

is this correct to implement it

No need to add to Makefile, and this will not work as the syntax of Makefile is different to bash.

Also this patch is no longer needed as https://github.com/tiann/KernelSU/commit/c697398893612a882df8f22ac1fb63bae2e79d79 fixed it

supechicken commented 1 year ago

how to activate this i have tried manually but the activation script do not work

It seems that this app does not support KernelSU yet.

djfaizp commented 1 year ago

how to activate this i have tried manually but the activation script do not work

you mean termux ? termux gain su access

supechicken commented 1 year ago

I mean the script itself

1457384613gh commented 1 year ago

他那个,好像是个什么鼠标外设的。 不知道 ARCVM 能不能调用 宿主系统 的 USB 设备。

djfaizp commented 1 year ago

他那个,好像是个什么鼠标外设的。 不知道 ARCVM 能不能调用 宿主系统 的 USB 设备。

you can connect it there is no issue at all

supechicken commented 1 year ago

编译的 vmlinux 不是有两份吗? 一份是 bootloop 的,体积翻倍; 另一份 是 成功的,体积增一点点。

会不会是换错了?

不可能,我用原來的和打了補丁的試了試,一換 kernel log 就報錯(我記得好像是說vsock端口被佔了)。兩個 kernel 重啟後都能用

hmtheboy154 commented 1 year ago

how to activate this i have tried manually but the activation script do not work

It seems that this app does not support KernelSU yet.

Panda keymapper (or Octopus) comes with ARM libraries only, when being injected into the system it will immediately reject because of different CPU arch. Even if ChromeOS's arcvm has native bridge it does not help at all. The only solution now is to modify bionic libc.

Speaking of ARM, please remember that arcvm has ARM version for ARM Chromebooks too

djfaizp commented 1 year ago

is this correct to implement it

No need to add to Makefile, and this will not work as the syntax of Makefile is different to bash.

Also this patch is no longer needed as c697398 fixed it

image I'm still getting this error

edit: I have a fork repo can you please contribute to it ?

as arc++ uses chrome os kernel itself I want to move to the lower release of chrome os.

image

https://github.com/djfaizp/brunch

1457384613gh commented 1 year ago

ARC++ has no its own vmlinux, at least I don't know how to make it support KernelSU.

ARC++ is like waydroid. However, if waydroid can support KernelSU, that of ARC++ can study it. So what you should do is to ask @hmtheboy154 how to make waydroid support KernelSU.

He will tell you that waydroid supports Magisk Delta. So why don't you try waydroid+MagiskΔ?

He may make you try BlissOS with KernelSU added by him. So why don't you try BlissOS+KernelSU?

Do you need Chrome desktop browser + Android with root?

Linux Distro + Chrome desktop browser + waydroid + MagiskΔ or BlissOS + Kiwi browser + KernelSU

However, you can still ask @hmtheboy154 whether there is a way to make waydroid support KernelSU or not.

djfaizp commented 1 year ago

However, if waydroid can support KernelSU, that of ARC++ can study it.

waydroid is to much laggy i have tried it

1457384613gh commented 1 year ago

Wait for his words.

djfaizp commented 1 year ago

ARC++ has no its own vmlinux, at least I don't know how to make it support KernelSU.

ARC++ is like waydroid. However, if waydroid can support KernelSU, that of ARC++ can study it. So what you should do is to ask @hmtheboy154 how to make waydroid support KernelSU.

He will tell you that waydroid supports Magisk Delta. So why don't you try waydroid+MagiskΔ?

He may make you try BlissOS with KernelSU added by him. So why don't you try BlissOS+KernelSU?

Do you need Chrome desktop browser + Android with root?

Linux Distro + Chrome desktop browser + waydroid + MagiskΔ or BlissOS + Kiwi browser + KernelSU

However, you can still ask @hmtheboy154 whether there is a way to make waydroid support KernelSU or not.

I want to play pubg mobile with keyboard mouse and stable android experiance

hmtheboy154 commented 1 year ago

ARC++ has no its own vmlinux, at least I don't know how to make it support KernelSU.

Old ARC is a container nearlt like WayDroid like you said, so instead of trying to find the guest kernel (arcvm is literally a VM), you directly build KernelSU into your ChromeOS kernel

ARC++ is like waydroid. However, if waydroid can support KernelSU, that of ARC++ can study it. So what you should do is to ask @hmtheboy154 how to make waydroid support KernelSU.

WayDroid did the same. In fact, I'm not the first one that brought KernelSU into WayDroid, someone else in China already did.

He will tell you that waydroid supports Magisk Delta. So why don't you try waydroid+MagiskΔ?

I won't tell because I don't know.

However, you can still ask @hmtheboy154 whether there is a way to make waydroid support KernelSU or not.

again, build the kernel with KernelSU, WayDroid will immediately recognize it

djfaizp commented 1 year ago

@hmtheboy154 I have tried to compile it but core_hook.c :70 :9: module is still producing the same error which was in ksud.c :87:27:

it's in

int i; for (i = 0; i < ngroups; i++) { gid_t gid = profile->groups[i]; kgid_t kgid = make_kgid(current_user_ns(), gid); if (!gid_valid(kgid)) { pr_warn("Failed to setgroups, invalid gid: %d\n", gid); put_group_info(group_info); return;

hmtheboy154 commented 1 year ago

what's this kernel source ?

djfaizp commented 1 year ago

It's here

My gcc version is G++11

1457384613gh commented 1 year ago

@natsumerinchan 帮忙看下,fydeOS 的这个 5.4 的内核 有没有希望 修补一个 vmlinuzhttps://github.com/openFyde/kernel/tree/chromeos-5.4 fydeOS 更新得慢,好几年不换内核啵。 宿主系统的 vmlinuz 真的行吗?他们说行,可以看看。

supechicken commented 1 year ago

again, build the kernel with KernelSU, WayDroid will immediately recognize it

I don't think it will work as the UID/GID is remapped in containers (i.e. under a Linux user namespace), which might break the approve/deny algorithm in KernelSU.

supechicken commented 1 year ago

~Never mind, just found that the source code can handle it by checking the current namespace.~ It seems that the namespace algorithm is designed for handling Android namespaces only (correct me if I am wrong ;) )

But will the init hook work when running in a container?

1457384613gh commented 1 year ago

@supechicken 这有个 shutdown arcvm,但不知道能不能在 crosh shell 里用上。 https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/concierge/arc_vm.cc Screenshot_2023-06-20-09-12-04-817_mark.via-edit.jpg

djfaizp commented 1 year ago

why I'm getting this error any idea?

depmod: WARNING: /home/alex/brunch/chroot/tmp/kernel/out/../../../home/chronos/kernel/lib/modules/4.19.282-brunch-sebanc/kernel/drivers/staging/rtlwifi/r8822be.ko needs unknown symbol rate_control_send_low modinfo: ERROR: Module alias mac80211 not found. depmod will prefer updates/ over kernel/ -- OK! depmod: ERROR: could not open directory /lib/modules/5.15.90.1-microsoft-standard-WSL2: No such file or directory depmod: FATAL: could not search modules: No such file or directory make[1]: *** [Makefile.real:108: install] Error 1 make: *** [Makefile:43: install] Error 2 root@Alex:/home/alex/brunch/chroot/tmp/backport-iwlwifi#

this issue is not related to KernelSU so making a comment here does not need to create a bug issue

1457384613gh commented 1 year ago

@natsumerinchan 帮忙看下 那个 5.4.217 的,能不能 kernelsu 修补。

我正好有个酷睿一代的设备安装了 fydeOS,是 5.4.217 的内核,可以用来测试。

我还制作了给 fydeOS 使用的 grub 主题,需要复制到 /boot/grub/themes 目录下,正好在复制主题的时候,顺便把 vmlinuz-ksu-5.4 复制到 /boot,然后,我还可以 编辑 grub.cfg,添加支持 kernelsu 的启动项。

https://github.com/openFyde/project-openfyde-patches/tree/main/sys-kernel/chromeos-kernel-5_4

natsumerinchan commented 1 year ago

@natsumerinchan 帮忙看下 那个 5.4.217 的,能不能 kernelsu 修补。

我正好有个酷睿一代的设备安装了 fydeOS,是 5.4.217 的内核,可以用来测试。

我还制作了给 fydeOS 使用的 grub 主题,需要复制到 /boot/grub/themes 目录下,正好在复制主题的时候,顺便把 vmlinuz-ksu-5.4 复制到 /boot,然后,我还可以 编辑 grub.cfg,添加支持 kernelsu 的启动项。

https://github.com/openFyde/project-openfyde-patches/tree/main/sys-kernel/chromeos-kernel-5_4

OK,等我恰完饭

djfaizp commented 1 year ago

Can't load key from file '/persist/keys/brunch.priv' 40A79174DB7F0000:error:1E08010C:DECODER routines:OSSL_DECODER_from_bio:unsupported:../crypto/encode_decode/decoder_lib.c:101:No supported data to decode. Input type: PEM Kernel signing failed Error: Process completed with exit code 1.

How to Fix it ? Link

supechicken commented 1 year ago

@supechicken 这有个 shutdown arcvm,但不知道能不能在 crosh shell 里用上。 https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/concierge/arc_vm.cc

應該不能,因為它沒有可以操作的dbus介面

djfaizp commented 1 year ago

I noticed brayo arcvm kernel work better in chrome os

natsumerinchan commented 1 year ago

su临时修复方法

arcvm_kernelsu_fix.zip

#!/data/adb/ksu/bin/busybox sh

/system/bin/su "$@"
supechicken commented 1 year ago

su临时修复方法

如果加exec的話能用嗎?像這樣:

#!/data/adb/ksu/bin/busybox sh
exec /system/bin/su "$@"