Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
20 votes
Accepted

How dangerous is the fact that SELinux is in "Permissive" mode? What should I be wary of?

TL;DR: Feel free to jump directly to the conclusion at the bottom if you like :) ! SELinux goal is to prevent privilege escalation by enforcing a mandatory policy which restricts possible actions ...
WhiteWinterWolf's user avatar
17 votes

How to run DNSCrypt as a background service on Android?

Pardon me if I fail to sum up the vast subject in a brief answer :) SELINUX AND AVC DENIALS Android is based on Linux kernel that makes use of Discretionary and Mandatory Access Controls (DAC, MAC) to ...
Irfan Latif's user avatar
  • 20.6k
15 votes
Accepted

How to disable dm-verity on Android with "user" build type ROM?

I'm going to give a general overview of how dm-verity and related things work on Android according to my limited knowledge. Situation might differ on different devices and ROMs. HOW IS DM-VERITY ...
Irfan Latif's user avatar
  • 20.6k
10 votes

What special privileges "/system/xbin/su" does have w.r.t. root access?

Since Android is based on Linux kernel, getting root access by executing /system/xbin/su - like one can do on a Linux system - used to work in good old days but not now. The story is a bit twisted. ...
Irfan Latif's user avatar
  • 20.6k
10 votes

How does SuperSu provide root privilege?

SuperSU is no more actively developed, the new prevailing standard is Magisk which was originally based on SuperSU (ideas and perhaps some code too) but now it has moved far ahead. So better go for a ...
Irfan Latif's user avatar
  • 20.6k
8 votes

Examine android (v30) selinux policy

First of all, I must admit that I fully agree with your "I've found this shockingly hard to do" statement. Google has designed Android mainly from a consumer perspective, and not for power users. The ...
WhiteWinterWolf's user avatar
8 votes
Accepted

Why reading permission to /proc/1/maps is denied and why doesn't the denial appear in logcat?

REASON 1: Apart from traditional Discretionary Access Control (DAC), - that makes use of *NIX owner/group/mode of processes/files to allow/deny access - Android implements several other access ...
Irfan Latif's user avatar
  • 20.6k
8 votes

What does TWRP "Fix Contexts" do?

SELinux is a security mechanism which stops unauthorized access of processes to other processes, actions and filesystems (UNIX's "file" includes all regular files, directories, block devices, ...
Irfan Latif's user avatar
  • 20.6k
7 votes

How to unpack/repack system.img of android ROM?

These commands don't work always: sometimes the system_new.img size becomes greater than system.img.ext4 and hence it doesn't flash on the device. As per my knowledge, the new image size should be ...
Vatish Sharma's user avatar
6 votes
Accepted

What is 02 in the magisk patched vbmeta.img?

According to this piece of source code by Intel, there is an uint32_t starting at position0x78 (120) and ending at 0x7b (124). This location is marked as "flags from the AvbVBMetaImageFlags ...
Grimoire's user avatar
  • 2,959
5 votes

How to run a program in an app context with Magisk?

Android framework takes care of a lot of things when forking an app from zygote. In short, it's nearly impossible to run an app process from commandline so that it behaves “exactly the same way” as if ...
Irfan Latif's user avatar
  • 20.6k
4 votes
Accepted

How to make SELinux injected rules persistent without unpacking-packing boot.img?

The init service you have defined won't inject SELinux policy rules because of two reasons: The syntax of sepolicy-inject commands is incomplete; .rc files aren't shell scripts. The correct syntax ...
Irfan Latif's user avatar
  • 20.6k
4 votes

What sepolicy context will allow any other context to access it?

ROOT USER AND SELINUX: User root (with UID 0) is the super user in Discretionary Access Control (DAC) implementation of *NIX operating systems. DAC is allowed by-default i.e. anyone can access ...
Irfan Latif's user avatar
  • 20.6k
4 votes
Accepted

SELinux permissive kernel - is it a security risk?

SELinux is a security framework which restricts (kernel and userspace) processes within their domains according to defined policy. So the ultimate goal is to load a working policy, label filesystems ...
Irfan Latif's user avatar
  • 20.6k
3 votes
Accepted

How to fix: only official released binaries are allowed to be flashed(recovery) on device / FAIL! (Auth) on Odin3 v3.13?

For LZ4 compression: lz4 -B6 --content-size system.img.ext4 system.img.ext4.lz4 command can be used to make a valid Odin Flashable file. To Fix "FAIL! (Auth)", we need to truncate the vbmeta.img file ...
Vatish Sharma's user avatar
3 votes

How to set SELinux to Permissive

If SELinux Mode Changer doesn't work, and you are properly rooted, then your kernel likely isn't compiled with permissive mode and was compiled with the flag EXTRA_CFLAGS += -DCONFIG_ALWAYS_ENFORCE=...
acejavelin's user avatar
  • 6,197
3 votes

SELinux denials after migrating application data between devices

On newer Android versions the process mentioned in the question and comment is not sufficient. In my experience on LineageOS 20 (that is Android 13), the following changes were needed: The cache and ...
Andrzej Szombierski's user avatar
2 votes
Accepted

SELinux prevents my init.rc exec command to execute

I finally managed to solve the problem. There are two problems: You're not using the "exactly the same identity of adb shell". There are a couple of groups to which adb shell belongs but they're not ...
frogatto's user avatar
  • 157
2 votes
Accepted

What is SELinux and its purpose?

The purpose of SElinux is for security and explained by the Android site: As part of the Android security model, Android uses SELinux to enforce mandatory access control (MAC) over all processes, ...
Bo Lawson's user avatar
  • 2,588
2 votes

How to make SELinux injected rules persistent without unpacking-packing boot.img?

I know the question was asked quite some time ago, but since I tried doing something similar recently and this post was one of the top hits on Google, I want to share my recent experience to help ...
Alhyoss's user avatar
  • 41
2 votes

SELinux Policy from Permissive to Enforcing

If a custom ROM has SEL set to enforcing, it means the dev is confident that features are working under strict SEL, and you can safely change it to permissive knowing that things will continue to work ...
Andy Yan's user avatar
  • 9,539
2 votes

how to extend support for EXT4 file system for microSD cards in stock or non lineage / CyanogenMod ROMS

I don't think I understand your question fully. It's not clear what and how you have tried so far and faced what constraints or limitations in achieving what you want to. But precisely answering your ...
Irfan Latif's user avatar
  • 20.6k
2 votes

How to mount system under super partion?

On devices with enough disk space one can convert ext4-dedup dynamic partition into r/w system partition. This can be done offline on linux computer using (official) Dynamic Partition Tools lpunpack ...
alecxs's user avatar
  • 4,074
1 vote
Accepted

How to add SELinux policy on a user-debug ROM that has `split` policy scheme?

To patch the policies, do the following: Change the value in /system/etc/selinux/plat_and_mapping_sepolicy.cil.sha256 OR empty this file. Inject required policies in /system/etc/selinux/plat_sepolicy....
Vatish Sharma's user avatar
1 vote
Accepted

SELinux always set to permissive, how to set enforcing permanently?

See this answer and this issue for details on how SELinux is enforced on Android. In short it depends on cmdline parameters of kernel and build configuration of init. Check on your device: ~# cat /...
Irfan Latif's user avatar
  • 20.6k
1 vote

How to unpack/repack system.img of android ROM?

Easy and it works: truncate --size=3000M system.img mke2fs -t ext4 -L system_rw system_rw.img sudo mount system_rw.img sudo cp -R --preserve=all /path_to_the_ronly_system.img_mountpoint/. /...
Tahypro87's user avatar
1 vote

How to disable dm-verity on Android with "user" build type ROM?

You can just edit the Magisk root package to ONLY disable the dm-verity flag. It's literally just commenting out a few lines of Magisk scripts, since the functionality is inherently present in Magisk. ...
user145453's user avatar
1 vote

lsusb returns "permission denied" in Termux

lsusb command lists entries in /sys/bus/usb/devices which is world-readable but SELinux would be denying access because u:r:untrusted_app:s0 context isn't allowed to access u:object_r:sysfs:s0. ...
Irfan Latif's user avatar
  • 20.6k
1 vote

Fix SELinux contexts for a SU binary

Apps can't elevate their privileges by making use of set-uid-root or file capabilities. It's due to Security Enhancements in Android 4.3: No setuid/setgid programs. Added support for filesystem ...
Irfan Latif's user avatar
  • 20.6k
1 vote
Accepted

Checking SELinux permissions in Android?

I found a tool in the AOSP /system/sepolicy/tools/sepolicy-check. You need to compile it and run it on the host not on the target, but it will evaluate your allow rules and let you check permission ...
mjh2007's user avatar
  • 131

Only top scored, non community-wiki answers of a minimum length are eligible