Sunday, June 8, 2025

Android file systems

/boot contains the kernel and ram disk. 

/system contains the rest of the Linux system. 

*/recovery contains Viber for recovery mode 

/data contains application data

*/cache contains frequently access data and logs

*/misc contains miscellaneous setting for the device. 

/sdcard contains info of data in sd card 

SELinux

Security enhanced Linux is a feature in Android. Discretionary access control DAC means application can ask for permission from user. Thus helped malware. Mandatory access control MAC ensure app work in isolation, included those running as root, and not able to corrupt the OS and device.  SELinux is used to enforce MAC. 

Trusted Executive Enviroment

TEE is an isolated area usually a separate processor which can guantee the security of data stored in it. When the cpu need to access these data, it delegated the operation to TEE. 

Android architecture

Android Inc was a start up and bought over by Google. Android uses a Linux kernel with the drivers for the phone hardware. The next higher layers are the HAL hardware abstract layer which expose the hardware to the upper layers. 

The next layer is the Android native library written in c it c++. WebKit, sqllit, media framework, c run time and OpenGL etc.  The Android runtime layer support the java app. 

Android translate the java byte code into dalvik byte code which is more optimised for low memory and processing. The dalvik byte code then run in a dalvik vm. The .class files are also consolidated and changed to  a single.dex. 

Earlier version of Android use JIT compiler in dalvik which translate segment of code which is used repeatedly (called traces) into machine code. Later version uses ahead of time AOT compilation which compile the whole byte codes to native code in ELF form during app installation. 

The next upper layer is the Java API framework which support the applications. 

Saturday, June 7, 2025

IOS operation modes

Normal mode is when iPhone was started in the usual way, going through a secure boot chain. The boot ROM contains the apple root CA public key is used to verify the next stage low level boot loader (LLB) is signed by apple or not before executing it. LLB finishes its work and load the second stage boot loader, iBoot, which load the iOS kernel

Recovery mode is entered if  any stage in the secure boot chain fails. The iPhone requires an upgrade or restoration to exit from recovery mode. 

Device Firmware Upgrade (DFU)  is entered when boot ROM cannot verifies or loads LLB. In DFU, a different boot sequence will be used. Boot ROM runs iBSS, a modified version of iBoot. It in turn runs iBEC that loads the kernel which loads the RAM disk. 

IOS

iOS is derived from OS X. The latter is open sourced but the former is proprietary. 

IOS architecture consists of 4 layers. Cocoa Touch layer implementation the ui for application and provide support for touch based input and multitasking. 

The media layer provide graphic, audio and video framework. 

The core derives layer provide fundamental services for application such as location, iCloud and social media services. 

The core OS layer provide networking , memory management, POSIX threading, filesystem etc. 

iPhone partition

The system partition is about 3G large. It is mounted read only. It changes to RW when being upgrade and itune reformat and rewrite it.  The user partition is mounted RW