Android Architecture & the Linux Kernel
Android Internals · Mobile Internals track
5 min read
In this module
The Android Stack
Android sits on top of the Linux kernel, but call it a Linux distro and any kernel maintainer will laugh. Google has hacked at the kernel, swapped out the userland wholesale, and bolted a managed runtime on top. To do Android security work you need a feel for those layers, especially the kernel-level changes.
The architecture is usually drawn as a five-layer stack — each layer feeds the one above.
The Linux Kernel Layer
The bottom of the stack is a modified Linux kernel. Vendors and devices ship different mainline versions, and on top of whichever they chose Google bolts a handful of Android-only subsystems.
Binder: The IPC Backbone
The headliner is the Binder driver (/dev/binder), a kernel-level IPC built specifically for Android's object-oriented service model. Pipes and sockets weren't a fit. Every app-to-service call — permission checks, drawing a window, playing audio — rides over Binder. Lesson 4 takes the whole thing apart.
Wakelocks: Power Management
Battery is everything on a phone. The kernel's wakelock system lets apps and drivers pin the CPU awake while they're doing something that can't be interrupted. Acquire a wakelock and the device stays up; only when every last wakelock is dropped does the kernel actually suspend.
# Viewing active wakelocks on a rooted device$ cat /sys/power/wake_lockPowerManagerService.WakeLocks sensor_ind bluetooth_timerMainline Linux folks have long hated wakelocks for breaking the standard power-management model. Android needed them anyway. Aggressive suspend is non-negotiable on a phone.
Anonymous Shared Memory (ashmem)
Android's ashmem (anonymous shared memory) is a simple way for processes to share buffers. The party trick is reclaim: under memory pressure the kernel can ditch unpinned ashmem regions without killing the owning process. POSIX shm doesn't do that. Newer kernels mostly use memfd instead, but ashmem still lurks in older devices.
Android extends the Linux kernel with several custom subsystems: Binder (IPC driver), wakelocks (CPU sleep control), and historically ashmem (reclaimable shared memory). These pieces make Android's mobile-tuned architecture work, and they widen the kernel attack surface beyond what you'd see on stock Linux.
The Hardware Abstraction Layer (HAL)
Above the kernel sits the HAL (Hardware Abstraction Layer). Every hardware bit — camera, GPS, Bluetooth, sensors — has a HAL module exposing a standard interface, so the framework can drive the hardware without caring whose silicon it is.
HALs used to live as shared libraries dlopen'd straight into the calling process. Since Android 8.0 (Project Treble), HALs run in their own processes behind a defined interface. Treble introduced HIDL (HAL Interface Definition Language) for that; Android 11 began allowing AIDL for HALs, and since Android 13 HIDL is deprecated and new HALs use AIDL. The benefit is straightforward: a bug in a camera HAL stops short of the system server.
Native Libraries and ART
The middle layers carry the native C/C++ libraries (Bionic libc, OpenGL ES, media codecs, SQLite) and the Android Runtime (ART) itself. ART runs your app code; it replaced Dalvik back in Android 5.0.
It isn't a traditional JVM. ART uses a register-based bytecode (DEX), a peculiar hybrid compilation strategy (lesson 3 unpacks it), and threads itself through Android's memory management and security plumbing.
ART doesn't start from scratch for every app. At boot, init launches zygote, a process that loads ART and preloads the common framework classes once. Every app process is a fork() of zygote, so it begins life sharing those pages copy-on-write and only pays for the memory it changes. That's also why every app in the ps listing further down has the same parent PID.
The Application Framework
The Application Framework is the Java/Kotlin API surface every app developer touches. Notable residents:
- ActivityManager: Manages the lifecycle of application components (activities, services, broadcast receivers).
- PackageManager: Handles app installation, permissions, and package queries.
- WindowManager: Controls window placement and compositing.
- ContentProviders: Mediate structured data access between apps.
All those services live inside the system_server process — one of the juiciest targets on the device. A bug in system_server hands the attacker the keys to app lifecycles, permission enforcement, and hardware access in one go.
Security Architecture Overview
Android security pulls on several kernel-level levers at once:
- UID isolation: every app gets its own Linux UID at install. Plain old Unix file permissions then keep apps out of each other's data.
- Process isolation: each app runs in its own process with its own ART instance.
- SELinux: mandatory access control with a default-deny policy (lesson 2).
- Seccomp-BPF: filters which syscalls an app can issue, shrinking the kernel surface it can reach.
# Each app gets a unique UID (u0_a prefix)$ ps -A | grep com.exampleu0_a182 12345 567 ... com.example.myappu0_a203 12346 567 ... com.example.otherapp# Different UIDs = different Unix users = file isolationStack those together and an attacker who lands code execution inside an app is still boxed in by UID isolation, SELinux policy, and seccomp filtering. Climbing from app-level compromise to system-level access means defeating each one independently.