Using Hardware Performance Events for Instruction-Level Monitoring on the x86 Architecture Sebastian Vogl and Claudia Eckert {vogls,eckertc}@in.tum.de Chair for IT Security Technische Universität München Munich, Germany 10.04.2012 S. Vogl and C. Eckert (TUM) 10.04.2012 1 / 42
Outline Motivation 1 Performance Monitoring Counters (PMCs) 2 PMC-based Instruction-level Monitoring (ILM) 3 Experiments & Results 4 Summary 5 S. Vogl and C. Eckert (TUM) 10.04.2012 2 / 42
Outline Motivation 1 Performance Monitoring Counters (PMCs) 2 PMC-based Instruction-level Monitoring (ILM) 3 Experiments & Results 4 Summary 5 S. Vogl and C. Eckert (TUM) 10.04.2012 3 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? My Research Make use of full hardware virtualization to detect malware infections and exploitation attempts . S. Vogl and C. Eckert (TUM) 10.04.2012 4 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main DATA 400707: call 400584 <vulnerable> 40070c: mov 0x0, %EAX vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 5 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main DATA 400707: call 400584 <vu 0x40070c (RET) vuln lner erab able le> 40070c: mov 0x0, %EAX vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 6 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main DATA 400707: call 400584 <vulnerable> 0x40070c (RET) 40070c: mov 0x0, %EAX RBP vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 7 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main DATA 400707: call 400584 <vulnerable> 0x40070c (RET) 40070c: mov 0x0, %EAX RBP vulnerable 400584: push %rbp 400585: mov %rsp,% ,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 8 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main DATA 400707: call 400584 <vulnerable> 0x40070c (RET) 40070c: mov 0x0, %EAX RBP BUFFER vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 9 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main * /bin/bash DATA exit 400707: call 400584 <vulnerable> system 40070c: mov 0x0, %EAX DATA (EBP) vulnerable DATA 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 10 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main * /bin/bash DATA exit 400707: call 400584 <vulnerable> system 40070c: mov 0x0, %EAX DATA (EBP) vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: : leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 11 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main * /bin/bash DATA exit 400707: call 400584 <vulnerable> 40070c: mov 0x0, %EAX system vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> 4006b2: leave 4006b3: ret system S. Vogl and C. Eckert (TUM) 10.04.2012 12 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? One possible Solution Make use of a Shadow Stack to verify the target of return instructions. S. Vogl and C. Eckert (TUM) 10.04.2012 13 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main DATA 400707: call 400584 <vulnerable> 40070c: mov 0x0, %EAX vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> Shadow Stack 4006b2: leave 4006b3: ret S. Vogl and C. Eckert (TUM) 10.04.2012 14 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main DATA 400707: call 400584 <vu 0x40070c (RET) vuln lner erab able le> 40070c: mov 0x0, %EAX vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> Shadow Stack 4006b2: leave 4006b3: ret 0x40070c (RET) S. Vogl and C. Eckert (TUM) 10.04.2012 15 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Stack main * /bin/bash DATA exit 400707: call 400584 <vu vuln lner erab able le> 40070c: mov 0x0, %EAX system vulnerable 400584: push %rbp 400585: mov %rsp,%rbp 400588: sub $0x20,%rsp <vulnerable code> Shadow Stack 4006b2: leave 4006b3: ret 0x40070c (RET) system EIP: system S. Vogl and C. Eckert (TUM) 10.04.2012 16 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Observation A Shadow Stack for return addresses can be implemented on the hypervisor-level by only trapping call and return instructions. S. Vogl and C. Eckert (TUM) 10.04.2012 17 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Observation A Shadow Stack for return addresses can be implemented on the hypervisor-level by only trapping call and return instructions. ILM Requirements Based on full hardware virtualization 1 S. Vogl and C. Eckert (TUM) 10.04.2012 17 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Observation A Shadow Stack for return addresses can be implemented on the hypervisor-level by only trapping call and return instructions. ILM Requirements Based on full hardware virtualization 1 Secure 2 S. Vogl and C. Eckert (TUM) 10.04.2012 17 / 42
Motivation ▸ Why Instructions-Level Monitoring (ILM) ? Observation A Shadow Stack for return addresses can be implemented on the hypervisor-level by only trapping call and return instructions. ILM Requirements Based on full hardware virtualization 1 Secure 2 Flexible 3 S. Vogl and C. Eckert (TUM) 10.04.2012 17 / 42
Motivation ▸ Why a new ILM mechanism? Existing Approaches Page-Fault (PF) -based ILM 1 Debug Register (DR) -based ILM 2 Trap Flag (TF) -based ILM 3 S. Vogl and C. Eckert (TUM) 10.04.2012 18 / 42
Motivation ▸ Why a new ILM mechanism? Existing Approaches Page-Fault (PF) -based ILM 1 Debug Register (DR) -based ILM 2 3 Trap Flag (TF)-based ILM S. Vogl and C. Eckert (TUM) 10.04.2012 19 / 42
Motivation ▸ Why a new ILM mechanism? Existing Approaches Page-Fault (PF) -based ILM 1 Debug Register (DR) -based ILM 2 3 Trap Flag (TF)-based ILM ▸ Insecure S. Vogl and C. Eckert (TUM) 10.04.2012 19 / 42
Motivation ▸ Why a new ILM mechanism? Existing Approaches Page-Fault (PF) -based ILM 1 Debug Register (DR) -based ILM 2 3 Trap Flag (TF)-based ILM ▸ Insecure ▸ Incomplete S. Vogl and C. Eckert (TUM) 10.04.2012 19 / 42
Motivation ▸ Why a new ILM mechanism? Existing Approaches Page-Fault (PF) -based ILM 1 Debug Register (DR) -based ILM 2 3 Trap Flag (TF)-based ILM ▸ Insecure ▸ Incomplete ▸ Inflexible S. Vogl and C. Eckert (TUM) 10.04.2012 19 / 42
Motivation ▸ Why a new ILM mechanism? Existing Approaches Page-Fault (PF) -based ILM 1 Debug Register (DR) -based ILM 2 3 Trap Flag (TF)-based ILM ▸ Insecure ▸ Incomplete ▸ Inflexible ⇒ None of the existing methods can provide the desired flexbility . S. Vogl and C. Eckert (TUM) 10.04.2012 19 / 42
Outline Motivation 1 Performance Monitoring Counters (PMCs) 2 PMC-based Instruction-level Monitoring (ILM) 3 Experiments & Results 4 Summary 5 S. Vogl and C. Eckert (TUM) 10.04.2012 20 / 42
Performance Monitoring Counters (PMCs) ▸ Overview Performance Monitoring on the x86 architecture Performance Events S. Vogl and C. Eckert (TUM) 10.04.2012 21 / 42
Performance Monitoring Counters (PMCs) ▸ Overview Performance Monitoring on the x86 architecture Performance Events PMCs that count these events S. Vogl and C. Eckert (TUM) 10.04.2012 21 / 42
Performance Monitoring Counters (PMCs) ▸ Overview Performance Monitoring on the x86 architecture Performance Events PMCs that count these events ▸ Which event is counted can be programmed. S. Vogl and C. Eckert (TUM) 10.04.2012 21 / 42
Performance Monitoring Counters (PMCs) ▸ Overview Performance Monitoring on the x86 architecture Performance Events PMCs that count these events ▸ Which event is counted can be programmed. ▸ Can be set to raise an interrupt on overflow. S. Vogl and C. Eckert (TUM) 10.04.2012 21 / 42
Performance Monitoring Counters (PMCs) ▸ Performance Events All instructions ▸ All branch instructions ▸ All conditional branch instructions ▸ All near call instructions ▸ All near return instructions ▸ All far branch instructions ▸ S. Vogl and C. Eckert (TUM) 10.04.2012 22 / 42
Outline Motivation 1 Performance Monitoring Counters (PMCs) 2 PMC-based Instruction-level Monitoring (ILM) 3 Experiments & Results 4 Summary 5 S. Vogl and C. Eckert (TUM) 10.04.2012 23 / 42
Recommend
More recommend