-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow su operation for SELinux Enforcing systems #234
base: master
Are you sure you want to change the base?
Conversation
This patch uses virtual resource names for IPC, which is currently not under the purview of SELinux, for now at least :)
Would it be appropriate for su in daemon mode to make an selinux call to set permissions on the socket it created? Would that get it across the line? |
If you could, the constraint I am trying to work against is where the selinux policy cannot be changed (that is, it is embedded in the boot image, like the samsung kernels). The other problem may/may not is the selinux is distributed as a shared lib I believe, we would need to check for whether the system is selinux enabled if you do want to go that route. The abstract resource I think is much cleaner without messing around with the permissions. (currently for locked down boot images we have to "shim" the startup of su in daemon mode anyways, not sure how long even this hack would work, if we the OEM locks that down).. |
Are abstract resources protected by filesystem permissions? I guess that's a nonissue since the socket peer is identified now. It's been a while since I've digged into this code. Would be good to have other eyes look at this for security problems. |
I don't believe so (it is more of linux thing, BSD for example completely ignores the file system permission for unix domain sockets), hence the patch removes it. Also the current implementation opens up the permissions anyway (0777). |
I think this is a good change. I recall initially wanting to use abstract sockets, but did not since they were not protected by filesystem permissions, which was the original implementation. Since then, also added checking the socket peer credentials as well to allow non-setuid invocation support. I'll see if I can get a few more eyes on this, as it pretty dramatically changes the internals of how the su daemon communicates with the world :) |
I think, given the general direction of this app, that, despite the hinderance, SE enforcing represents a significant opportunity. My (limited) reading of the se doco suggests that you can get very fine grained control of access to sockets. I started a big para about Superuser managing contexts for access to the su binary and then realised all the apps appear as zygote. There might still be something in that. I looked a bit in the daemon code and can see you have defaulted to denied in places where SE might be configured to deny you access to critical info (like the sockets remote credentials). I haven't looked hard enough yet to say confidently "its good", but it looks to be in reasonable shape. I'll try to review it better this week. On a slightly different track: I am currently playing with my 4.3 GS4. I have compiled this patch and put it manually into a system partition, from the providers image, by loop mounting it on linux, then using img2simg and heimdall to get it onto the phone. ** This has not bumped the knox flag. ** I needed to use setfilecon while the image was mounted on linux to give execute rights on the su binary. I currently get a blank Superuser dialog that flashes almost too fast to read when anything asks for su. The calling app waits until superuser is manually started, and then claims it was denied. I have tried auto allow, no pin, no tick for declared. "There are currently no Superuser app policies". I have one entry in the log for Superuser allow, and three for Titanium backup denied, despite several attempts. I seem to be getting one entry in the log per reboot. Setting auto accept, rebooting and hitting titanium still failed. For a connectbot local su invoke, logcat shows Update: Update2: |
This patch does not appear to reduce security. I do think I might have found a hole in the original (and this version) though. Not sure how to PM koush. If I'm right, I don't want to post it here till theres a fix. |
koush @ koushikdutta.com |
Thank you very much to let me use your Great application. |
So, Android L dropped, which is in enforcing mode. Connecting to abstract sockets does not work:
|
root from shell works, but root from other apps results in this connect to abstract socket error. i had a similar issue using abstract sockets for IPC inside a zygote based process in another app. |
I may need to go back to a FIFO based method. |
Ugh, apparently fifo doesnt work anymore either. Creating a file as root, and changing ownership to another uid does not work. The new uid still can't access it. |
Yup that is correct..There is way around it by shiming in the
|
shimming in the daemon? What do you mean? |
Well, creating a new policy is not ideal. Requiring a custom boot image is rather annoying. |
Yes, new policy is not ideal as noted before. By "shiming" I meant find a process (there will always be one :) ) that has all the SE Policies that the SU daemon needs for working in a enforcing mode, replace that with a script, that starts both of them. It is of course a hack, it will preserve the custom boot image. The downside is for proprietary roms, it is not future proof. I believe the other SU program/app uses the same approach. |
Ok |
Dd |
|
2 similar comments
|
|
This patch uses virtual resource names for IPC, which is currently not under the purview of
SELinux, for now at least :)