say, private file on portal
for example:
(more detail in later lecture)
way for programs to make request to OS:
program sets registers to indicate requested operation
program runs special instruction (x86-64: syscall)
hardware switches into privileged mode + runs OS function
OS function decodes requested operation from registers
OS function decides if operation is allowed to proceed
argument: needs extra metadata
what would be wrong with using:
most common way OSes identify ‘‘who’’ process belongs to:
(unspecified for now) procedure sets user IDs
every process has a user ID
user ID used to decide what process is authorized to do
process’s user identified with unique number
core part of OS only knows number (not name!)
effective user ID is used for all permission checks
standard programs/library maintain number to name mapping
/etc/passwd on typical single-user systemsPOSIX also has group IDs
like user IDs: kernel (= core part of OS) only knows numbers
also process has some other group IDs — we’ll talk later
: /u/bjc8c ; id
uid=858545(bjc8c) gid=90002(csfaculty)
groups=90002(csfaculty),150015(slurm-cs-brad-campbell)
id command displays uid, gid, group list
names looked up in database
example: video group for access to monitor
put process in video group when logged in directly
don’t do it when SSH’d in
who is running a process or accessing a resource
but also need permissions
POSIX files support a per-file access control list
one user ID + read/write/execute bits for user
one group ID + read/write/execute bits for group
default setting — read/write/execute
on directories, “execute” means “search” instead
permissions encoded as 9-bit number, can write as octal: XYZ
octal divides into three 3-bit parts:
each 3-bit part has a bit for ‘read’ (4), ‘write’ (2), ‘execute’ (1)
0bRWE700 — user read+write+execute; group none; other none451?451 — user read; group read+execute; other executechmod 700 file
chmod u=rwx,go= file
user read write execute; group/others no accesss
chmod 451 file
chmod u=r,g=rx,o=x file
user read; group read/execute; others execute
chmod u+rx foo
add user read and execute permissions chmod o-rwx,u=rx foo
remove other read/write/execute permissions
set user permissions to read/execute
leave group settings unchanged
more flexible access control lists
list of (user or group, read or write or execute or …)
supported by NTFS (Windows)
a version standardized by POSIX, but usually not supported
# group students have read+execute permissions
group:students:r-x
# group faculty has read/write/execute permissions
group:faculty:rwx
# user mst3k has read/write/execute permissions
user:mst3k:rwx
# user tj1a has no permissions
user:tj1a:---
# POSIX acl rule:
# user take precedence over group entries
getfacl file
setfacl -m 'user:tj1a:---' file
setfacl -x 'user:tj1a' file
setfacl -M acl.txt file
setfacl -X acl.txt file
identity: who is running a process or accessing a resource
permissions: who has what access to a file or resource
now need enforcement
request made to core part of OS = system call
handler for system calls checks permissions
file operations (eg: open, rename, …)
process operations (eg: kill, …)
…
user ID 0 is special
superuser or root
some OS functionality: only works for uid 0
automatically passes all (or almost all) permission checks
processor has two modes
programs running as superuser still in user mode
superuser : OS :: kernel mode : hardware
certain hardware instructions/operations only enabled in kernel mode
somemachine login: jo
password: ********
jo@somemachine$ ls
...
this is a program which…
typical single-user system: /etc/shadow
department machines: network service
/bin/login entirely user-space code
only thing special about it: when it’s run
could use any criteria to decide, not just passwords
tj1a@somemachine$ sudo restart
Password: *********
sudo: run command with superuser permissions
issue: what makes the sudo command privileged?
setuid(0)extra metadata bit on
if set: exec() syscall changes effective user ID to owner’s ID
sudo program: owned by root, marked set-user-ID
marking setuid: chmod u+s
mount USB stick
control access to device — printer, monitor, etc.
write to secure log file
bind to a particular port number <1024
argc == 0?code execution/corruption in utilities that run with high privilege
e.g. buffer overflow, command injection
login, sudo, system services, …
bugs in system call implementations
logic errors in checking delegated operations