Protection and OS Structure

Slides:



Advertisements
Similar presentations
The Kernel Abstraction. Challenge: Protection How do we execute code with restricted privileges? – Either because the code is buggy or if it might be.
Advertisements

CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Virtual Machine Monitors CSE451 Andrew Whitaker. Hardware Virtualization Running multiple operating systems on a single physical machine Examples:  VMWare,
Stack Management Each process/thread has two stacks  Kernel stack  User stack Stack pointer changes when exiting/entering the kernel Q: Why is this necessary?
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
Protection and the Kernel: Mode, Space, and Context.
G53SEC 1 Reference Monitors Enforcement of Access Control.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Windows 2000 System Mechanisms Computing Department, Lancaster University, UK.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
G53SEC 1 Reference Monitors Enforcement of Access Control.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Lecture Topics: 10/29 Architectural support for operating systems –timers –kernel mode –system calls –protected instructions.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
CSE 451: Operating Systems Winter 2015 Module 25 Virtual Machine Monitors Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
Of Privilege, Traps, Interrupts & Exceptions Prof. Sirer CS 316 Cornell University.
CSCE451/851 Introduction to Operating Systems
Virtual Machine Monitors
Introduction to Operating Systems
Introduction to Operating Systems
Interrupts and exceptions
Memory Protection: Kernel and User Address Spaces
CS 6560: Operating Systems Design
CSE451 Operating Systems Winter 2012
Anton Burtsev February, 2017
Protection of System Resources
CS 3305 System Calls Lecture 7.
File Systems CSE451 Andrew Whitaker
CSE451 Operating Systems Winter 2011
CSE 120 Principles of Operating
Memory Protection: Kernel and User Address Spaces
Introduction to Operating Systems
Memory Protection: Kernel and User Address Spaces
CSE 451: Operating Systems Spring 2012 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
CSE 451: Operating Systems Spring 2006 Module 2 Architectural Support for Operating Systems John Zahorjan 534 Allen Center.
Computer-System Architecture
Module 2: Computer-System Structures
CSE 451: Operating Systems Winter 2006 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CSE 153 Design of Operating Systems Winter 18
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
Architectural Support for OS
Operating Systems Lecture 3.
CSE 451: Operating Systems Autumn 2004 Module 2 Architectural Support for Operating Systems Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
CSE 451: Operating Systems Spring 2005 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
CSE 451: Operating Systems Autumn 2009 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
CSE 451: Operating Systems Autumn Module 24 Virtual Machine Monitors
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
CSE 451: Operating Systems Winter 2004 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
Module 2: Computer-System Structures
Steve Gribble (for Hank Levy)
File Systems CSE451 Andrew Whitaker
CSE 451: Operating Systems Autumn Module 24 Virtual Machine Monitors
Interrupts and System Calls
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Presentation transcript:

Protection and OS Structure Andrew Whitaker CSE451

Protection Challenge: OS must safely support multiple protection domains OS as “law enforcement” Goals Buggy application can’t crash the system Malicious application can’t take control User data is protected from untrusted users and programs Not always the case: e.g., DOS

The User/Kernel boundary Implemented in hardware Allows the OS to execute privileged instructions Applications enter kernel mode by executing a system call App App App user OS kernel

Examples of Privileged Instructions Manipulating I/O devices Why? Interrupt enable/disable flag Halt instruction

System Call Overview User program invokes helper procedure e.g., read, write, gettimeofday Helper passes control to the OS Indicates the system call number Packages user arguments into registers Issues a software interrupt (or trap) OS saves user state (registers) OS invokes appropriate system call handler OS returns control to the user application

A kernel crossing illustrated Firefox: read(int fileDescriptor, void *buffer,int numBytes); ) package arguments trap to kernel mode user mode kernel mode restore app state, return to user mode, resume trap handler save registers find sys_read( ) handler in vector table sys_read( ) kernel routine

Kernel Entry Points Interrupts Software interrupts (traps, exceptions) Disk, network, timer, etc. Software interrupts (traps, exceptions) System calls Protection violations e.g,. User executes a privileged instructions Page faults Error conditions e.g., divide by zero, illegal opcode

Memory Protection Problem #1: OS must protect applications from each other Solution: virtual memory -- each application has its own address space, which maps to private physical pages Problem #2: Kernel must protect its own code and data Solution: Split address space in half Kernel half requires privileged mode access

Simplified Linux Address Space Layout kernel space user-accessible Q: Why is the zero page unmapped? 0xc0000000

Other Forms of OS Protection Disk protection: Expressed in terms of file system access control permissions (UNIX: read, write, execute) drwxr-xr-x 4 gaetano www 4096 Mar 15 2005 sewpc drwxrwx--x 4 zahorjan www 4096 Mar 15 2005 software drwxrwxr-x 9 levy www 4096 Mar 16 2005 sosp16 -rw------- 1 lazowska www 2006 Oct 9 1998 staff drwxrwxr-x 3 beame ctheory 4096 Jun 1 2002 stoc96 CPU protection: Must guarantee each process a fraction of the CPU users files

Sample Test Question: Insecure System Call Consider a hypothetical system call, zeroFill, which fills a user buffer with zeroes: zeroFill(char* buffer, int bufferSize); The following kernel implementation of zeroFill contains a security vulnerability. What is the vulnerability, and how would you fix it? void sys_zeroFill(char* buffer, int bufferSize) { for (int i=0; i < bufferSize; i++) { buffer[i] = 0; }}

Solution The user buffer pointer is untrusted, and could point anywhere. In particular, it could point inside the kernel address space. This could lead to a system crash or security breakdown. Fix: verify the pointer is a valid user address

Follow-up Question Is it a security risk to execute the zeroFill function in user-mode? void zeroFill(char* buffer, int bufferSize) { for (int i=0; i < bufferSize; i++) { buffer[i] = 0; }}

Solution No. User-mode code does not have permission to access the kernel’s address space. If it tries, the hardware raises an exception, which is safely handled by the OS More generally, no user mode code should ever be a security vulnerability. Unless the OS has a bug…

Sample Test Question What bad thing could happen if a user application could overwrite the interrupt dispatch vector? How does the OS prevent this?

Solution An application could: 1) Prevent I/O operations from ever completing; 2) Prevent time from advancing, thus dominating the processor Applications cannot modify the interrupt vector because it lives in the kernel address space. Any attempt to modify the interrupt vector raises a kernel exception, which is safely handled.

Sample Test Question What prevents an application from directly reading from the disk, instead of passing through file system access control checks?

Solution Instructions for manipulating I/O devices are privileged. Any attempt to use them in user mode raises a protection exception, which the operating system gracefully handles.