‘struct sigcontext’ On using Linux’s signaling mechanism for debugqing application programs.

Slides:



Advertisements
Similar presentations
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
Advertisements

The ‘system-call’ interface We see how an application program can invoke privileged kernel services.
Page-Faults in Linux How can we study the handling of page-fault exceptions?
Context Switch Animation Another one by Anastasia.
COS318 Lec 21 Operating System Structures Vivek Pai Princeton University.
Project 2 Roadmap. Background – Context Switching One processor and multiple threads running concurrently – How?!! Give each thread a small time quantum.
Context switch in Linux
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages.
Cse322, Programming Languages and Compilers 1 6/18/2015 Lecture #16, May 24, 2007 Runtime.c Running the code debugging assembler division strings for println.
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
ICS312 Set 3 Pentium Registers. Intel 8086 Family of Microprocessors All of the Intel chips from the 8086 to the latest pentium, have similar architectures.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
8086 emulation Using Virtual-8086 mode to execute real-mode procedures in a protected-mode environment.
ESP int f(int x) {.... } int g(int y) { …. f(2); …. } int main() { …. g(1); …. } EIP 100: 200: 250: 300: 350:
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
6.828: PC hardware and x86 Frans Kaashoek
Practical Session 4. Labels Definition - advanced label: (pseudo) instruction operands ; comment valid characters in labels are: letters, numbers, _,
1 #include void silly(){ char s[30]; gets(s); printf("%s\n",s); } main(){ silly(); return 0; }
Derived from "x86 Assembly Registers and the Stack" by Rodney BeedeRodney Beede x86 Assembly Registers and the Stack Nov 2009.
Other Processors. Having learnt MIPS, we can learn other major processors. Not going to be able to cover everything; will pick on the interesting aspects.
Chapter 4 Process Abstraction Chien-Chung Shen CIS, UD
(-133)*33+44* *33+44*14 Input device memory calculator Output device controller Control bus data bus memory.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Register Allocation Harry Xu CS 142 (b) 02/11/2013.
6. HAL and IDT ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section  Hardware Abstraction Layer ◦ Section
X86 Assembly Language We will be using the nasm assembler (other assemblers: MASM, as, gas)
Chapter 2 The Microprocessor Architecture Microprocessors prepared by Dr. Mohamed A. Shohla.
What You Need to Know for Project Three Steve Muckle Wednesday, February 19 th Spring 2003.
EXPLOITATION CRASH COURSE – FALL 2013 UTD Computer Security Group – Andrew Folloder csg.utdallas.edu (credit: Scott Hand)
Microprocessor, Programming & Interfacing Tutorial 2- Module 3.
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
Lecture 7 Interrupt ,Trap and System Call
Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 4, 2010 CSCE 212Honors Computer Organization.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Virtualizing the CPU: Processes 1. How to provide the illusion of many CPUs? CPU virtualizing – The OS can promote the illusion that many virtual CPUs.
Chapter Overview General Concepts IA-32 Processor Architecture
Exploiting & Defense Day 1 Recap
Assembly function call convention
Homework / Exam Return and Review Exam #1 Reading Machine Projects
Assembly language.
C function call conventions and the stack
Operating Systems Engineering
Programming the I/O Hardware
CS-401 Computer Architecture & Assembly Language Programming
Computer Architecture and Assembly Language
Other Processors.
Anton Burtsev February, 2017
ICS143A: Principles of Operating Systems Lecture 13: Context switching
CSCE 212Honors Computer Organization
Exploiting & Defense Day 2 Recap
Aaron Miller David Cohen Spring 2011
Basic Microprocessor Architecture
Assembly IA-32.
Programming the I/O Hardware
Assembly Language Programming II: C Compiler Calling Sequences
CS 301 Fall 2002 Computer Organization
Discussions on HW2 Objectives
The Microprocessor & Its Architecture
Tutorial No. 11 Module 10.
Computer Architecture CST 250
Discussions on HW2 Objectives
Low-Level Thread Dispatching on the x86
CSCE 212Honors Computer Organization
Computer Architecture and System Programming Laboratory
Computer Architecture and System Programming Laboratory
Register Allocation Harry Xu CS 142 (b) 05/08/2018.
Presentation transcript:

‘struct sigcontext’ On using Linux’s signaling mechanism for debugqing application programs

Installing a signal-handler #include <signal.h> void handler( int signo, siginfo_t *si, void *sc ); int main( void ) { struct sigaction oa, sa = {0}; sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = handler; sigaction( SIGSEGV, &sa, &oa ); }

Layout of kernel-stack (by cpu) Upon entry to kernel’s exception-handler: SS saved pointer to user-stack ESP EFLAGS CS saved pointer to user-opcode EIP error code SS:ESP ‘error code’ = segment-selector for the illegal memory-segment access

Layout of kernel-stack (by Linux) ss esp eflags cs eip error gs fs es ds eax ebp edi esi edx ecx SS:ESP ebx

command-line arguments command-line arguments Layout of user-stack Upon entering ‘main()’ Upon entering ‘handler()’ environment strings environment strings command-line arguments command-line arguments envp envp argv argv argc argc tos return-address return-address sigstub sigcontext siginfo sc si signum tos return-address

‘segvtrap.cpp’ We have constructed this demo-program to show how you could utilize the context information that Linux can provide to your signal-handler (if you use SA_SIGINFO) You can use our ‘run.cpp’ tool to examine an application-program’s exit-status

In-class exercises Try commenting out the ‘exit(1)’ statement Then add statement: sc ->eip += 1; Try replacing ‘asm(“ hlt “)’ statement with this privileged instruction: inb( 0x1F7 ); Try replacing ‘asm(“ hlt “)’ statement with this illegal assignment: *(char*)0 = 0; Try replacing ‘asm(“ hlt” )’ statement with an instruction that reads a kernel-address