Tecniche di debugging nel kernel Linux. Andrea Righi -
|
|
- Alannah Watkins
- 6 years ago
- Views:
Transcription
1 Tecniche di debugging nel kernel Linux
2 Agenda Overview (kernel programming) Kernel crash classification Debugging techniques Example(s) Q/A
3 What's a kernel? The kernel provides an abstraction layer for the applications to use the physical hardware resources Kernel basic facilities Process management Memory management Device management System call interface
4 User space Good for debugging (gdb) Lots of user-space libraries available Unpredictable latency (context switch, scheduler, syscall,...) Overhead Impossibility to fully interact with interrupt routines Impossibility to access certain memory address More difficult to share certain features with other drivers Reliability: user processes can be terminated upon critical system events (OOM, filesystem errors, etc.)
5 Kernel space Written in C and assembly No debugging tool (kgdb, UML,...) Bugs can hang the entire system User memory is swappable, kernel memory can't be swapped out Kernel stack size is small (8K / 4K - THREAD_SIZE_ORDER) Floating point is forbidden Userspace libraries are not available Linux kernel must be portable (this is important if you consider to contribute mainstream) Closed source kernel modules taint the kernel
6 Example kernel module #include <linux/init.h> #include <linux/module.h> /* Module constructor */ static int init hello_init(void) printk(kern_info "Hello, world!\n"); return 0; /* Module destructor */ static void exit hello_exit(void) printk(kern_info "Goodbye\n"); module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Andrea Righi MODULE_DESCRIPTION("BetterEmbedded hello world example");
7 Kernel problems Kernel panic (fatal error for the system) Kernel oops (non-fatal error) Wrong result (fatal from user's perspective)
8 Kernel panic No recovery is possible Example: exception in an atomic context (i.e., interrupt) Typically result in a system reboot (panic=n), or blinking LED or just hang
9 [ ] general protection fault: 0000 [#1] PREEMPT SMP [ ] Modules linked in: crashtest(o) [last unloaded: crashtest] [ ] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G O rc7+ #535 [ ] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ ] task: ffff88003d90a2c0 ti: ffff88003d92e000 task.ti: ffff88003d92e000 [ ] RIP: 0010:[<ffffffff811ab0e5>] [<ffffffff811ab0e5>] kmalloc_track_caller+0xd5/0x2b0 [ ] RSP: 0018:ffff88003e EFLAGS: [ ] RAX: RBX: ffff88003e1d6a20 RCX: be841 [ ] RDX: be801 RSI: RDI: [ ] RBP: ffff88003e0039c8 R08: d6a20 R09: [ ] R10: R11: R12: [ ] R13: R14: R15: ffff88003d [ ] FS: (0000) GS:ffff88003e000000(0000) knlgs: [ ] CS: 0010 DS: 0000 ES: 0000 CR0: b [ ] CR2: ab008 CR3: dc8000 CR4: e0 [ ] DR0: DR1: DR2: [ ] DR3: DR6: ffff0ff0 DR7: [ ] Stack: [ ] be801 ffff88003d92ffd8 ffffffff d ffff880034e3f300 [ ] ffff88003e003a [ ] ffff88003e003a00 ffffffff c ffff880034e3f
10 ] Call Trace: ] <IRQ> ] [<ffffffff d>]? alloc_skb+0x7d/0x ] [<ffffffff c>] kmalloc_reserve.isra.52+0x3c/0xa ] [<ffffffff d>] alloc_skb+0x7d/0x ] [<ffffffff81677e5b>] tcp_send_ack+0x3b/0xf ] [<ffffffff8166ab1e>] tcp_ack_snd_check+0x5e/0xa ] [<ffffffff81671c64>] tcp_rcv_established+0x204/0x6f ] [<ffffffff810e678e>]? put_lock_stats.isra.26+0xe/0x ] [<ffffffff8167c681>] tcp_v4_do_rcv+0x161/0x ] [<ffffffff816fea39>]? _raw_spin_lock_nested+0x79/0x ] [<ffffffff8167dc91>] tcp_v4_rcv+0x731/0x ] [<ffffffff810e706f>]? lock_is_held+0x5f/0x ] [<ffffffff816563d8>] ip_local_deliver_finish+0xc8/0x2f ] [<ffffffff a>]? ip_local_deliver_finish+0x4a/0x2f ] [<ffffffff81656e77>] ip_local_deliver+0x47/0x ] [<ffffffff >] ip_rcv_finish+0x140/0x5e ] [<ffffffff816570e3>] ip_rcv+0x233/0x ] [<ffffffff >] netif_receive_skb_core+0x6a2/0x ] [<ffffffff81625a10>]? netif_receive_skb_core+0x50/0x ] [<ffffffff >] netif_receive_skb+0x21/0x ] [<ffffffff >] netif_receive_skb+0x23/0x1f ] [<ffffffff >] napi_gro_receive+0x98/0xd ] [<ffffffff81565c5a>] e1000_clean_rx_irq+0x18a/0x ] [<ffffffff >] e1000_clean+0x251/0x ] [<ffffffff810e678e>]? put_lock_stats.isra.26+0xe/0x ] [<ffffffff810e6df4>]? lock_release_holdtime.part.27+0xd4/0x ] [<ffffffff >] net_rx_action+0xd5/0x2e ] [<ffffffff81088d17>] do_softirq+0xf7/0x ] [<ffffffff810891d5>] irq_exit+0xb5/0xc ] [<ffffffff >] do_irq+0x63/0xd ] Code: c8 48 8b 55 c0 48 8b e0 ff ff a8 08 0f 85 5f c 8b 23 4d 85 e4 0f d 4a 40 4d 8b 07 <49> 8b 1c 04 4c 89 e f c7 08 0f 94 c0 84 c ] RIP [<ffffffff811ab0e5>] kmalloc_track_caller+0xd5/0x2b ] RSP <ffff88003e003988> ] ---[ end trace baac76a23c6da73c ] ] Kernel panic - not syncing: Fatal exception in interrupt
11 Kernel oops A message is displayed in the log when a recoverable error has occurred in kernel space Example: access a bad address (i.e., NULL pointer dereference) An oops does not mean the system has crashed Current process is killed Oops message is displayed along with a registers dump and a stack trace
12 [ ] BUG: unable to handle kernel NULL pointer dereference at (null) [ ] IP: [<ffffffffa00003c6>] procfs_write+0x2d6/0x320 [crashtest] [ ] PGD 3a78d067 PUD 362be067 PMD 0 [ ] Oops: 0002 [#1] PREEMPT SMP [ ] Modules linked in: crashtest(o) [ ] CPU: 0 PID: 1587 Comm: bash Tainted: G O rc7+ #535 [ ] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ ] task: ffff88003a7ec580 ti: ffff f6000 task.ti: ffff f6000 [ ] RIP: 0010:[<ffffffffa00003c6>] [<ffffffffa00003c6>] procfs_write+0x2d6/0x320 [crashtest] [ ] RSP: 0018:ffff f7e78 EFLAGS: [ ] RAX: RBX: RCX: e [ ] RDX: RSI: ffffffffa RDI: ffff f7eaa [ ] RBP: ffff f7ee0 R08: R09: [ ] R10: ffff88003a7ec580 R11: R12: [ ] R13: a R14: ffff f7f50 R15: [ ] FS: (0000) GS:ffff88003de00000(0063) knlgs: f75f76c0 [ ] CS: 0010 DS: 002b ES: 002b CR0: [ ] CR2: CR3: CR4: f0 [ ] DR0: DR1: DR2: [ ] DR3: DR6: ffff0ff0 DR7: [ ] Stack: [ ] ffffffff811b66cb ffff88003a7ec580 [ ] ffff f7ec8 4f e [ ] b9fa0 ffff fd a [ ] Call Trace: [ ] [<ffffffff811b66cb>]? vfs_write+0x1bb/0x1f0 [ ] [<ffffffff8121a86d>] proc_reg_write+0x3d/0x80 [ ] [<ffffffff811b65d8>] vfs_write+0xc8/0x1f0 [ ] [<ffffffff811b6ad5>] SyS_write+0x55/0xa0 [ ] [<ffffffff81708ce5>] sysenter_dispatch+0x7/0x1f [ ] [<ffffffff813c50ae>]? trace_hardirqs_on_thunk+0x3a/0x3f [ ] Code: e1 f3 6f e1 48 c7 c a0 e8 d5 f3 6f e1 e9 e2 fd ff ff c7 45 d e9 d6 fd ff ff e8 bf fc ff ff e9 cc fd ff ff <c7> e9 bc fd ff ff eb fe 66 c7 07 [ ] RIP [<ffffffffa00003c6>] procfs_write+0x2d6/0x320 [crashtest] [ ] RSP <ffff f7e78> [ ] CR2: [ ] ---[ end trace 33bbddb c ]---
13 Kernel fault classification panic( have a nice day... ;-) ) BUG() / BUG_ON(condition) exception (i.e., invalid opcode, division by zero,...) memory corruption stack overflow/underflow NOTE: in kernel space stack size is limited to 2 pages (8K in almost all architectures) write after free write to a bad address concurrent access without protections (locks, etc.) soft lockup lock a CPU without giving other tasks a chance to run hard lockup lock a CPU without giving other tasks or interrupts a chance to run hung task: task doesn't get a chance to run for more than N seconds scheduling while atomic deadlock use FPU registers in kernel space
14 Useful debugging kernel options Kernel Hacking section -> CONFIG_KALLSYMS_ALL: print function names instead of addresses in kernel messages CONFIG_FRAME_POINTER: get useful stack info in case of kernel bugs CONFIG_DEBUG_ATOMIC_SLEEP: enable sleep inside atomic section checks (i.e., sleep from interrupt handler, sleep when a lock is held, etc...) CONFIG_LOCKUP_DETECTOR: detect hard and soft lockups CONFIG_LOCKDEP: lock dependency enging (deadlock detection) CONFIG_DYNAMIC_FTRACE: enable individual function tracing dynamically (via debugfs /sys/kernel/debug/tracing)
15 Debugging techniques blinking LED printk() procfs SysReq key (Documentation/sysrq.txt) function instrumentation (kprobes) dynamic ftrace (CONFIG_DYNAMIC_FTRACE) debugger (kgdb)
16 printk() Advantages easy to use no need any other system support Disadvantages have to modify and rebuild kernel/modules no interactive debugging
17 printk(): levels printk levels KERN_EMERG: system is unusable KERN_ALERT: action must be taken immediately KERN_CRIT: critical condition KERN_ERR: error condition KERN_WARNING: warning condition KERN_NOTICE: normal condition KERN_INFO: informational KERN_DEBUG: debug message Show kernel messages: # dmesg Redirect all kernel messages to the console # echo 8 > /proc/sys/kernel/printk
18 procfs static int procfs_read(struct seq_file *m, void *v)... static ssize_t procfs_write(struct file *file, const char user *ubuf, size_t count, loff_t *pos)... static int procfs_open(struct inode *inode, struct file *file) return single_open(file, procfs_read, NULL); static int procfs_release(struct inode *inode, struct file *file) return 0; static const struct file_operations procfs_fops =.open = procfs_open,.read = seq_read,.write = procfs_write,.llseek = seq_lseek,.release = procfs_release, ; static int init myproc_init(void) if (!proc_create( myproc, 0666, NULL, &procfs_fops)) return -ENOMEM; return 0; static void exit myproc_exit(void) remove_proc_entry( myproc, NULL);
19 Kprobes (Kernel probes) Kprobes allow to dynamically break into any kernel routine and collect debugging and performance information (CONFIG_KPROBES=y) Trap almost every kernel code address, specifying a handler routine to be invoked when the breakpoint is hit How does it work? Make a copy of the probed instruction and replace the original instruction with a breakpoint instruction (int3 on x86) When the breakpoint is hit, a trap occurs, CPU's registers are saved and the control passes to the Kprobes pre-handler The saved instruction is executed in single-step mode The Kprobes post-handler is executed The rest of the original function is executed
20 Kprobes (example) static int my_handler(struct kprobe *p, struct pt_regs *regs) /* Do something here... */ static struct kprobe my_kp =.pre_handler = my_wrapper,.symbol_name = schedule_timeout, ; static int init my_kprobe_init(void) int ret; ret = register_kprobe(&my_kp); if (ret < 0) printk(kern_info "%s: error %d\n", func, ret); return ret; return 0; static void exit my_kprobe_exit(void) unregister_kprobe(&my_kp);
21 Dump a stack trace static const char function_name[] = "schedule_timeout"; static int my_handler(struct kprobe *p, struct pt_regs *regs) dump_stack(); printk(kern_info "%s called %s(%d)\n", current->comm, function_name, (int)regs->di); static struct kprobe my_kp =.pre_handler = my_wrapper,.symbol_name = function_name, ; static int init my_kprobe_init(void) int ret; ret = register_kprobe(&my_kp); if (ret < 0) printk(kern_info "%s: error %d\n", func, ret); return ret; return 0; static void exit my_kprobe_exit(void) unregister_kprobe(&my_kp);
22 Dynamic ftrace # mount -t debufs none /sys/kernel/debug # cd /sys/kernel/debug # echo sys_nanosleep hrtimer_interrupt > set_ftrace_filter # echo function > current_tracer # echo 1 > tracing_on # usleep 1 # echo 0 > tracing_on # cat trace # tracer: function # # entries-in-buffer/entries-written: 5/5 #P:4 # # _-----=> irqs-off # / _----=> need-resched # / _---=> hardirq/softirq # / _--=> preempt-depth # / delay # TASK-PID CPU# TIMESTAMP FUNCTION # usleep-2665 [001] : sys_nanosleep <-system_call_fastpath <idle>-0 [001] d.h : hrtimer_interrupt <-smp_apic_timer_interrupt usleep-2665 [001] d.h : hrtimer_interrupt <-smp_apic_timer_interrupt <idle>-0 [003] d.h : hrtimer_interrupt <-smp_apic_timer_interrupt <idle>-0 [002] d.h : hrtimer_interrupt <-smp_apic_timer_interrupt
23 KGDB + QEMU Setting up kgdb using kvm/qemu $ kvm -m smp 4 -drive file=debian-6-i386.img -vnc :1 -redir tcp:5190: :22 -kernel /src/linux/arch/x86/boot/bzimage -append "root=/dev/sda1 kgdbwait kgdboc=ttys0" -serial pty char device redirected to /dev/pts/3 (label serial0) $ gdb vmlinux (gdb) target remote /dev/pts/3
24 Debugging workqueues workqueue: asynchronous process execution context kworkers are going crazy (using too much cpu)? Something being scheduled in rapid succession A single work item consumes alots of cpu cycles How to debug? kernel tracepoints: echo workqueue:workqueue_queue_work > /sys/kernel/debug/tracing/set_event kworker stack trace: cat /proc/the_offending_kworker/stack root ? S 12:07 0:00 [kworker/0:1] root ? S 12:07 0:00 [kworker/1:2] root ? S 12:12 0:00 [kworker/0:0] root ? S 12:13 0:00 [kworker/1:0]
25 References J. Corbet, A. Rubini, G. Kroah-Hartman: Linux Device Drivers 3rd Edition Linux documentation Linux weekly news:
26 Q/A You're very welcome! #bem2013
Scrivere device driver su Linux. Better Embedded 2012 Andrea Righi
Scrivere device driver su Linux Agenda Overview Kernel-space vs user-space programming Hello, world! kernel module Writing a character device driver Example(s) Q/A Overview What's a kernel? The kernel
More informationVirtual USB Fuzzer Updates
Virtual USB Fuzzer Updates [ 110.768243] usb 1-1: new full-speed USB device number 48 using xhci_hcd [ 111.028327] usb 1-1: config 1 has 1 interface, different from the descriptor's value: 10 [ 111.030544]
More informationConfigurations. Make menuconfig : Kernel hacking/
Kernel Debugging Configurations Make menuconfig : Kernel hacking/ Timing info on printks depreciated logic Detection of hung tasks SLUB debugging Kernel memory leak detector Mutext/lock debugging Kmemcheck
More informationDecoding Those Inscrutable RCU CPU Stall Warnings
Paul E. McKenney, IBM Distinguished Engineer, Linux Technology Center Member, IBM Academy of Technology Open Source Summit North America, September 12, 2017 Decoding Those Inscrutable RCU CPU Stall Warnings
More informationDecoding Those Inscrutable RCU CPU Stall Warnings
Paul E. McKenney, IBM Distinguished Engineer, Linux Technology Center Member, IBM Academy of Technology linux.conf.au Kernel Miniconf, January 22, 2018 Decoding Those Inscrutable RCU CPU Stall Warnings
More informationKernel. Kernel = computer program that connects the user applications to the system hardware Handles:
Kernel programming Kernel Kernel = computer program that connects the user applications to the system hardware Handles: Memory management CPU scheduling (Process and task management) Disk management User
More informationUsing kgdb and the kgdb Internals
Using kgdb and the kgdb Internals Jason Wessel jason.wessel@windriver.com Tom Rini trini@kernel.crashing.org Amit S. Kale amitkale@linsyssoft.com Using kgdb and the kgdb Internals by Jason Wessel by Tom
More informationBinghamton University. CS-220 Spring X86 Debug. Computer Systems Section 3.11
X86 Debug Computer Systems Section 3.11 GDB is a Source Level debugger We have learned how to debug at the C level But the machine is executing X86 object code! How does GDB play the shell game? Makes
More informationDebugging Kernel without Debugger
Debugging Kernel without Debugger Masami Hiramatsu Software Platform Research Dept. Yokohama Research Lab. Hitachi Ltd., 1 Who am I? Masami Hiramatsu Researcher in Hitachi
More informationFtrace Kernel Hooks: More than just tracing. Presenter: Steven Rostedt Red Hat
Ftrace Kernel Hooks: More than just tracing Presenter: Steven Rostedt rostedt@goodmis.org Red Hat Ftrace Function Hooks Function Tracer Function Graph Tracer Function Profiler Stack Tracer Kprobes Uprobes
More informationDevice Drivers. CS449 Fall 2017
Device Drivers CS449 Fall 2017 Software Layers User-level I/O so7ware & libraries Device-independent OS so7ware Device drivers Interrupt handlers User OperaEng system (kernel) Hardware Device Drivers User
More informationVirtual File System (VFS) Implementation in Linux. Tushar B. Kute,
Virtual File System (VFS) Implementation in Linux Tushar B. Kute, http://tusharkute.com Virtual File System The Linux kernel implements the concept of Virtual File System (VFS, originally Virtual Filesystem
More informationASE++ : Linux Kernel Programming
ASE++ : Linux Kernel Programming Giuseppe Lipari (giuseppe.lipari@univ-lille.fr) April 8, 2018 Contents 1 Introduction 1 2 Setting up the environment 2 3 Writing a kernel module 5 4 Other useful information
More information2006/7/22. NTT Data Intellilink Corporation Fernando Luis Vázquez Cao. Copyright(C)2006 NTT Data Intellilink Corporation
Evaluating Linux Kernel Crash Dumping Mechanisms 2006/7/22 NTT Data Intellilink Corporation Fernando Luis Vázquez Cao 1 Who am I? LKDTT (Linux Kernel Dump Test Tool) maintainer MKDump (Mini Kernel Dump)
More informationPrinceton University Computer Science 217: Introduction to Programming Systems Exceptions and Processes
Princeton University Computer Science 217: Introduction to Programming Systems Exceptions and Processes Much of the material for this lecture is drawn from Computer Systems: A Programmer s Perspective
More informationCS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014
CS5460/6460: Operating Systems Lecture 24: Device drivers Anton Burtsev April, 2014 Device drivers Conceptually Implement interface to hardware Expose some high-level interface to the kernel or applications
More informationCS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A)
CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A) Professor Adam Bates Fall 2018 Learning Objectives: Talk about the relevant skills required in MP1 Announcements: MP1
More information18-600: Recitation #3
18-600: Recitation #3 Bomb Lab & GDB Overview September 12th, 2017 1 Today X86-64 Overview Bomb Lab Introduction GDB Tutorial 2 3 x86-64: Register Conventions Arguments passed in registers: %rdi, %rsi,
More informationKDUMP AND INTRODUCTION TO VMCORE ANALYSIS
KDUMP AND INTRODUCTION TO VMCORE ANALYSIS HOW TO GET STARTED WITH INSPECTING KERNEL FAILURES PATRICK LADD TECHNICAL ACCOUNT MANAGER, RED HAT pladd@redhat.com slides available at https://people.redhat.com/pladd
More informationProcesses and Exceptions
Princeton University Computer Science 217: Introduction to Programming Systems Processes and Exceptions Much of the material for this lecture is drawn from Computer Systems: A Programmer s Perspective
More informationRAS Enhancement Activities for Mission-Critical Linux Systems
RAS Enhancement Activities for MissionCritical Linux Systems Hitachi Ltd. Yoshihiro YUNOMAE 01 MissionCritical Systems We apply Linux to missioncritical systems. Banking systems/carrier backend systems/train
More informationOverview of the x86-64 kernel. Andi Kleen, SUSE Labs, Novell Linux Bangalore 2004
Overview of the x86-64 kernel Andi Kleen, SUSE Labs, Novell ak@suse.de Linux Bangalore 2004 What s wrong? x86-64, x86_64 AMD64 EM64T IA32e IA64 x64, CT Names x86-64, x86_64 AMD64 EM64T IA32e x64 CT Basics
More informationCrashes, Panics and Other Oddities. Imed Chihi, Red Hat February 2008
Crashes, Panics and Other Oddities Imed Chihi, Red Hat February 2008 Agenda Defining some terms Analogy with User Space The BUG() Macro Bad Pointer Handling The NMI Watchdog Machine Check Exceptions EDAC
More information/dev/hello_world: A Simple Introduction to Device Drivers under Linux
Published on Linux DevCenter (http://www.linuxdevcenter.com/) See this if you're having trouble printing code examples /dev/hello_world: A Simple Introduction to Device Drivers under Linux by Valerie Henson
More informationProcess Control. Philipp Koehn. 23 April 2018
Process Control Philipp Koehn 23 April 2018 Control Flow 1 The CPU executes one instruction after another Typically, they are next to each other in memory (unless jumps, branches, and returns from subroutine)
More informationThe State of Kernel Debugging Technology. Jason Wessel - Product Architect for WR Linux Core Runtime - Kernel.org KDB/KGDB Maintainer
The State of Kernel Debugging Technology Jason Wessel - Product Architect for WR Linux Core Runtime - Kernel.org KDB/KGDB Maintainer August 12 th, 2010 Agenda Brief history of kernel.org kernel debuggers
More informationLab 7 Linux Debugging. EECS 448: Software Engineering I Mark Calnon October 17, 2011
Lab 7 Linux Debugging EECS 448: Software Engineering I Mark Calnon October 17, 2011 GDB Getting Started To start gdb from the command line, first browse to the directory containing the core dump to debug
More informationSoftware Based Fault Injection Framework For Storage Systems Vinod Eswaraprasad Smitha Jayaram Wipro Technologies
Software Based Fault Injection Framework For Storage Systems Vinod Eswaraprasad Smitha Jayaram Wipro Technologies The agenda Reliability in Storage systems Types of errors/faults in distributed storage
More informationLinux Kernel Development (LKD)
Linux Kernel Development (LKD) Session 1 Loadable Kernel Modules (LKM) Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 PBS LKD: S1 1 / 66 Disclaimer Material and Slides Some of the material/slides are adapted
More information- Knowledge of basic computer architecture and organization, ECE 445
ECE 446: Device Driver Development Fall 2014 Wednesdays 7:20-10 PM Office hours: Wednesdays 6:15-7:15 PM or by appointment, Adjunct office Engineering Building room 3707/3708 Last updated: 8/24/14 Instructor:
More informationFtrace - What s new. Since my last explanation of ftrace (from v3.18) Steven Rostedt 25/10/ VMware Inc. All rights reserved.
Ftrace - What s new Since my last explanation of ftrace (from v3.18) Steven Rostedt 25/10/2017 2017 VMware Inc. All rights reserved. What ftrace did (and still does) Function tracing Function graph tracing
More informationStacktraces in perf and ftrace. Frederic Weisbecker Collaboration summit 2012
] Stacktraces in perf and ftrace Frederic Weisbecker Collaboration summit 2012 Raw stacktrace One shot: Used for debugging [ 328.028320] Call Trace: [ 328.028320] []
More informationKprobes Presentation Overview
Kprobes Presentation Overview This talk is about how using the Linux kprobe kernel debugging API, may be used to subvert the kernels integrity by manipulating jprobes and kretprobes to patch the kernel.
More informationKernel Modules. Kartik Gopalan
Kernel Modules Kartik Gopalan Kernel Modules Allow code to be added to the kernel, dynamically Only those modules that are needed are loaded. Unload when no longer required - frees up memory and other
More informationIntroduction p. 1 Why Linux? p. 2 Embedded Linux Today p. 3 Open Source and the GPL p. 3 Free Versus Freedom p. 4 Standards and Relevant Bodies p.
Foreword p. xix Preface p. xxi Acknowledgments p. xxvii About the Author p. xxix Introduction p. 1 Why Linux? p. 2 Embedded Linux Today p. 3 Open Source and the GPL p. 3 Free Versus Freedom p. 4 Standards
More informationCSC369 Lecture 2. Larry Zhang
CSC369 Lecture 2 Larry Zhang 1 Announcements Lecture slides Midterm timing issue Assignment 1 will be out soon! Start early, and ask questions. We will have bonus for groups that finish early. 2 Assignment
More informationMaintaining Linux Long Term & Adding Specific Features in Telecom Systems. Keika Kobayashi NEC Communication Systems Sep 29, Japan2010
Maintaining Linux Long Term & Adding Specific Features in Telecom Systems Keika Kobayashi NEC Communication Systems Sep 29, 2010@LinuxCon Japan2010 OUTLINE 1. Background 2. What we did 1. Keep kernel stable.
More informationLinux drivers - Exercise
Embedded Realtime Software Linux drivers - Exercise Scope Keywords Prerequisites Contact Learn how to implement a device driver for the Linux OS. Linux, driver Linux basic knowledges Roberto Bucher, roberto.bucher@supsi.ch
More informationNPTEL Course Jan K. Gopinath Indian Institute of Science
Storage Systems NPTEL Course Jan 2012 (Lecture 17) K. Gopinath Indian Institute of Science Accessing Devices/Device Driver Many ways to access devices under linux Non-block based devices ( char ) - stream
More informationCharacter Device Drivers One Module - Multiple Devices
Review from previous classes Three Types: Block, Character, and Network Interface Device Drivers MAJOR & MINOR numbers assigned register_chrdev_region(), alloc_chrdev_region(), unregister_chrdev_region()
More informationLinux Kernel Module Programming. Tushar B. Kute,
Linux Kernel Module Programming Tushar B. Kute, http://tusharkute.com Kernel Modules Kernel modules are piece of code, that can be loaded and unloaded from kernel on demand. Kernel modules offers an easy
More informationEnhancement Activities on the Current Upstream Kernel for Mission-Critical Systems
Enhancement Activities on the Current Upstream Kernel for MissionCritical Systems Hitachi Ltd. Yoshihiro YUNOMAE 01 MissionCritical Systems We apply Linux to missioncritical systems. Banking systems/carrier
More informationAssembly I: Basic Operations. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Assembly I: Basic Operations Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Basic Execution Environment RAX RBX RCX RDX RSI RDI RBP RSP R8 R9 R10
More informationUnderstanding Real Time Linux. Alex Shi
Understanding Real Time Linux Alex Shi Agenda What s real time OS RTL project status RT testing and tracing Reasons of latency and solutions for them Resources Summary What s real time OS Real time and
More informationLecture 6. User-Mode Linux. Jeff Dike. 9 November, Advanced Operating Systems. SOA/OS Lecture 6, UML 1/33
Lecture 6 User-Mode Linux Jeff Dike Advanced Operating Systems 9 November, 2011 SOA/OS Lecture 6, UML 1/33 Contents User-Mode Linux Keywords Resources Questions SOA/OS Lecture 6, UML 2/33 Outline User-Mode
More informationCSE 153 Design of Operating Systems Fall 18
CSE 153 Design of Operating Systems Fall 18 Lecture 2: OS model and Architectural Support Last time/today l Historic evolution of Operating Systems (and computing!) l Today: We start our journey in exploring
More informationCSC369 Lecture 2. Larry Zhang, September 21, 2015
CSC369 Lecture 2 Larry Zhang, September 21, 2015 1 Volunteer note-taker needed by accessibility service see announcement on Piazza for details 2 Change to office hour to resolve conflict with CSC373 lecture
More informationSystem calls and assembler
System calls and assembler Michal Sojka sojkam1@fel.cvut.cz ČVUT, FEL License: CC-BY-SA 4.0 System calls (repetition from lectures) A way for normal applications to invoke operating system (OS) kernel's
More informationDebugging realtime application with Ftrace
Debugging realtime application with Ftrace Pierre Ficheux (pierre.ficheux@smile.fr) 02/2018 1 Disclaimer Poor English speaker! But good French speaker and writer :-) Loin du français je meurs (Louis-Ferdinand
More informationThe device driver (DD) implements these user functions, which translate system calls into device-specific operations that act on real hardware
Introduction (Linux Device Drivers, 3rd Edition (www.makelinux.net/ldd3)) Device Drivers -> DD They are a well defined programming interface between the applications and the actual hardware They hide completely
More informationAn Implementation Of Multiprocessor Linux
An Implementation Of Multiprocessor Linux This document describes the implementation of a simple SMP Linux kernel extension and how to use this to develop SMP Linux kernels for architectures other than
More informationPostmortem Debugging with Coresight HKG18-TR14. Leo Yan, Linaro Support and Solutions Engineering
Postmortem Debugging with Coresight HKG18-TR14 Leo Yan, Linaro Support and Solutions Engineering Introduction This session discusses postmortem debugging techniques in the Linux kernel. Firstly we will
More informationLinux Kernel Modules & Device Drivers April 9, 2012
Linux Kernel Modules & Device Drivers April 9, 2012 Pacific University 1 Resources Linux Device Drivers,3rd Edition, Corbet, Rubini, Kroah- Hartman; O'Reilly kernel 2.6.10 we will use 3.1.9 The current
More informationImproving Linux Development with better tools. Andi Kleen. Oct 2013 Intel Corporation
Improving Linux Development with better tools Andi Kleen Oct 2013 Intel Corporation ak@linux.intel.com Linux complexity growing Source lines in Linux kernel All source code 16.5 16 15.5 M-LOC 15 14.5 14
More informationan infinite loop Processes and Exceptions doing nothing on a busy system timing nothing
an infinite loop Processes and Exceptions int main(void) { while (1) { /* waste CPU time */ If I run this on a lab machine, can you still use it? even if the machine only has one core? 1 2 timing nothing
More informationAbstraction via the OS. Device Drivers. Software Layers. Device Drivers. Types of Devices. Mechanism vs. Policy. Jonathan Misurda
Abstraction via the OS Device Drivers Jonathan Misurda jmisurda@cs.pitt.edu Software Layers level I/O software & libraries Device independent OS software Device drivers Interrupt handlers Hardware Operating
More informationHardware Latencies How to flush them out (A use case) Steven Rostedt Red Hat
Hardware Latencies How to flush them out (A use case) Steven Rostedt Red Hat Here s a story, of a lovely lady... No this isn t the Brady Bunch Nor is it about a lovely lady But it probably could have been
More informationDeveloping Real-Time Applications
Developing Real-Time Applications Real Time Operating Systems and Middleware Luca Abeni luca.abeni@unitn.it Characterised by temporal constraints deadlines Concurrent (application: set of real-time tasks)
More informationOverhead Evaluation about Kprobes and Djprobe (Direct Jump Probe)
Overhead Evaluation about Kprobes and Djprobe (Direct Jump Probe) Masami Hiramatsu Hitachi, Ltd., SDL Jul. 13. 25 1. Abstract To implement flight recorder system, the overhead
More informationDynamic Probes - Debugging by Stealth
Dynamic Probes - Debugging by Stealth Update and Work-in-Progress Linux.conf.au Australia Suparna Bhattacharya suparna@in.ibm.com IBM Linux Technology Centre 23 January, 2003 Overview 1. What and Why?
More informationSoftware Layers. Device Drivers 4/15/2013. User
Software Layers Device Drivers User-level I/O software & libraries Device-independent OS software Device drivers Interrupt handlers Hardware User Operating system (kernel) Abstraction via the OS Device
More informationCAN STRACE MAKE YOU FAIL?
CAN STRACE MAKE YOU FAIL? Nahim El Atmani @brokenpi_pe July 15, 2016 1 DEFINITION 1.0 strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor interactions
More informationOperating System System Call & Debugging Technique
1 Operating System System Call & Debugging Technique 진주영 jjysienna@gmail.com System Call 2 A way for user-space programs to interact with the kernel System Call enables application programs in user-mode
More informationCS 453: Operating Systems Programming Project 5 (100 points) Linux Device Driver
CS 453: Operating Systems Programming Project 5 (100 points) Linux Device Driver 1 Setup In this assignment, we will write a simple character driver called booga. Please do a git pull --rebase in your
More informationWhat is concurrency? Concurrency. What is parallelism? concurrency vs parallelism. Concurrency: (the illusion of) happening at the same time.
What is concurrency? Concurrency Johan Montelius KTH 2017 Concurrency: (the illusion of) happening at the same time. A property of the programing model. Why would we want to do things concurrently? What
More informationKthreads, Mutexes, and Debugging. Sarah Diesburg CS 3430 Operating Systems
Kthreads, Mutexes, and Debugging Sarah Diesburg CS 3430 Operating Systems 1 Story of Kernel Development Some context 2 In the old days There were no modules or virtual machines The kernel is a program
More informationCSE 153 Design of Operating Systems
CSE 153 Design of Operating Systems Winter 19 Lecture 3: OS model and Architectural Support Last time/today Historic evolution of Operating Systems (and computing!) Today: We start our journey in exploring
More informationExceptions and Processes
Exceptions and Processes Samira Khan April 18, 2017 Control Flow Processors do only one thing: From startup to shutdown, a simply reads and executes (interprets) a sequence of instructions, one at a time
More informationConcurrency. Johan Montelius KTH
Concurrency Johan Montelius KTH 2017 1 / 32 What is concurrency? 2 / 32 What is concurrency? Concurrency: (the illusion of) happening at the same time. 2 / 32 What is concurrency? Concurrency: (the illusion
More informationImproving Linux development with better tools
Improving Linux development with better tools Andi Kleen Oct 2013 Intel Corporation ak@linux.intel.com Linux complexity growing Source lines in Linux kernel All source code 16.5 16 15.5 M-LOC 15 14.5 14
More informationNetBSD/pkgsrc for the last 3 years
DEBUGGING LESSONS LEARNED WHILE FIXING NETBSD ABOUT ME maya@netbsd.org coypu@sdf.org NetBSD/pkgsrc for the last 3 years THIS TALK Mix of a bunch of bugs Not solo work Thanks to riastradh, dholland, martin,
More informationHuawei Frame Buffer Driver Arbitrary Memory Write
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
More informationCS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes
CS 261 Fall 2017 Mike Lam, Professor Exceptional Control Flow and Processes Exceptional control flow Most control flow is sequential However, we have seen violations of this rule Exceptional control flow
More informationLinux modules 1. Support system calls and services 2. Programming facilities 3. Kernel probing
Advanced Operating Systems MS degree in Computer Engineering University of Rome Tor Vergata Lecturer: Francesco Quaglia Linux modules 1. Support system calls and services 2. Programming facilities 3. Kernel
More informationDistribution Kernel Security Hardening with ftrace
Distribution Kernel Security Hardening with ftrace Because sometimes your OS vendor just doesn't have the security features that you want. Written by: Corey Henderson Exploit Attack Surface Hardening system
More informationDebugging uclinux on Coldfire
Debugging uclinux on Coldfire By David Braendler davidb@emsea-systems.com What is uclinux? uclinux is a version of Linux for CPUs without virtual memory or an MMU (Memory Management Unit) and is typically
More informationIntroduction to the Linux Kernel. Hao-Ran Liu
Introduction to the Linux Kernel Hao-Ran Liu The history Initially developed by Linus Torvalds in 1991 Source code is released under GNU Public License (GPL) If you modify and release a program protected
More informationOverview. This Lecture. Interrupts and exceptions Source: ULK ch 4, ELDD ch1, ch2 & ch4. COSC440 Lecture 3: Interrupts 1
This Lecture Overview Interrupts and exceptions Source: ULK ch 4, ELDD ch1, ch2 & ch4 COSC440 Lecture 3: Interrupts 1 Three reasons for interrupts System calls Program/hardware faults External device interrupts
More informationCopyright 2000 by Barry B. Brey The CPU Scheduling Processes
Copyright 2000 by Barry B. Brey The CPU Scheduling Processes One method used to schedule processes in a small real-time operating system (RTOS) is via a time slice to switch between various processes.
More informationGDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial
A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program
More informationAssembly Language Programming 64-bit environments
Assembly Language Programming 64-bit environments October 17, 2017 Some recent history Intel together with HP start to work on 64-bit processor using VLIW technology. Itanium processor is born with the
More informationW4118: interrupt and system call. Junfeng Yang
W4118: interrupt and system call Junfeng Yang Outline Motivation for protection Interrupt System call 2 Need for protection Kernel privileged, cannot trust user processes User processes may be malicious
More informationSYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14
SYSTEM CALL IMPLEMENTATION CS124 Operating Systems Fall 2017-2018, Lecture 14 2 User Processes and System Calls Previously stated that user applications interact with the kernel via system calls Typically
More information6/17/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:
Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Introduction This chapter presents the microprocessor
More informationECE 598 Advanced Operating Systems Lecture 19
ECE 598 Advanced Operating Systems Lecture 19 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 7 April 2016 Homework #7 was due Announcements Homework #8 will be posted 1 Why use
More informationIMPLEMENTATION OF SIGNAL HANDLING. CS124 Operating Systems Fall , Lecture 15
IMPLEMENTATION OF SIGNAL HANDLING CS124 Operating Systems Fall 2017-2018, Lecture 15 2 Signal Handling UNIX operating systems allow es to register for and handle signals Provides exceptional control flow
More informationApplying User-level Drivers on
Applying User-level Drivers on DTV System Gunho Lee, Senior Research Engineer, ELC, April 18, 2007 Content Background Requirements of DTV Device Drivers Design of LG DTV User-level Drivers Implementation
More informationCSE 120 Principles of Operating Systems
CSE 120 Principles of Operating Systems Spring 2018 Lecture 2: Architectural Support for Operating Systems Geoffrey M. Voelker Administrivia Project 0 Due 4/9 11:59pm, done individually Homework #1 Due
More informationcoreboot - Bug #86 IRQ errors precede slow down of tape I/O, via SCSI and PCI/PCIe bridge
coreboot - Bug #86 IRQ errors precede slow down of tape I/O, via SCSI and PCI/PCIe bridge 12/12/2016 07:35 PM - Andrew Engelbrecht Status: New Start date: 12/12/2016 Priority: Normal Due date: Assignee:
More informationChapter 2: The Microprocessor and its Architecture
Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Chapter 2: The Microprocessor and its Architecture Introduction This chapter presents the microprocessor
More informationFinish up OS topics Group plans
Finish up OS topics Group plans Today Finish up and review Linux device driver stuff Walk example again See how it all goes together Discuss talking to MMIO RTOS (on board) Deferred interrupts Discussion
More informationIntroduction to Linux Device Drivers Recreating Life One Driver At a Time
Introduction to Linux Device Drivers Recreating Life One Driver At a Time Muli Ben-Yehuda mulix@mulix.org IBM Haifa Research Labs, Haifa Linux Club Linux Device Drivers, Technion, Jan 2004 p.1/42 why write
More informationNPTEL Course Jan K. Gopinath Indian Institute of Science
Storage Systems NPTEL Course Jan 2012 (Lecture 18) K. Gopinath Indian Institute of Science Spinlocks & Semaphores Shared data betw different parts of code in kernel most common: access to data structures
More informationDynamic Tracing and Instrumentation
Dynamic Tracing and Instrumentation Bryan Cantrill and Mike Shapiro (bmc, mws@eng.sun.com) Solaris Kernel Group Kernel Debugging Today if (no_advanced_debugging) printf(9f) ASSERT(i_am_a_debug_kernel!=
More informationDebugging Linux systems using GDB and QEMU. Khem Raj
Debugging Linux systems using GDB and QEMU Khem Raj Agenda Introduction Compiling and debugging Linux kernel using QEMU Creating image file for root file system Compiling and debugging uclibc dynamic linker
More informationWindows Interrupts
Windows 2000 - Interrupts Ausgewählte Betriebssysteme Institut Betriebssysteme Fakultät Informatik 1 Interrupts Software and Hardware Interrupts and Exceptions Kernel installs interrupt trap handlers Interrupt
More information4/9/17. Memory sharing. Device sharing. Princeton University Computer Science 217: Introduction to Programming Systems.
Princeton University Computer Science 217: Introduction to Programming Systems sharing Just one CPU, but each appears to have its own CPU s and Processes 1 2 10 milliseconds Much of the material for this
More informationAnalyzing Kernel Behavior by SystemTap
Analyzing Kernel Behavior by SystemTap Kernel Tracer Approach 2009/2/25 Hitachi, Ltd., Software Division Noboru Obata ( ) Hitachi, Ltd. 2009. All rights reserved. Contents 1. Improving RAS Features for
More informationSistemi in Tempo Reale
Laurea Specialistica in Ingegneria dell'automazione Sistemi in Tempo Reale Giuseppe Lipari Introduzione alla concorrenza Fundamentals Algorithm: It is the logical procedure to solve a certain problem It
More informationCS 5460/6460 Operating Systems
CS 5460/6460 Operating Systems Fall 2009 Instructor: Matthew Flatt Lecturer: Kevin Tew TAs: Bigyan Mukherjee, Amrish Kapoor 1 Join the Mailing List! Reminders Make sure you can log into the CADE machines
More information