290 likes | 427 Views
Secretly Monopolizing the CPU Without Superuser Privileges. In a nutshell. We implement a “cheat” utility: shell~/> cheat 90% program. Unlike a rootkit. e.g. “cosmic rays attack” on JVMs [S&P 2003]. obtain root & install rootkit: secretly ctrl all resources. cheat
E N D
In a nutshell • We implement a “cheat” utility: shell~/>cheat 90% program
e.g. “cosmic rays attack” on JVMs [S&P 2003] obtain root & install rootkit: secretly ctrl all resources cheat secretly ctrl one resource(can envision rootless rootkit) The privileges-conflict axis Attackers/defenders conflict often revolves around 1) Privileges of using resources, and 2) How long these privileges last privileges-conflict axis general limited
Operating System “ticks” • Ticks = periodic hardware interrupts • OSs wake up HZ times a second: • Since the 1960s (60Hz, like the grid)[Dijkstra; the “THE” system; CACM’68]
The tick-handler • Tick-handler’s activities: 1) Deliver due alarm signals 2) CPU accounting 3) Initiating preemption (for multitasking) 4) ... • Kernel’s “main loop”; its way to maintain control
Concealment: how? Run when OS not looking…(Not as easy as it sounds) cheater runs cheater runs cheater runs time tick n+2 tick n tick n+1 tick n+3
Misaccounting: if we pull it off The ‘honest’ process appears consuming 100% honest honest honest honest cheater runs cheater runs cheater runs time tick n+2 tick n tick n+1 tick n+3
Monopolizing: how? • The negative-feedback scheduling-principle - Running reduces priority to run more • This principle guarantees 1) Fair allocation of CPU 2) Chronic sleepers (like emacs) get high priority • Latter largely what makes editors responsive - And indeed, our cheater looks like an editor!
“Interactivity” makes it worse • Turns out monopolizing is possible even without concealment capabilities… • Scheduling for ‘interactivity’ raises ugly head:
The cheat algorithm void cheat_attack( double fraction) { work = fraction * cycles_per_tick(); nanosleep(0); // sync with tick tick_start = get_cycles(); while( 1 ) { now = get_cycles(); if( now - tick_start ≥ work ) { nanosleep(0); // avoid bill tick_start = get_cycles();} // do some short work here… } }
billed CPU [ms] used CPU [ms] cheater honest other Evaluation 80%-cheater vs. honest-process tick time [ms] tick time [%] time [sec]
time [sec] used CPU [ms] honest tick time [ms] cheater billed CPU [ms] after time [sec] used CPU [ms] Cycle-accurate billing honest before tick time [ms] billed CPU [ms] cheater
cheater ( 50.02% ) honest ( 49.97% ) other ( 0.01% ) Curbing interactives preference all the data zoom in tick time [ms] billed CPU [ms] time [ms] used CPU [ms]
Conclusions • Cheating allows unprivileged users to - seize CPU, often secretly • To protect against cheating, one must 1) maintain accurate-enough info 2) incorporate info in scheduler (unlike Solaris, XP) 3) do it carefully (unlike Linux2.6, FreeBSD/ULE, XP) • OS trend: prioritize based on sleep-frequency - plays straight to the hands of cheaters - probably fruitless - alternative: explicitly track relevant devices [NOSSDAV’04, TOMCCAP'06]
“Cheat” attack - Impact • Linux scheduler: Ingo Molnar, maintainer of the Linux Scheduler: [ From the CFS-scheduler announcementpeople.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt]“Due to its design, the CFS scheduler is not prone to any of the 'attacks' that exist today against the heuristics of the stock scheduler”
“Cheat” attack - Impact • Amazon’s “Elastic Compute Cloud” (EC2) • F. Zhou, M. Goel, P. Desnoyers, & R. Sundaram,“Scheduler vulnerabilities & coordinated attacks in cloud computing”, Northeastern U., Boston Technical Report, 2010 • Subverting Xen hypervisor with the cheat attack • “Following the responsible disclosure model, we have reported this vulnerability to Amazon; they have since implemented a fix that we have tested and verified”
Cheat accuracy achieved cheat rate [%] desired cheat rate [%]
all the others all the others one competitor on 80% cheater Effect of background load all are honest one is 80%-cheater CPU [%] number of competing processes
Running unmodified programs Two approaches: 1) Cheat server 2) Binary instrumentation
Stealing a cluster with a P-III sum of honest (10 per node) CPU [%] sum of 60%-cheaters (one per node) cluster size [nodes; log scale]
Binary instrumentation slowdown block trace function instruction selected function instrumentation granularity
Protecting against cheating: degrees of accuracy • Two approaches 1) Solaris & Windows way - Account for every kernel entry/exit (which e.g. slows down syscalls path) 2) BSD & Linux way - Accounting by tick-handler only (inaccurate) • Compromise - Accounting only upon a context-switch - Price: context-switch slower by 5%