domenica 16 agosto 2015

Samsung SIII, Stagefright and Cyanogenmod 11

2015-09-01: Update
Cyanogenmod issued a new version of CM11 for the samsung SIII (intl) https://download.cyanogenmod.org/?device=i9300&type=snapshot

2015-08-17: Update
It seems that Cyanogenmod will issue an update also for CM11: http://www.cyanogenmod.org/blog/more-stagefright

Introduction
I have a Samsung S3 phone equipped with Cyanogenmod 11. I chosen Cyanogenmod because I believe the community support is better than the Samsung one. Unfortunately the Stagefright bugs [1] highlighted a different reality: if I want to use Android 4.x on my phone I will not be protect by the Stagefright bugs.
To be honest, Cyanogenmod 12 is (will be) patched from this bug, but I don't want to use this version because I don't like it.
Instead Samsung seems to don't support anymore this phone; so no update will be available. Pay attention that on the basis of the OpenSignal data, the Samsung SIII is still one of the most diffuse devices [2].
To check if my phone is vulnerable, I used the Stagefright Detector app [3]. The results are shown below.
On the site of Zimperium it is possible to access to the patches which fix the bug [4].

Fixing my phone
USE THESE INFORMATION AT YOUR OWN RISK; PLEASE BE AWARE THAT ANY INFORMATION YOU MAY FIND HERE MAY BE INACCURATE, MISLEADING, DANGEROUS.
I followed the Cyanogenmod tutorial [5] to compile the source.
First, I downloaded the Cyanogenmod source [7] (be patient, I needed 18h to download all the source) and I applied the Zimperium patches. I had to adapt the patches to the downloaded source: some patches were not applicable (may be these are related to more recent source) and others were already applied. So I applied only 7 patches. You can download the source from my github-repository [6].
I compiled only the frameworks/av module with the command mma, then I copied the file "$(OUT_DIR)/target/product/i9300/obj/lib/libstagefright.so" in /system/libs. Pay attention that I had to remount the /system filesystem read-write in order to copy the library on the phone.
Links
[1] https://en.wikipedia.org/wiki/Stagefright_(bug)
[2] http://opensignal.com/reports/2015/08/android-fragmentation/
[3] https://play.google.com/store/apps/details?id=com.zimperium.stagefrightdetector&hl=en
[4] https://blog.zimperium.com/stagefright-vulnerability-details-stagefright-detector-tool-released
[5] https://wiki.cyanogenmod.org/w/Build_for_i9300
[6] https://github.com/kreijack/android_frameworks_av.git branch cm11-zimperium-patches
[7] repo init -u https://github.com/CyanogenMod/android.git -b cm-11.0; repo sync

My little patches...

Below a list of my patches spread on different projects: Linux kernel [all] 2018-02-01 iversion: Rename make inode_cmp_iversion{+raw}...