Week11: Race Conditions

Size: px
Start display at page:

Download "Week11: Race Conditions"

Transcription

1 Week11: Race Conditions Pascal Meunier, Ph.D., M.Sc., CISSP March 28, 2007 Developed thanks to the support of Symantec Corporation, NSF SFS Capacity Building Program (Award Number ) and the Purdue e-enterprise Center Copyright (2006 Purdue Research Foundation. All rights reserved.

2 Race Conditions (CWE ID 362) Definition: security issues resulting from concurrent or interruptible code Related concepts: Concurrency (ID 557), Multi-threading (ID 366) Thread safety (shared resources) Interrupts Re-entrant code (vs overwriting memory locations) Atomicity Transactions Late binding of labels to objects Security context switches (ID 368) Filesystem links (ID 59)

3 Time of Check, Time of Use Problem (ID 367) TOC/TOU Problem happens with these operations Check if something is OK to do Do it In a pre-emptively multi-tasked environment, anything could happen in-between the execution of two assembly code operations Conditions may change in-between and the check becomes invalid Example: "switch" statement race condition (ID 365) The variable used for the "switch" may change value during execution

4 Example Race Condition User 1 creates a file with world-writable permissions User 1 wants to change the permissions to exclude others with "chmod 700 filename" User 2 tries to overwrite the file in-between Will user 1 or user 2 succeed? User 1 should have set the umask correctly!

5 Database Race Condition If (condition for field 1) then do something to field 2 However process 2 changes field 1 in-between... Result: invalid combination of values (e.g., bank account balance) Program invariant is violated Integrity of records is violated

6 Example Race Condition Two processes: red and blue Red: Check that user 1 has enough money to pay check #y Blue: Check that user 1 has enough money to pay check #x Red: Pay check #y Is there really enough money to pay check #x?

7 Handling Signals Signals are another way in which your program flow can get interrupted If your program gets interrupted while managing data structures, it is dangerous for the signal handler to attempt to use those structures Signal handlers can get interrupted by other (different) signals! (CWE ID 364) What if the same handler is called for multiple signals? Is the handler's code re-entrant? Example attack: calling free in non-re-entrant clean-up code that is interrupted and called again free may get called twice (see double-frees in NVD)

8 Solutions Atomic operations: An operation that can't be interrupted is called "atomic" Mechanisms that prevent concurrent access to, or modification of, an object by different processes or threads Semaphores (up to the programmer to do correctly) Lock files vs file locking Database locks Critical regions (enforced by compilers) Monitors (enforced by compilers) Special assembly code instructions for accessing and managing memory (e.g., multi-processor environments)

9 Database Locks Race conditions described above can be prevented while using a database to store the data Table and row locks Nobody else can write to a database object while you have a read lock Nobody else can read or write to a database object while you have a write lock Transactions Instead of locking, if the database can't complete the operation (due to competing accesses), the database can revert to a valid (past) state Database integrity is preserved However the operation you were attempting can fail

10 Lock Files Typically used for: Checking if another copy of a program (e.g., a server or an installer) is running Typically is either empty or contains the pid of a process Can be used like a primitive semaphore Compliance is purely voluntary and isn't enforced by the OS May introduce vulnerabilities Unrestricted Critical Resource Lock (412) CVE Predictable file names used for locking, allowing attacker to create the lock beforehand.

11 Mini-Lab: Lock File Make a "C" program that creates a lock file If the lock file already exists, it should print a message stating so and exit. Otherwise, it should sleep 20 seconds, print that it was successful, delete the lock file and exit. Try to run it twice simultaneously (e.g., two terminals). What happens? Is it possible in your implementation to have a race condition if two copies are started simultaneously? Check all the flags that you can use with "open"

12 What to Submit Your code A copy of terminal sessions showing that it operates correctly (as defined on the previous slide) Due April 11 before start of class

13 File Locking UNIX file locks are "advisory", i.e., not enforced by the operating system shared exclusive Windows: files aren't shared by default Files may have locks if shared: shared exclusive byte-ranged Sometimes this is advisory, sometimes it is enforced. One needs to be careful

14 Object Locks The "synchronized" keyword (Java) locks an object synchronized(this) { } Be careful of conditions before entering a synchronized section, if the conditions depend on what happens in that section Could trigger a race condition Can happen in other languages as well

15 Example: Double-checked locking anti-pattern Lazy initialization if (helper == null) { synchronized(this) { if (helper == null) { helper = new Helper(); } } } "helper" may be assigned a value by thread "A" before it is ready for use by other threads Reference: "The "Double-Checked Locking is Broken" Declaration" at CheckedLocking.html

16 Problems in Context Switches (ID 368) Context switch between operations done at different privilege levels and in different security contexts isn't done atomically Case study: Web browsers Navigating web sites with different security properties CVE XSS when web browser executes Javascript events in the context of a new page while it's being loaded, allowing interaction with previous page in different domain.

17 File System Race Conditions Files can be accessed by either name, or a file handle (Windows) or file descriptor (UNIX) Files can be renamed, deleted, moved, etc... Names and paths are bound to files at the time of a function call The same path and name can refer to different objects, given different times Typical TOC/TOU issue: Permissions, file length, ownership, etc... are checked first Then an operation is attempted An attacker will substitute another object for the second operation

18 UNIX Filenames vs File Descriptors Filenames and directory structure are changeable Open file descriptors are fixed System calls that use a file descriptor are to be used whenever possible instead of the equivalent functionality using paths fchmod(int fd, mode_t mode); fchown(int fd, uid_t owner, gid_t group); fchdir(int fd); fstat(int fd, struct stat *sb); File descriptors specify an inode (see next slide)

19 Inodes An inode is a data structure containing user, group and access control information (and more) The inode specifies the location of the file on the disk Hard links associate a name to an inode Several hard links can point to a single inode There's no difference between the "first" hard link and others Inodes are deleted only when all references have been deleted Open file descriptors and hard links count as references Directories also have inodes

20 Hard Links in UNIX By creating hard links, an attacker could make you: Change the permissions of an unintended file Change the contents of an unintended file Defenses: Manipulate files inside safe directories (with correctly set permissions) Don't open and manipulate files as root if you don't need to Don't re-open temporary files in shared directories (more on this later)

21 File System Links Hard links Windows: CreateHardLink UNIX: ln Symbolic links UNIX and Windows Vista: ln -s Windows: a.k.a. "directory junctions" in NTFS Manually: use Linkd.exe (Win 2K resource kit) or "junction" freeware Virtual Drives "subst" command Shortcuts (.lnk files)

22 Virtual Drives (Windows) Similar to symbolic links but limited functionality Effect A drive letter ("X:") actually points to a directory on a physical drive Overcomes limits on path length NTFS has limit of characters Windows has a limit of 256 characters NT, 2000, XP "Path too long" error Malicious software can hide inside very long paths Setup using a "subst" virtual drive Remove drive, and virus scanner can't find it!

23 Subst Vulnerability Virtual drives persist after a user logs off (NT) If next user tries to use that same letter drive, they may use a folder of the attacker's choosing Store confidential files Run trojans Example: Network-mapped home drive Mounting operation used to fail silently if the drive letter was already in use CVE

24 Windows Shortcuts (CWE ID 64) Created with a.lnk file Handled by the application, not automatically by the OS Can link files to files, or urls to files Someone typing in Internet Explorer may end up launching an executable instead of browsing there Firefox is not affected, because this is applicationdependent Reference: ck_is_a_feature_microsoft/0, , ,00.htm

25 Hard Links Indistinguishable from original entry (peer) May not refer to directories or span file systems Created link is subject to the same, normal file access permissions. Deleting a hard link doesn't delete the file unless all references to the file have been deleted A reference is either a hard link or an open file descriptor In Windows, a hard link exists at the NTFS file system level and is not supported by FAT32 Note: Different from a Windows shortcut

26 Example % ls -al.localized -rw-r--r-- root wheel.localized % ln.localized pascal/hard.loc % ls -al pascal/hard.loc -rw-r--r-- root wheel hard.loc % rm pascal/hard.loc override rw-r--r-- root/wheel for pascal/hard.loc? yes % ls -al.localized -rw-r--r-- root wheel.localized Note that the hard link showed the same permissions Note that deleting the hard link didn't delete the file (the reference count was not zero)

27 Hard Link Vulnerability Example (CWE ID 62) Fool audit logging programs by using a hard link to a sensitive file Audit trails record benign name instead of sensitive file access CVE (NTFS)

28 Symbolic Links Windows Directory junctions apply to directories only Can refer to directories on different computers Jargon: "File system reparse points" Contain parameters resolved at access time Several operations, complex setup (see tion) UNIX and Windows Vista Contain a path, which is resolved at access time May refer to directories and files May span file systems Permissions appear different from the original

29 Symbolic Link Example Using the same starting file as for the hard link example: % ln -s.localized pascal/sym.loc % ll pascal/sym.loc lrwxr-xr-x 1 pascal staff pascal/sym.loc ->.localized Note: The -> ) The permissions (see the l?) The owner and group are different (they were root/wheel for ".localized") Deleting the symlink doesn't delete the file

30 Power of Symbolic Links You can create links to files that don t exist yet Symlinks continue to exist after the files they point to have been renamed, moved or deleted They are not updated You can create links to arbitrary files, even in file systems you can t see Symlinks can link to files located across partition and disk boundaries Example: You can change the version of an application in use, or even an entire web site, just by changing a symlink Very convenient!

31 Basic Symlink Attack (CWE ID 61) Trick a process (with higher privileges) to operate on another file than the one it thinks it is. Example: Create the link "temp -> /etc/password" A privileged process executes truncate( temp, 0) The "truncate" call follows symlinks Changes the length of the file "temp" to 0 But truncated /etc/password instead! Note that the contents are deleted, not the file Can be used for write or read operations Or deletion if the symlink is in the path and not the end point

32 Conditions of Vulnerability If you are operating in a secured directory, you don't need to worry about symlink attacks A secured directory is one with permissions of all the directories from the root of the file system to your directory, set such that only you (or root) can make changes in your secured directory Example: /home/me (user home directories are usually set by default with secure permissions) You are at risk if you operate In a shared directory such as /tmp In someone else's directory, especially with elevated privileges Example: an anti-virus program running as administrator

33 Example: CUPS Vulnerability CVE Common Unix Printing System (CUPS) through allows local users with lp privileges to create or overwrite arbitrary files via file race conditions, as demonstrated by "ice-cream". Predictable file name: '/etc/cups/certs/<pid>' Shared directory with users that have "lp" privilege "lp" privilege could be gained through another exploit File manipulated using root privileges Symlink redirected operations anywhere and allowed gaining root privileges

34 Suggested Workarounds 1) Store the file in a secured directory It was stored in a shared directory 2) Relinquish root privileges before doing file operations (if not needed) 3) Use a random name 4) Create files with "umask 077" New files will give no permissions to groups and others What about third-party components that you utilize?

35 Question In Unix, which one of these allows an attacker to fool you into deleting a different file than you intended? a) Hard links b) Symbolic links in the path, excluding the file itself c) File descriptors d) Inodes

36 UNIX Defenses: Creating a file int open(const char *path, int oflag, mode_t mode); The flags should be O_CREAT O_EXCL If the last path item is a symbolic link and O_CREAT and O_EXCL are set, the link is not followed. The check for symlinks and the file creation with the correct permissions (mode) are not subject to race conditions (it's an atomic operation) The mode should be as narrow as practical Can your lock file program be fooled by a symlink? Is it possible for an attacker to delete your lock file and directory, create a link and make you delete something else? Create a fake lock file before your program runs?

37 Conclusions Race conditions are difficult to prevent when using late bindings e.g., paths and file names in file systems that are accessed by different users and processes Operating systems should always provide calls that unambiguously refer to objects (file systems and others) for all operations but they don't Most synchronization or serialization mechanisms depend on the good will of individual applications Windows, UNIX and C/C++ give you many opportunities to mess up

38 Questions or Comments?

39 About These Slides You are free to copy, distribute, display, and perform the work; and to make derivative works, under the following conditions. You must give the original author and other contributors credit The work will be used for personal or non-commercial educational uses only, and not for commercial activities and purposes For any reuse or distribution, you must make clear to others the terms of use for this work Derivative works must retain and be subject to the same conditions, and contain a note identifying the new contributor(s) and date of modification For other uses please contact the Purdue Office of Technology Commercialization. Developed thanks to the support of Symantec Corporation

40 Pascal Meunier Contributors: Jared Robinson, Alan Krassowski, Craig Ozancin, Tim Brown, Wes Higaki, Melissa Dark, Chris Clifton, Gustavo Rodriguez-Rivera

Secure Software Programming and Vulnerability Analysis

Secure Software Programming and Vulnerability Analysis Secure Software Programming and Vulnerability Analysis Christopher Kruegel chris@auto.tuwien.ac.at http://www.auto.tuwien.ac.at/~chris Race Conditions Secure Software Programming 2 Overview Parallel execution

More information

Advanced Systems Security: Ordinary Operating Systems

Advanced Systems Security: Ordinary Operating Systems Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Advanced Systems Security:

More information

CS390S, Week 6: Shells and Environment

CS390S, Week 6: Shells and Environment CS390S, Week 6: Shells and Environment Pascal Meunier, Ph.D., M.Sc., CISSP February 13, 2008 Developed thanks to support and contributions from Symantec Corporation, support from the NSF SFS Capacity Building

More information

Virtual File System. Don Porter CSE 306

Virtual File System. Don Porter CSE 306 Virtual File System Don Porter CSE 306 History Early OSes provided a single file system In general, system was pretty tailored to target hardware In the early 80s, people became interested in supporting

More information

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:

RCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry: Logical Diagram VFS, Continued Don Porter CSE 506 Binary Formats RCU Memory Management File System Memory Allocators System Calls Device Drivers Networking Threads User Today s Lecture Kernel Sync CPU

More information

VFS, Continued. Don Porter CSE 506

VFS, Continued. Don Porter CSE 506 VFS, Continued Don Porter CSE 506 Logical Diagram Binary Formats Memory Allocators System Calls Threads User Today s Lecture Kernel RCU File System Networking Sync Memory Management Device Drivers CPU

More information

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand File Systems Basics Nima Honarmand File and inode File: user-level abstraction of storage (and other) devices Sequence of bytes inode: internal OS data structure representing a file inode stands for index

More information

C and C++ Secure Coding 4-day course. Syllabus

C and C++ Secure Coding 4-day course. Syllabus C and C++ Secure Coding 4-day course Syllabus C and C++ Secure Coding 4-Day Course Course description Secure Programming is the last line of defense against attacks targeted toward our systems. This course

More information

CS631 - Advanced Programming in the UNIX Environment

CS631 - Advanced Programming in the UNIX Environment CS631 - Advanced Programming in the UNIX Environment Slide 1 CS631 - Advanced Programming in the UNIX Environment Files and Directories Department of Computer Science Stevens Institute of Technology Jan

More information

SysSec. Aurélien Francillon

SysSec. Aurélien Francillon SysSec Aurélien Francillon francill@eurecom.fr https://www.krackattacks.com/ https://arstechnica.com/information-technology/2017/10/crypto-failure-cripples-millions-ofhigh-security-keys-750k-estonian-ids/

More information

3/7/18. Secure Coding. CYSE 411/AIT681 Secure Software Engineering. Race Conditions. Concurrency

3/7/18. Secure Coding. CYSE 411/AIT681 Secure Software Engineering. Race Conditions. Concurrency Secure Coding CYSE 411/AIT681 Secure Software Engineering Topic #13. Secure Coding: Race Conditions Instructor: Dr. Kun Sun String management Pointer Subterfuge Dynamic memory management Integer security

More information

Non-atomic check and use aka TOCTOU (Time of Check, Time of Use) or race conditions. Erik Poll Digital Security group Radboud University Nijmegen

Non-atomic check and use aka TOCTOU (Time of Check, Time of Use) or race conditions. Erik Poll Digital Security group Radboud University Nijmegen Non-atomic check and use aka TOCTOU (Time of Check, Time of Use) or race conditions Erik Poll Digital Security group Radboud University Nijmegen A classic source of (security) problems race condition aka

More information

Processes are subjects.

Processes are subjects. Identification and Authentication Access Control Other security related things: Devices, mounting filesystems Search path Race conditions NOTE: filenames may differ between OS/distributions Principals

More information

CYSE 411/AIT681 Secure Software Engineering Topic #13. Secure Coding: Race Conditions

CYSE 411/AIT681 Secure Software Engineering Topic #13. Secure Coding: Race Conditions CYSE 411/AIT681 Secure Software Engineering Topic #13. Secure Coding: Race Conditions Instructor: Dr. Kun Sun 1 Secure Coding String management Pointer Subterfuge Dynamic memory management Integer security

More information

SECURE PROGRAMMING TECHNIQUES. Race conditions. General terms. File access races. Network races. Multithreading. Signal handling races MEELIS ROOS 1

SECURE PROGRAMMING TECHNIQUES. Race conditions. General terms. File access races. Network races. Multithreading. Signal handling races MEELIS ROOS 1 Race conditions General terms File access races Network races Multithreading Signal handling races MEELIS ROOS 1 General terms Race condition correctness of the program depends on timing (race with an

More information

Secure Architecture Principles

Secure Architecture Principles Computer Security Course. Secure Architecture Principles Slides credit: Dan Boneh What Happens if you can t drop privilege? In what example scenarios does this happen? A service loop E.g., ssh Solution?

More information

Symlink attacks. Do not assume that symlinks are trustworthy: Example 1

Symlink attacks. Do not assume that symlinks are trustworthy: Example 1 Symlink attacks Do not assume that symlinks are trustworthy: Example 1 Application A creates a file for writing in /tmp. It assumes that since the file name is unusual, or because it encodes A's name or

More information

File System Definition: file. File management: File attributes: Name: Type: Location: Size: Protection: Time, date and user identification:

File System Definition: file. File management: File attributes: Name: Type: Location: Size: Protection: Time, date and user identification: File System Definition: Computer can store the information on different storage media such as magnetic disk, tapes, etc. and for convenience to use the operating system provides the uniform logical view

More information

Chapter 6. File Systems

Chapter 6. File Systems Chapter 6 File Systems 6.1 Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems 350 Long-term Information Storage 1. Must store large amounts of data 2. Information stored must

More information

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017 ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 The Operating System (OS) Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke)

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 19 Lecture 7/8: Synchronization (1) Administrivia How is Lab going? Be prepared with questions for this weeks Lab My impression from TAs is that you are on track

More information

Virtual File System. Don Porter CSE 506

Virtual File System. Don Porter CSE 506 Virtual File System Don Porter CSE 506 History ò Early OSes provided a single file system ò In general, system was pretty tailored to target hardware ò In the early 80s, people became interested in supporting

More information

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories Chapter 4 - Files and Directories Information about files and directories Management of files and directories File Systems Unix File Systems UFS - original FS FFS - Berkeley ext/ext2/ext3/ext4 - Linux

More information

File System NTFS. Section Seven. NTFS, EFS, Partitioning, and Navigating Folders

File System NTFS. Section Seven. NTFS, EFS, Partitioning, and Navigating Folders 13 August 2002 File System Section Seven NTFS, EFS, Partitioning, and Navigating Folders NTFS DEFINITION New Technologies File System or NTFS was first applied in Windows NT 3.0 back in 1992. This technology

More information

Cox Business Online Backup Administrator Guide. Version 2.0

Cox Business Online Backup Administrator Guide. Version 2.0 Cox Business Online Backup Administrator Guide Version 2.0 2012 by Cox Communications. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic,

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu CS@ECNU Operating System Labs Project 3 Oral test Handin your slides Time Project 4 Due: 6 Dec Code Experiment report Operating System Labs Overview of file system File

More information

Files and File Systems

Files and File Systems File Systems 1 Files and File Systems files: persistent, named data objects data consists of a sequence of numbered bytes alternatively, a file may have some internal structure, e.g., a file may consist

More information

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

CS61 Scribe Notes Date: Topic: Fork, Advanced Virtual Memory. Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu CS61 Scribe Notes Date: 11.6.14 Topic: Fork, Advanced Virtual Memory Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu Administrivia: Final likely less of a time constraint What can we do during

More information

FILE SYSTEMS. Jo, Heeseung

FILE SYSTEMS. Jo, Heeseung FILE SYSTEMS Jo, Heeseung TODAY'S TOPICS File system basics Directory structure File system mounting File sharing Protection 2 BASIC CONCEPTS Requirements for long-term information storage Store a very

More information

Race Condition Vulnerability Lab

Race Condition Vulnerability Lab Concordia Institute for Information Systems Engineering - INSE 6130 1 Race Condition Vulnerability Lab Copyright c 2006-2012 Wenliang Du, Syracuse University. The development of this document is funded

More information

Sandboxing. (1) Motivation. (2) Sandboxing Approaches. (3) Chroot

Sandboxing. (1) Motivation. (2) Sandboxing Approaches. (3) Chroot Sandboxing (1) Motivation Depending on operating system to do access control is not enough. For example: download software, virus or Trojan horse, how to run it safely? Risks: Unauthorized access to files,

More information

File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University File Systems Overview Jin-Soo Kim ( jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics File system basics Directory structure File system mounting

More information

The UNIX File System

The UNIX File System The UNIX File System Magnus Johansson (May 2007) 1 UNIX file system A file system is created with mkfs. It defines a number of parameters for the system as depicted in figure 1. These paremeters include

More information

File Systems. What do we need to know?

File Systems. What do we need to know? File Systems Chapter 4 1 What do we need to know? How are files viewed on different OS s? What is a file system from the programmer s viewpoint? You mostly know this, but we ll review the main points.

More information

CNIT 129S: Securing Web Applications. Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2

CNIT 129S: Securing Web Applications. Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2 CNIT 129S: Securing Web Applications Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2 Finding and Exploiting XSS Vunerabilities Basic Approach Inject this string into every parameter on every

More information

RCU. ò Dozens of supported file systems. ò Independent layer from backing storage. ò And, of course, networked file system support

RCU. ò Dozens of supported file systems. ò Independent layer from backing storage. ò And, of course, networked file system support Logical Diagram Virtual File System Don Porter CSE 506 Binary Formats RCU Memory Management File System Memory Allocators System Calls Device Drivers Networking Threads User Today s Lecture Kernel Sync

More information

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

CSC209H Lecture 1. Dan Zingaro. January 7, 2015 CSC209H Lecture 1 Dan Zingaro January 7, 2015 Welcome! Welcome to CSC209 Comments or questions during class? Let me know! Topics: shell and Unix, pipes and filters, C programming, processes, system calls,

More information

Case Studies in Access Control

Case Studies in Access Control Joint software development Mail 1 / 38 Situations Roles Permissions Why Enforce Access Controls? Unix Setup Windows ACL Setup Reviewer/Tester Access Medium-Size Group Basic Structure Version Control Systems

More information

Outline. Classic races: files in /tmp. Race conditions. TOCTTOU example. TOCTTOU gaps. Vulnerabilities in OS interaction

Outline. Classic races: files in /tmp. Race conditions. TOCTTOU example. TOCTTOU gaps. Vulnerabilities in OS interaction Outline CSci 5271 Introduction to Computer Security Day 3: Low-level vulnerabilities Stephen McCamant University of Minnesota, Computer Science & Engineering Race conditions Classic races: files in /tmp

More information

The bigger picture. File systems. User space operations. What s a file. A file system is the user space implementation of persistent storage.

The bigger picture. File systems. User space operations. What s a file. A file system is the user space implementation of persistent storage. The bigger picture File systems Johan Montelius KTH 2017 A file system is the user space implementation of persistent storage. a file is persistent i.e. it survives the termination of a process a file

More information

CptS 360 (System Programming) Unit 6: Files and Directories

CptS 360 (System Programming) Unit 6: Files and Directories CptS 360 (System Programming) Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2019 Motivation Need to know your way around a filesystem. A properly organized filesystem

More information

Files (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Files (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1 Files (review) and Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 midterms (Feb 11 and April 1) Files and Permissions Regular Expressions 2 Sobel, Chapter 6 160_pathnames.html

More information

CIS Operating Systems File Systems Security. Professor Qiang Zeng Fall 2017

CIS Operating Systems File Systems Security. Professor Qiang Zeng Fall 2017 CIS 5512 - Operating Systems File Systems Security Professor Qiang Zeng Fall 2017 Previous class File and directory Hard link and soft link Mount Layered structure File system design Naïve: linked list

More information

Table 12.2 Information Elements of a File Directory

Table 12.2 Information Elements of a File Directory Table 12.2 Information Elements of a File Directory Basic Information File Name File Type File Organization Name as chosen by creator (user or program). Must be unique within a specific directory. For

More information

Operating Systems Lab

Operating Systems Lab Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 4 Paths, Links & File Permissions

More information

How To Set User Account Password In Windows 7 From Guest

How To Set User Account Password In Windows 7 From Guest How To Set User Account Password In Windows 7 From Guest To change the password of a specific user in windows 7 or 8.1, without knowing How to change or set Windows 7 default font settings to bold, italic?

More information

CS2506 Quick Revision

CS2506 Quick Revision CS2506 Quick Revision OS Structure / Layer Kernel Structure Enter Kernel / Trap Instruction Classification of OS Process Definition Process Context Operations Process Management Child Process Thread Process

More information

Advanced System Security: Vulnerabilities

Advanced System Security: Vulnerabilities Advanced System Security: Vulnerabilities Trent Jaeger Systems and Internet Infrastructure Security (SIIS) Lab Computer Science and Engineering Department Pennsylvania State University CSE544 -Advanced

More information

Chapter 10: File-System Interface

Chapter 10: File-System Interface Chapter 10: File-System Interface Objectives: To explain the function of file systems To describe the interfaces to file systems To discuss file-system design tradeoffs, including access methods, file

More information

CSE543 - Introduction to Computer and Network Security

CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Software Vulnerabilities Professor Trent Jaeger 1 Programming Why do we write programs? Function What functions do we enable via our programs?

More information

The UNIX File System

The UNIX File System The UNIX File System Magnus Johansson May 9, 2007 1 UNIX file system A file system is created with mkfs. It defines a number of parameters for the system, such as: bootblock - contains a primary boot program

More information

Files and File Systems

Files and File Systems File Systems 1 files: persistent, named data objects Files and File Systems data consists of a sequence of numbered bytes file may change size over time file has associated meta-data examples: owner, access

More information

Files.Kennesaw.Edu. Kennesaw State University Information Technology Services. Introduces. Presented by the ITS Technology Outreach Team

Files.Kennesaw.Edu. Kennesaw State University Information Technology Services. Introduces. Presented by the ITS Technology Outreach Team Kennesaw State University Information Technology Services Introduces Files.Kennesaw.Edu Presented by the ITS Technology Outreach Team Last Updated 08/12/13 Powered by Xythos Copyright 2006, Xythos Software

More information

The Kernel Abstraction. Chapter 2 OSPP Part I

The Kernel Abstraction. Chapter 2 OSPP Part I The Kernel Abstraction Chapter 2 OSPP Part I Kernel The software component that controls the hardware directly, and implements the core privileged OS functions. Modern hardware has features that allow

More information

CSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19

CSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19 CSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19 User and Group IDs Ref: Chapter 3 of [HGS]. Each user is given an ID (integer) called uid. (Most system programs use uid instead of the

More information

CS 326: Operating Systems. Process Execution. Lecture 5

CS 326: Operating Systems. Process Execution. Lecture 5 CS 326: Operating Systems Process Execution Lecture 5 Today s Schedule Process Creation Threads Limited Direct Execution Basic Scheduling 2/5/18 CS 326: Operating Systems 2 Today s Schedule Process Creation

More information

CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O

CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O Sections 8.2-8.5, Bryant and O'Hallaron PROCESS CONTROL (CONT.) CMSC 216 - Wood, Sussman, Herman, Plane 2 Signals

More information

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell

More information

Parents and Children

Parents and Children 1 Process Identifiers Every process apart from the PID also has a PUID and a PGID. There are two types of PUID and PGID: real and effective. The real PUID is always equal to the user running the process

More information

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019 CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?

More information

Case Study: Access Control. Steven M. Bellovin October 4,

Case Study: Access Control. Steven M. Bellovin October 4, Case Study: Access Control Steven M. Bellovin October 4, 2015 1 Case Studies in Access Control Joint software development Mail Steven M. Bellovin October 4, 2015 2 Situations Small team on a single machine

More information

The Kernel Abstraction

The Kernel Abstraction The Kernel Abstraction Debugging as Engineering Much of your time in this course will be spent debugging In industry, 50% of software dev is debugging Even more for kernel development How do you reduce

More information

UNIX File Hierarchy: Structure and Commands

UNIX File Hierarchy: Structure and Commands UNIX File Hierarchy: Structure and Commands The UNIX operating system organizes files into a tree structure with a root named by the character /. An example of the directory tree is shown below. / bin

More information

Due: February 26, 2014, 7.30 PM

Due: February 26, 2014, 7.30 PM Jackson State University Department of Computer Science CSC 438-01/539-01 Systems and Software Security, Spring 2014 Instructor: Dr. Natarajan Meghanathan Project 1: Exploring UNIX Access Control in a

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 18: Naming, Directories, and File Caching 18.0 Main Points How do users name files? What is a name? Lookup:

More information

POSIX / System Programming

POSIX / System Programming POSIX / System Programming ECE 650 Methods and Tools for Software Eng. Guest lecture 2017 10 06 Carlos Moreno cmoreno@uwaterloo.ca E5-4111 2 Outline During today's lecture, we'll look at: Some of POSIX

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2002 Lecture 18: Naming, Directories, and File Caching 18.0 Main Points How do users name files? What is a name? Lookup:

More information

Chapter 11: File System Implementation. Objectives

Chapter 11: File System Implementation. Objectives Chapter 11: File System Implementation Objectives To describe the details of implementing local file systems and directory structures To describe the implementation of remote file systems To discuss block

More information

Principles of Operating Systems

Principles of Operating Systems Principles of Operating Systems Lecture 24-26 - File-System Interface and Implementation Ardalan Amiri Sani (ardalan@uci.edu) [lecture slides contains some content adapted from previous slides by Prof.

More information

File System Interface. ICS332 Operating Systems

File System Interface. ICS332 Operating Systems File System Interface ICS332 Operating Systems Files and Directories Features A file system implements the file abstraction for secondary storage It also implements the directory abstraction to organize

More information

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell

More information

Chapter 10: File-System Interface

Chapter 10: File-System Interface Chapter 10: File-System Interface Objectives: To explain the function of file systems To describe the interfaces to file systems To discuss file-system design tradeoffs, including access methods, file

More information

Processes are subjects.

Processes are subjects. Identification and Authentication Access Control Other security related things: Devices, mounting filesystems Search path TCP wrappers Race conditions NOTE: filenames may differ between OS/distributions

More information

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1 Student Name: Lab Section: Linux File System Permissions (modes) - Part 1 Due Date - Upload to Blackboard by 8:30am Monday March 12, 2012 Submit the completed lab to Blackboard following the Rules for

More information

Interprocess Communication By: Kaushik Vaghani

Interprocess Communication By: Kaushik Vaghani Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the

More information

Introduction to OS Synchronization MOS 2.3

Introduction to OS Synchronization MOS 2.3 Introduction to OS Synchronization MOS 2.3 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Challenge How can we help processes synchronize with each other? E.g., how

More information

CS 153 Design of Operating Systems Winter 2016

CS 153 Design of Operating Systems Winter 2016 CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization Administrivia Homework 1 Due today by the end of day Hopefully you have started on project 1 by now? Kernel-level threads (preemptable

More information

CS 33. Files Part 2. CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

CS 33. Files Part 2. CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. CS 33 Files Part 2 CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. Directories unix etc home pro dev passwd motd twd unix... slide1 slide2 CS33 Intro to Computer

More information

Execution of Multiple flows (threads, processes, tasks, etc) If not controlled can lead to nondeterministic behavior

Execution of Multiple flows (threads, processes, tasks, etc) If not controlled can lead to nondeterministic behavior Race Conditions March 27, 2006 March 27, 2006 Concurrency Concurrency and Race condition Execution of Multiple flows (threads, processes, tasks, etc) If not controlled can lead to nondeterministic behavior

More information

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

CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES Your name: SUNet ID: In accordance with both the letter and the spirit of the Stanford Honor Code, I did not cheat on this exam. Furthermore,

More information

Crystal Enterprise. Overview. Contents. Installation FAQ: Crystal Enterprise 9 & 10

Crystal Enterprise. Overview. Contents. Installation FAQ: Crystal Enterprise 9 & 10 : Crystal Enterprise 9 & 10 Overview Contents This document has been compiled in an effort to assist you both in determining installation requirements for your Crystal Enterprise (CE) installation as well

More information

Copyright (2004) Purdue Research Foundation. All rights reserved.

Copyright (2004) Purdue Research Foundation. All rights reserved. CS390S, Week 3: Buffer Overflows, Part 1 Pascal Meunier, Ph.D., M.Sc., CISSP January 23, 2008 Developed thanks to support and contributions from Symantec Corporation, support from the NSF SFS Capacity

More information

Lecture 2: Architectural Support for OSes

Lecture 2: Architectural Support for OSes Lecture 2: Architectural Support for OSes CSE 120: Principles of Operating Systems Alex C. Snoeren HW 1 Due Tuesday 10/03 Why Architecture? Operating systems mediate between applications and the physical

More information

Data Security and Privacy. Unix Discretionary Access Control

Data Security and Privacy. Unix Discretionary Access Control Data Security and Privacy Unix Discretionary Access Control 1 Readings for This Lecture Wikipedia Filesystem Permissions Other readings UNIX File and Directory Permissions and Modes http://www.hccfl.edu/pollock/aunix1/filepermissions.htm

More information

ICS Principles of Operating Systems

ICS Principles of Operating Systems ICS 143 - Principles of Operating Systems Lectures 17-20 - FileSystem Interface and Implementation Prof. Ardalan Amiri Sani Prof. Nalini Venkatasubramanian ardalan@ics.uci.edu nalini@ics.uci.edu Outline

More information

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

More information

Improving User Accounting and Isolation with Linux Kernel Features. Brian Bockelman Condor Week 2011

Improving User Accounting and Isolation with Linux Kernel Features. Brian Bockelman Condor Week 2011 Improving User Accounting and Isolation with Linux Kernel Features Brian Bockelman Condor Week 2011 Case Study: MPD The MPICH2 library is a common implementation of the MPI interface, a popular parallel

More information

Secure Coding in C and C++ Race conditions

Secure Coding in C and C++ Race conditions Secure Coding in C and C++ Race conditions Lecture 6 Oct 1, 2014 Acknowledgement: These slides are based on author Seacord s original presentation Concurrency and Race condition Concurrency Execution of

More information

8/31/2015 BITS BYTES AND FILES. What is a bit. Representing a number. Technically, it s a change of voltage

8/31/2015 BITS BYTES AND FILES. What is a bit. Representing a number. Technically, it s a change of voltage Personal Computing BITS BYTES AND FILES What is a bit Technically, it s a change of voltage Two stable states of a flip-flop Positions of an electrical switch That s for the EE folks It s a zero or a one

More information

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group. CMPS 12L Introduction to Programming Lab Assignment 2 We have three goals in this assignment: to learn about file permissions in Unix, to get a basic introduction to the Andrew File System and it s directory

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

Lecture 5: Synchronization w/locks

Lecture 5: Synchronization w/locks Lecture 5: Synchronization w/locks CSE 120: Principles of Operating Systems Alex C. Snoeren Lab 1 Due 10/19 Threads Are Made to Share Global variables and static objects are shared Stored in the static

More information

Files and Directories

Files and Directories Files and Directories Stat functions Given pathname, stat function returns structure of information about file fstat function obtains information about the file that is already open lstat same as stat

More information

Can Delete Sharing Folder Windows 7 Access Denied

Can Delete Sharing Folder Windows 7 Access Denied Can Delete Sharing Folder Windows 7 Access Denied File and folder permissions on Windows are pretty great when they're working for you but when the OS suddenly decides to deny access to a folder on your

More information

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD: ,

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD: , Question 2: (15 Marks) The Sleeping-Barber Problem: A barbershop consists of a waiting room with n chairs, and the barber room containing the barber chair. If there are no customers to be served, the barber

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu CS@ECNU Operating System Labs Project 4 (multi-thread & lock): Due: 10 Dec Code & experiment report 18 Dec. Oral test of project 4, 9:30am Lectures: Q&A Project 5: Due:

More information

Inode. Local filesystems. The operations defined for local filesystems are divided in two parts:

Inode. Local filesystems. The operations defined for local filesystems are divided in two parts: Local filesystems Inode The operations defined for local filesystems are divided in two parts: 1. Common to all local filesystems are hierarchical naming, locking, quotas attribute management and protection.

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Review: RAID 2 RAID o Idea: Build an awesome disk from small, cheap disks o Metrics: Capacity, performance, reliability 3 RAID o Idea:

More information

File-System Interface. File Structure. File Concept. File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection

File-System Interface. File Structure. File Concept. File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection TDIU11 Operating Systems File-System Interface File-System Interface [SGG7/8/9] Chapter 10 File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection How the file system

More information