Smack Labeled
Total Page:16
File Type:pdf, Size:1020Kb
SP Project 2 Basic SMACK features 1 Tizen project flow Tizen dev. environment Project 0 build Tizen Porting to Odroid-U3 Tizen application Project 2 development Basic SMACK Project 1 features Tizen web application Tizen development security Project 3 : SMACK SMACK security rule modify Tizen platform Project 4 development New SMACK rules Linux kernel development 2 Tizen Security Model . Non-root applications • All applications run under same non-root user ID . Application sandboxing • All applications are sandboxed by Smack . Resource access control • Important system objects are Smack labeled . Least privilege • All applications will have manifest file describing permissions 3 Tizen Security Model . Mandatory access control powered by Smack • Each application is Smack labeled and has proper Smack rules − Assigned and maintained by manifest file from each package • Application based sandboxing − Each application is able to write to home directory only . SMACK (Simple Mandatory Access Control Kernel) • Upstream Linux Security Module • Simple {subject, object, permission} access control model 4 SMACK . Units SMACK • Subject, Object, Access permission • Subject: processes • Object: processes, files . Rules SMACK • SMACK rule files in /opt/etc/smack/ • Rule format (subject) (object) (access permission) When (subject) accesses (object), access between them follows (access permission) E.g.: When (process) accesses (file), read only is permitted reference site #1 reference site #2 5 SMACK Application Web Application Native Application Web Framework Native Framework W3C/HTML5 Device APIs Social/Content Locations Uix Media Web/Xml Video Touch BT Call CSS3 WebGL LBS NFC Net/Telephony/Messaging Graphics/UI … … Worker Msg Web Runtime Base/IO/Text/Locales App/Security/System Services Core Framework Core Application Application Graphics & UI Multimedia Web Messaging Location Framework Security System Base Connectivity Telephony PIM Kernel SMACK is here Linux Kernel & device drivers 6 SMACK’s normal behavior Basic behavior (app_label) (file_label) (access_permission) org.tizen.image-viewer * arwxt the application has all the access permission to Exception the file in SDcard Change the label of the file into a strange label Exception handling behavior smack detect (app_label) (file_label) (access_permission) org.tizen.image-viewer virus ----- application lose all access permission to the strange labeled file 7 Process SMACK Labels . Reference • Kernel document − linux3.10/Documentation/security/Smack.txt . id command with option “-Z” • Will show your process Smack label . ps command with option “-Z” • Will show SMACK labels of processes 8 Changing Your (user) SMACK Label . All processes run with a Smack label . A privileged process can change its Smack label • By writing the new label into a special file in the proc filesystem • E.g.) echo [new label] > /proc/self/attr/current 9 Changing SMACK Label of a Process . chsmack • Display Smack extended attribute values − ex) # chsmack [program_path] tizen application path • Set Smack extended attribute values − ex) # chsmack –e [Smack label] [program_path] 10 Changing SMACK Labels of Files . chsmack • Display Smack extended attribute values − ex) # chsmack [file_path] • Set Smack extended attribute values − ex) # chsmack –a [Smack label] [file_path] 11 Checking Smack Labels on Files Smack is not working properly (We might not see “sp_smack”) We need to troubleshoot! (kernel patch) 12 Kernel patch Linux kernel Linux kernel ( original ) Patch ( patched ) Patch file kernel.org 13 Kernel patch . How to generate patch file 1 2 3 1. Copy program program.orig 2. Modify 3. Diff program Patch file 14 Kernel patch . Patch file Source , Destination (-) : to be removed (+): to be added 15 Kernel patch . Patch file Source , Destination (-) : to be removed (+): to be added 16 Kernel patch . Patch file Source , Destination (-) : to be removed (+): to be added 17 Kernel patch . How to apply a patch program.orig Patch Patch file program.orig 18 SMACK source patch in kernel . Not working in Tizen 2.2 • Caused by different version between platform and kernel tizen 2.2(reference) tizen 3.0(reference) tizen 2.2(ported) platform platform platform tizen 2.2 SMACK src tizen 3.0 SMACK src tizen 2.2 SMACK src kernel 3.0v kernel 3.10v kernel 3.10v tizentizen2.22.2 SMACKsmack srcsrc tizen 3.0 SMACK src tizen 3.0 SMACK src ref hardware src ref hardware src U3 hardware src 19 SMACK source patch in kernel . Solution • Change kernel SMACK source version 3.0 to 2.2 (Project 02) tizen 2.2(reference) tizen 3.0(reference) tizen 2.2(ported) platform platform platform tizen 2.2 SMACK src tizen 3.0 SMACK src tizen 2.2 SMACK src kernel 3.0v kernel 3.10v kernel 3.10v tizentizen2.22.2 SMACKsmack srcsrc tizen 3.0 SMACK src tizen 2.2 SMACK src ref hardware src ref hardware src U3 hardware src 20 SMACK source patch in kernel . SMACK source path • linux3.10/security/smack/ . Change kernel SMACK source version 3.0 to 2.2 • Compile error occurs after copy • Solutions − include additional header file − modify and add operation struct entry − modify functions 21 SMACK source patch in kernel . Include additional header file − linux/msg.h − linux/shm.h − linux/binfmts.h . Modify smack_ops operation struct entry .file_mmap = smack_file_mmap, => .mmap_file = smack_mmap_file, .dentry_open = smack_dentry_open => .file_open = smack_file_open, . Add smack_ops operation struct entry .mmap_addr = cap_mmap_addr, . Modify function • see patch file(download) 22 SMACK feature verification 23 SMACK feature verification 24 SMACK feature verification 25 SMACK feature verification 26 SMACK feature verification 27 SMACK feature verification 28 SMACK feature verification 29 SMACK feature verification 30 SMACK feature verification 31 SMACK feature verification 32 SMACK feature verification 33 Tip . Tizen Screen Capture $ sdb shell $ xwd -root -out /tmp/screen.xwd $ exit $ sdb pull /tmp/screen.xwd $ convert screen.xwd 0.png . Using source analysis tool • vim plugin • ctag • cscope 34 Tip . Tizen application execute • /usr/apps/org.tizen.[appname]/bin/executable_file − E.g.) /usr/apps/org.tizen.gallery/bin/gallery . Tizen application termination • ps –ef • kill -9 [application pid] 35 References . Tizen Wiki, Security: Smack • https://wiki.tizen.org/wiki/Security:Smack . Kernel Documentation • https://www.kernel.org/doc/Documentation/security/Smack.txt 36.