Huawei Frame Buffer Driver Arbitrary Memory Write

Similar documents
MediaTek Log Filtering Driver Information Disclosure

Finding User/Kernel Pointer Bugs with Type Inference p.1

Unleashing D* on Android Kernel Drivers. Aravind Machiry

SA30228 / CVE

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

(Early) Memory Corruption Attacks

General Pr0ken File System

Escalating Privileges in Linux using Fault Injection. September 25, 2017

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

Linux Kernel Exploitation. Where no user has gone before

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

Secure Software Development: Theory and Practice

The Kernel Abstraction. Chapter 2 OSPP Part I

Exploits and gdb. Tutorial 5

System Security Class Notes 09/23/2013

ECE 471 Embedded Systems Lecture 22

Important From Last Time

Exploiting USB/IP in Linux

Static Vulnerability Analysis

Trinity A Linux kernel fuzz tester.

Lecture 4 September Required reading materials for this class

EL2310 Scientific Programming

Verification & Validation of Open Source

Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan

Buffer overflow background

How Double-Fetch Situations turn into Double-Fetch Vulnerabilities:

Leveraging CVE for ASLR Bypass & RCE. Gal De Leon & Nadav Markus

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics.

User Programs. Computer Systems Laboratory Sungkyunkwan University

Defeat Exploit Mitigation Heap Attacks. compass-security.com 1

Is stack overflow still a problem?

Android Kernel Security

CSE 509: Computer Security

Program Security and Vulnerabilities Class 2

Secure Coding Techniques

CS 550 Operating Systems Spring Interrupt

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software.

New York University CSCI-UA : Advanced Computer Systems: Spring 2016 Midterm Exam

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

On The Effectiveness of Address-Space Randomization. H. Shacham, M. Page, B. Pfaff, E.-J. Goh, N. Modadugu, and D. Boneh Stanford University CCS 2004

CNIT 127: Exploit Development. Ch 18: Source Code Auditing. Updated

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS)

CSC369 Lecture 2. Larry Zhang

CMPSC 497 Buffer Overflow Vulnerabilities

CSC369 Lecture 2. Larry Zhang, September 21, 2015

MWR InfoSecurity Security Advisory. Linux USB Device Driver - Buffer Overflow. 29 th October Contents

About unchecked management SMM & UEFI. Vulnerability. Patch. Conclusion. Bruno Pujos. July 16, Bruno Pujos

Automatic Source Audit with GCC. CoolQ Redpig Fedora

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

Project 2-1 User Programs

Buffer overflows (a security interlude) Address space layout the stack discipline + C's lack of bounds-checking HUGE PROBLEM

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

CS 550 Operating Systems Spring System Call

Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08

CSE 565 Computer Security Fall 2018

TDDB68 Lesson 2 Pintos Assignments 3 & 4. Mattias Eriksson 2010 (or

Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit

Overview REWARDS TIE HOWARD Summary CS 6V Data Structure Reverse Engineering. Zhiqiang Lin

Secure Architecture Principles

CSCE 548 Building Secure Software Integers & Integer-related Attacks & Format String Attacks. Professor Lisa Luo Spring 2018

Tolerating Hardware Device Failures in Software. Asim Kadav, Matthew J. Renzelmann, Michael M. Swift University of Wisconsin Madison

RBS NetGain Enterprise Manager Multiple Vulnerabilities of 11

CS61 Scribe Notes Lecture 18 11/6/14 Fork, Advanced Virtual Memory

SA31675 / CVE

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable)

10. I/O System Library

Security and Privacy in Computer Systems. Lecture 5: Application Program Security

Introduction to Computer Systems , fall th Lecture, Sep. 28 th

When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to.

ISA564 SECURITY LAB. Code Injection Attacks

Fault Injection in System Calls

Operating Systems 2010/2011

Important From Last Time

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

putting m bytes into a buffer of size n, for m>n corrupts the surrounding memory check size of data before/when writing

prin'() tricks DC4420 slides, Feb 2012

Secure Programming. Input Validation. Learning objectives Code Injection: Outline. 4 Code Injection

Introduction to Programming (Java) 4/12

Lecture 10. Pointless Tainting? Evaluating the Practicality of Pointer Tainting. Asia Slowinska, Herbert Bos. Advanced Operating Systems

TIP675-SW-82. Linux Device Driver. 48 TTL I/O Lines with Interrupts Version 1.2.x. User Manual. Issue November 2013

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES

Systems Programming and Computer Architecture ( )

EL2310 Scientific Programming

typedef void (*type_fp)(void); int a(char *s) { type_fp hf = (type_fp)(&happy_function); char buf[16]; strncpy(buf, s, 18); (*hf)(); return 0; }

CYSE 411/AIT681 Secure Software Engineering Topic #12. Secure Coding: Formatted Output

2/9/18. CYSE 411/AIT681 Secure Software Engineering. Readings. Secure Coding. This lecture: String management Pointer Subterfuge

SA28083 / CVE

Advanced Systems Security: Ordinary Operating Systems

EECS 482 Introduction to Operating Systems

CS61 Scribe Notes Date: Topic: Fork, Advanced Virtual Memory. Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu

Simple Overflow. #include <stdio.h> int main(void){ unsigned int num = 0xffffffff;

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC

c-lambda: C FFI via raco ctool

Rooting Routers Using Symbolic Execution. Mathy HITB DXB 2018, Dubai, 27 November 2018

String Oriented Programming Exploring Format String Attacks. Mathias Payer

Analysis of MS Multiple Excel Vulnerabilities

CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES

CSc 466/566. Computer Security. 20 : Operating Systems Application Security

INTRODUCTION TO EXPLOIT DEVELOPMENT

Transcription:

Huawei Frame Buffer Driver Arbitrary Memory Write 18/07/2017 Software Affected Versions Author Severity Vendor Vendor Response MediaTek Frame Buffer Driver Huawei Y6 Pro Dual SIM (TIT-L01C576B115) Mateusz Fruba High Huawei Fix Released Description: Huawei is a company that provides networking and telecommunications equipment. The MediaTek frame buffer driver, as shipped with Huawei Y6 Pro, implements an IOCTL interface vulnerable to an arbitrary memory write due to insufficient input validation. Impact: Local processes running in the context of a system application, media server, or system server can leverage the frame buffer driver memory corruption to escalate their privileges to root or kernel. Cause: The MediaTek frame buffer driver fails to validate user-supplied data. Solution: This vulnerability was resolved by Huawei in version TIT-L01C576B119. More information can be found on the Huawei web page: http://www.huawei.com/en/psirt/security-advisories/huawei-sa-20170527-01-smartphone-en 1

Technical details The MediaTek frame buffer driver implements the mtkfb_ioctl IOCTL handler which receives data passed from user space to the kernel. This driver is implemented in /drivers/misc/mediatek/videox/mt6735/. When mtkfb_ioctl is called, the pbuf variable is user-controlled and copied from user space in mtkfb_ioctl using copy_from_user. This can be seen below: static int mtkfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) void user *argp = (void user *)arg; DISP_STATUS ret = 0; int r = 0; switch (cmd) case MTKFB_CAPTURE_FRAMEBUFFER: unsigned long pbuf = 0; else dprec_logger_start(dprec_logger_wdma_dump, 0, 0); primary_display_capture_framebuffer_ovl(pbuf, ebgra8888); dprec_logger_done(dprec_logger_wdma_dump, 0, 0); The primary_display_capture_framebuffer_ovl function is then called with the pbuf variable set to the value passed from user space. 2

The primary_display_capture_framebuffer_ovl function makes use of memset and casts the unsigned long value to a void pointer without any verification as follows: int primary_display_capture_framebuffer_ovl(unsigned long pbuf, unsigned int format) if (pgc->state == DISP_SLEEPED) if (!primary_display_cmdq_enabled()) if (_is_decouple_mode(pgc->session_mode) _is_mirror_mode(pgc->session_mode)) primary_display_capture_framebuffer_decouple(pbuf, format); ret = m4u_alloc_mva(m4uclient, M4U_PORT_DISP_WDMA0, pbuf, NULL, buffer_size, M4U_PROT_READ M4U_PROT_WRITE, 0, (unsigned int*)&mva); ret = m4u_cache_sync(m4uclient, M4U_PORT_DISP_WDMA0, pbuf, buffer_size, mva, M4U_CACHE_FLUSH_BY_RANGE); This leads to control of the destination address for memset, thus allowing to zero out arbitrary memory. Following this, we see that pbuf is passed as an argument to primary_display_capture_framebuffer_decouple and used without any validation while calculation the destination address for a write operation. int primary_display_capture_framebuffer_decouple(unsigned long pbuf, unsigned int format) for (i = 0; i<h_yres; i++) for (j = 0; j<w_xres; j++) memcpy((void*)tem_va, (void*)src_va, 4); *(unsigned long*)(pbuf + (i*w_xres + j) * 4) = 0xFF000000 (tem_va[0] << 16) (tem_va[1] << 8) (tem_va[2]); The lack of input validation in this function allows malicious attackers to provide values that can result in an arbitrary memory write. 3

The following crash is observed when this vulnerability is triggered: 2652.261167]<0> (0)[6016:MTKFB_CAPTURE_F][DISP]func mtkfb_open [ 2652.262092]<0> (0)[6016:MTKFB_CAPTURE_F][DISP]func mtkfb_ioctl [ 2652.262107]<0> (0)[6016:MTKFB_CAPTURE_F]mtkfb_ioctl, info=ffffffc078442800, cmd nr=0x00000003, cmd size=0x00000008 [ 2652.262119]<0> (0)[6016:MTKFB_CAPTURE_F][DISP]primary capture: begin [ 2652.262136]<0> (0)[6016:MTKFB_CAPTURE_F]Unable to handle kernel paging request at virtual address 4142424244 [ 2652.262148]<0> (0)[6016:MTKFB_CAPTURE_F]pgd = ffffffc047571000 [ 2652.262157][4142424244] *pgd=0000000000000000 [ 2652.262170]<0> (0)[6016:MTKFB_CAPTURE_F][KERN Warning] ERROR/WARN forces debug_lock off! [ 2652.262180]<0> (0)[6016:MTKFB_CAPTURE_F][KERN Warning] check backtrace: [ 2659.832215]<0>-(0)[6016:MTKFB_CAPTURE_F]CPU: 0 PID: 6016 Comm: MTKFB_CAPTURE_F Tainted: G W 3.10.65 #1 [ 2659.832233]<0>-(0)[6016:MTKFB_CAPTURE_F]task: ffffffc04d30a000 ti: ffffffc0398c8000 task.ti: ffffffc0398c8000 [ 2659.832250]<0>-(0)[6016:MTKFB_CAPTURE_F]PC is at memset+0x1c/0x60 [ 2659.832268]<0>-(0)[6016:MTKFB_CAPTURE_F]LR is at primary_display_capture_framebuffer_ovl+0x2b4/0x498 [ 2659.832281]<0>-(0)[6016:MTKFB_CAPTURE_F]pc : [<ffffffc0002e8f4c>] lr : [<ffffffc000495840>] pstate: 20000145 [ 2659.832292]<0>-(0)[6016:MTKFB_CAPTURE_F]sp : ffffffc0398cba50 [ 2659.832301]x29: ffffffc0398cba50 x28: ffffffc0398c8000 [ 2659.832318]x27: ffffffc000dbf000 x26: ffffffc001077ef0 [ 2659.832334]x25: 0000000001002002 x24: 0000000000000500 [ 2659.832349]x23: 00000000000002d0 x22: 0000004142424244 [ 2659.832365]x21: ffffffc001077ea8 x20: 0000000000000000 [ 2659.832380]x19: ffffffc001077000 x18: 0000000000000001 [ 2659.832395]x17: 0000007f8737d350 x16: ffffffc00010dc0c [ 2659.832410]x15: 0000000000000000 x14: 0000000000020000 [ 2659.832425]x13: 000000000001aa78 x12: 0000000000000001 [ 2659.832441]x11: 0000000000000058 x10: ffffffc000bb1bb8 [ 2659.832457]x9 : 00000000000042da x8 : 000000000000fc40 [ 2659.832472]x7 : 0000000000000048 x6 : 000000000000b9ae [ 2659.832486]x5 : 000000000000000a x4 : 0000004142424244 [ 2659.832500]x3 : 0000000000000001 x2 : 0000000000383ff8 [ 2659.832516]x1 : 0000000000000000 x0 : 0000004142424244 As shown in the above crash log it was possible to force MediaTek frame buffer to put 0x4142424244 value as destination address for memset function what caused kernel panic, as this user space address was currently not mapped within process address space. 4

Detailed Timeline Date Summary 2017-03-28 Issue reported to Huawei. 2017-06-05 Huawei confirmed this issue was fixed in version TIT-L01C576B119. 5