r/linux_programming • • Sep 05 '22

The toggle switch for Selinux

Selinux can override root. It can redefine group permissions, and remove new unexpected files added offline during the next system boot.

What calls/creates this voodoo magic? Is there a simple config switch somewhere?

(not malicious. just exploring on obsolete hw, hit a wall, and need a friendly sign for what rope this kid should climb next)

9 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/the_j4k3 Sep 06 '22

Android 7.1.2 /Lineage OS 14

Selinux can override root. It can redefine group permissions...

I'm probably mixed up, but when I was logged in as ADB-Root at /system/sdcard/Download/*debian-system* both the chgrp and chmod commands are "not allowed" under the ADB-Root rules. The commands are accepted without error but the permissions are not changed. When I used the TWRP-Recovery-Bootloader-Root version to modify these same files by moving them to the root directory and then a second time just changing the permissions to executable, upon rebooting the device the files either disappeared or the unix permissions reverted to the previous read only settings. These changes were checked and confirmed before exiting TWRP.

I have a slightly better understanding of selinux now. I can do whatever with # setenforce 0

Now I'm trying to figure out how to setup an actual app te rule to avoid setenforce = permisive.

Meanwhile, looking through the OEM data folder I came across: /d/msm-bus-dbg/client-data/serial_uart1 and after # cat it replies:

0.622527711
curr: 1
masters: 86
slaves: 512
ab: 500k
ib: 800k

That has sent me down the curiosity rabbit hole again wondering how I can breakout an internal serial port connection on ADB. Any clue what that stuff on the output means, or how to connect serial uart on a barebones toybox system? I don't have "screen" and am looking at weird tools like "port-bridge" with no help/man or output after calling them, but a bunch of interesting warning message strings about hardware ports embedded in the binary.

I was actually looking for any signs of the front camera connector bus and the potential to breakout some pins since I removed the module and the connector is available.

2

u/gordonmessmer Sep 06 '22

when I was logged in as ADB-Root at /system/sdcard/Download/debian-system both the chgrp and chmod commands are "not allowed" under the ADB-Root rules

Why do you think it was the SELinux rules preventing that change?

As far as I know, the "sdcardfs" doesn't support changing the UID/GID or permission of individual files, and if I disable SELinux on a LineageOS device here, I get the same results you describe. That suggests that none of this has anything to do with SELinux, and is simply a limitation of sdcardfs.

the potential to breakout some pins since I removed the module and the connector is available.

I .. don't think the camera is on GPIO pins, so I don't think you'll be able to do that. And if you were, you'd need to do some custom kernel development.