User-level processes (clients) request services from the kernel (server) via special protected procedure calls



Similar documents
Migration of Process Credentials

Kernel Intrusion Detection System

Lab 6: Building Your Own Firewall

Linux Distributed Security Module 1

USB Driver. Installation Guide for LTE Devices

Linux Firewall Lab. 1 Overview. 2 Lab Tasks. 2.1 Task 1: Firewall Policies. Laboratory for Computer Security Education 1

Linux LKM Firewall v 0.95 (2/5/2010)

CSE543 - Introduction to Computer and Network Security. Module: Operating System Security

Linux Kernel Architecture

Remote PC Guide Series - Volume 2a

Ubuntu Professional Training Course Overview (E-learning, Ubuntu LTS)

Performance Monitor on PowerQUICC II Pro Processors

How to Restore a Linux Server Using Bare Metal Restore

Operating Systems Design 16. Networking: Sockets

Embedded Linux development training 4 days session

Safety measures in Linux

Restoring a Suse Linux Enterprise Server 9 64 Bit on Dissimilar Hardware with CBMR for Linux 1.02

ITRAINONLINE MMTK WIRELESS CLIENT INSTALLATION HANDOUT

How to Add a New System Call for Minix 3

NSA Security-Enhanced Linux (SELinux)

An Embedded Wireless Mini-Server with Database Support

Linux Kernel Rootkit : Virtual Terminal Key Logger

CBMR for Linux v6.2.2 User Guide

Linux Server (Web, FTP, File) on Vmware

Assignment 5: Adding and testing a new system call to Linux kernel

Create a virtual machine at your assigned virtual server. Use the following specs

Remote PC Guide Series - Volume 2b

UNIX Sockets. COS 461 Precept 1

Minix Mini Unix (Minix) basically, a UNIX - compatible operating system. Minix is small in size, with microkernel-based design. Minix has been kept

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

Step By Step Guide for Starting "Hello, World!" on OpenWRT

Chapter 2 System Structures

Example of Standard API

EXPLORING LINUX KERNEL: THE EASY WAY!

Five standard procedures for building the android system. Figure1. Procedures for building android embedded systems

Virtualization for Cloud Computing

Analysis of the Linux Audit System 1

USB Driver. Installation Guide for H5 Devices

Project Adding a System Call to the Linux Kernel

Q N X S O F T W A R E D E V E L O P M E N T P L A T F O R M v Steps to Developing a QNX Program Quickstart Guide

WES 9.2 DRIVE CONFIGURATION WORKSHEET

PiFace Control & Display

Survey of Filesystems for Embedded Linux. Presented by Gene Sally CELF

Trusted RUBIX TM. Version 6. Installation and Quick Start Guide Red Hat Enterprise Linux 6 SELinux Platform. Revision 6

Tutorial. Reference for more thorough Mininet walkthrough if desired

sys socketcall: Network systems calls on Linux

Quick Deployment Step-by-step instructions to deploy Oracle Big Data Lite Virtual Machine

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Operating System Engineering: Fall 2005

The Linux CryptoAPI A User s Perspective

Operating Systems Project: Device Drivers

Cosmic Board for phycore AM335x System on Module and Carrier Board. Application Development User Manual

Installing VMware Tools on Clearswift v4 Gateways

Yosemite Server Backup Installation Guide

Linux Embedded devices with PicoDebian Martin Noha

Libmonitor: A Tool for First-Party Monitoring

SETTING UP A LAMP SERVER REMOTELY

HW (Fat001) TPM. Figure 1. Computing Node

Linux Driver Devices. Why, When, Which, How?

Load Balancing - Single Multipath Route HOWTO

10 STEPS TO YOUR FIRST QNX PROGRAM. QUICKSTART GUIDE Second Edition

SELinux. Security Enhanced Linux

I Control Your Code Attack Vectors Through the Eyes of Software-based Fault Isolation. Mathias Payer, ETH Zurich

Eaton NetWatch NetWatch installation and configuration guide VMware ESX 3 Virtual architecture

Newton2 Developers Guide

Using the NicheStack TCP/IP Stack - Nios II Edition Tutorial

Acronis Backup & Recovery 10 Server for Linux. Quick Start Guide

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Building a Python Plugin

Systemd for Embedded Linux. Challenges and Opportunities

Introduction. dnotify

Freescale Semiconductor, I

Toasterkit - A NetBSD Rootkit. Anthony Martinez Thomas Bowen

How To Run A Password Manager On A 32 Bit Computer (For 64 Bit) On A 64 Bit Computer With A Password Logger (For 32 Bit) (For Linux) ( For 64 Bit (Foramd64) (Amd64 (For Pc

8 Tutorial: Using ASN.1

Image Acquisition Toolbox Adaptor Kit User's Guide

IT6204 Systems & Network Administration. (Optional)

CS197U: A Hands on Introduction to Unix

CPSC 226 Lab Nine Fall 2015

A Design of Video Acquisition and Transmission Based on ARM. Ziqiang Hao a, Hongzuo Li b

ORACLE BUSINESS INTELLIGENCE WORKSHOP. Prerequisites for Oracle BI Workshop

AlienVault Unified Security Management (USM) 4.x-5.x. Deploying HIDS Agents to Linux Hosts

Implementing SAN & NAS with Linux by Mark Manoukian & Roy Koh

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Operating System Structures

One-Stop Intel TXT Activation Guide

Getting Started with the Linux Intrusion Detection

How to Create, Setup, and Configure an Ubuntu Router with a Transparent Proxy.

Operating System Overview. Otto J. Anshus

RocketRAID 2640/2642 SAS Controller Ubuntu Linux Installation Guide

The POSIX Socket API

Creating a DUO MFA Service in AWS

Using Red Hat Enterprise Linux with Georgia Tech's RHN Satellite Server Installing Red Hat Enterprise Linux

Installing Proview on an Windows XP machine

Chapter 3 Operating-System Structures

QuickBooks Enterprise Solutions. Linux Database Server Manager Installation and Configuration Guide

Upgrade ProTracker Advantage Access database to a SQL database

PetaLinux SDK User Guide. Application Development Guide

Installing Java (Windows) and Writing your First Program

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Transcription:

Linux System Call

What is System Call? User-level processes (clients) request services from the kernel (server) via special protected procedure calls System calls provide: An abstraction layer between processes and hardware, allowing the kernel to provide access control, arbitration A virtualization of the underlying system A well-defined API for system services

System Call Procedure in Linux

Add New System Call (Tutorial 1) Download Kernel Source Code Kernel-level modification (1) Allocate an unused system call number (2) Register sys_call_table (3) Program new system call handler (4) Kernel compile and rebooting User-level modification (1) Make library interface (2) Make user program that call the library function

Add New System Call (Tutorial 1) Download Kernel Source Code Kernel-level modification (1) Allocate an unused system call number (2) Register sys_call_table (3) Program new system call handler (4) Kernel compile and rebooting User-level modification (1) Make library interface (2) Make user program that call the library function

Download Kernel Source Code Tutorial environment 32bit Ubuntu 12.04 (Kernel Version : 3.2.0) on VMware Download Kernel Source Code (1) $ apt-get source linux-image-$(uname -r) (2) or Download at http://www.kernel.org

Add New System Call (Tutorial 1) Download Kernel Source Code Kernel-level modification (1) Allocate an unused system call number (2) Register sys_call_table (3) Program new system call handler (4) Kernel compile and rebooting User-level modification (1) Make library interface (2) Make user program that call the library function

Allocate Unused System Call Number /(source code path)/arch/x86/include/asm/unistd_32.h

Register sys_call_table /(source code path)/arch/x86/kernel/syscall_table_32.s

Program new system call handler /(source code path)/kernel/newsyscall.c

Modify Makefile /(source code path)/kernel/makefile

Kernel Compile and Rebooting $ apt-get update $ apt-get install build-essential libncurses5 libncurses5-dev /(source code path)/ Follow the below commands to compile the kernel (1) $ make menuconfig (2) $ make bzimage (3) $ make modules (4) $ make modules_install (5) $ make install modify /etc/default/grub like below Change grub configuration Reboot Press esc key to see the grub menu $ update-grub

Add New System Call (Tutorial 1) Download Kernel Source Code Kernel-level modification (1) Allocate an unused system call number (2) Register sys_call_table (3) Program new system call handler (4) Kernel compile and rebooting User-level modification (1) Make library interface (2) Make user program that call the library function

Make Library Interface and User Program Library Interface If you get the message such as NR_newsyscall is not defined, you can add a line in /usr/include/i386- linux-gnu/asm/unistd_32.h as follow User Program /usr/include/i386-linux-gnu/asm/unistd_32.h

Check the Results Check the kernel print message $ dmesg $ tail f /var/log/syslog

Linux Kernel Module

What is Kernel Module? A Module is a object file that contains code to extend the functionality of the base kernel Modules are used to add support for new hardware and file systems Also used to add new system calls and executable interpreters

Linking a Module to the Kernel Reference : Linux Device Drivers 2 nd Edition

Make a Kernel Module (Tutorial 2) Write a simple module code Write a Makefile Load the simple module to kernel

Simple Module Code

Makefile

Load the Module

Check the Module List $ lsmod $ cat /proc/modules

Load a Module at the Boot Time $ make install Add the name of module to the /etc/modules $ depmod Reboot

Linux Security Module

What is Linux Security Module? LSM(Linux Security Module) is a framework that allows the Linux kernel to support a variety of computer security models while avoiding favoritism toward any single security implementation. The framework is standard part of the Linux kernel since Linux 2.6. AppArmor, SELinux, Smack and TOMOYO Linux are the currently accepted modules in the official kernel. LSM doesn t provide any security rather it add security fields to kernel and provide interface to manage these fields for maintaining security attributes.

Design of LSM User Level Process User space LSM is to mediate access to internal kernel objects open system call Kernel space By placing hooks in kernel code just before the access look up inode error checks LSM module provides the functions to be called by these hooks DAC checks LSM hook access inode OK? Yes or No LSM Policy Engine Examine context. Does request pass policy? Grant or Deny.

System Call Hook vs. LSM Hook

Linux Security Module Architecture LSM의 구조 Security Policy + Security Module = LSM Framework

Make a Security Module (Tutorial 3) Write a simple security module code Write a Makefile Modify the kernel Load the security module to kernel

Simple Security Module Code include/linux/security.h LSM hook Registration (1) Hooking function pointer is defined in security.h struct security_operations { char name[security_name_max + 1]; int (*socket_connect) (struct socket *sock, struct sockaddr *address, int addrlen);.. omitted.. } 1. security_operation Structure Definition sample.c static struct security_operations sample_ops = {.socket_connect = sample_socket_connect, hooking function is defined for socket_connect.inode_link = sample_inode_link,.inode_unlink = sample_inode_unlink,.inode_symlink = sample_inode_symlink,.inode_mkdir = sample_inode_mkdir, 생략.. } define a hook to security operations structure When we want to add a hook, we can refer to security_operations in include/linux/security.h sample.c 2. security_operation Structure Registration Define a security check function when the connect() is called. sample_socket_connect() { //check permission check_perm(&perm); }

Simple Security Module Code LSM hook Registration (2) 2. security_operation Structure Registration security/sample/sample.c static init int sample_init(void) { reset_security_ops(); if (register_security (&sample_ops)) { printk("sample: Unable to register with kernel.\n"); return 0; } Register register_security () function using a predefined structure to register security_operations Defined previously registered sample_ops } printk(kern_info "Sample: Initializing.\n"); return 0; security/security.c int register_security(struct security_operations *ops) {.. Omitted. security_operations is registered as a security function } if (security_ops!= &default_security_ops) return -EAGAIN; security_ops = ops; sample_ops is registered as a security function return 0;

Simple Security Module Code Connect System Call Main() { connect() connect system call } User Level net/socket.c Kernel Level SYSCALL_DEFINE3(connect, int, fd, struct sockaddr user *, uservaddr, int, addrlen) connection system call function in Kernel { sockfd_lookup_light (); move_addr_to_kernel(); security_socket_connect(); security check function } sock->ops->connect(); Connection() function security/sample/sample.c security/security.c int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen) { return security_ops->socket_connect(sock, address, addrlen); } sample_socket_connect() { //set parameters perm_info.connect_info.sock = sock; perm_info.connect_info.address = address; perm_info.connect_info.addrlen = addrlen; } //check permission check_perm(&perm);

Write a Makefile Makefile Explanation obj-m := name of object file KDIR := kernel source directory(symbolic) PWD := module source directory -C : change the directory to next parameter M= module location (SUBDIRS is same meaning with M)

Have you got this error message? Try to load the sample security module $ tail f /var/log/syslog Check the kernel symbol table

Why??? Befor Linux v.2.6.24 After Linux v.2.6.24 : Built-In Security Modules ex) SELinux, Apparmor, TOMOYO, LSM LSM : Other Modules (User Defined) LSM LSM

We Need to Modify the Kernel Basis on Linux Kernel v3.2.0 /include/linux/security.h Line Remove init from void init security_fixup_ops(struct security_operations *ops) 1663 /security/security.c Remove init from static inline int init verify(struct security_operations *ops) 34 int init register_security(struct security_operations *ops) 113 Add EXPORT_SYMBOL() at bottom line EXPORT_SYMBOL(register_security); EXPORT_SYMBOL(reset_security_ops); /security/capability.c Remove init from void init security_fixup_ops(struct security_operations *ops) 875

Kernel Compile and Rebooting Follow the below commands to re-compile the kernel (1) make mrproper (2) make menuconfig (3) make clean (4) make bzimage (5) make install Reboot

Load the Security Module to Kernel Load the Security Module $ tail f /var/log/syslog Check the kernel symbol table