{"id":316,"date":"2010-02-25T11:04:53","date_gmt":"2010-02-25T19:04:53","guid":{"rendered":"http:\/\/www.outflux.net\/blog\/?p=316"},"modified":"2010-02-25T11:04:53","modified_gmt":"2010-02-25T19:04:53","slug":"fun-with-process-scheduling","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2010\/02\/25\/fun-with-process-scheduling\/","title":{"rendered":"fun with process scheduling"},"content":{"rendered":"<p>In an attempt to force an exec to totally stall so I could attach gdb to a process that does a setuid transition without freaking it out (i.e. can&#8217;t launch &#8220;sudo gdb &#8230;&#8221;), I briefly played with process priority, scheduling, and CPU affinity (pinning a process to a CPU).<\/p>\n<p>So far, the best attempt at stalling the process was to set CPU affinity, set its scheduling policy (IDLE), drop the priority value fully (19), and then run a CPU hog with the same CPU affinity with a very high priority (-20).<\/p>\n<p>Staller: <code>sudo schedtool -a 0 -N -n -20 -e \/tmp\/spin-cpu<\/code><br \/>\nStallee: <code>schedtool -a 0 -D -n 19 -e \/usr\/bin\/sudo -s<\/code><\/p>\n<p>The hope was to then run &#8220;<code>sudo gdb \/usr\/bin\/sudo $(pidof sudo)<\/code>&#8220;, but it seems that this still isn&#8217;t enough to make the exec of sudo totally stall while the &#8220;spin-cpu&#8221; process is running &#8212; it certainly executes more slowly, but I want it to <em>stop<\/em>.<\/p>\n<p>I have this feeling like I&#8217;m missing something obvious about how to accomplish this gdb session sanely.  I wonder if I can get gdb to switch targets across a child exec, i.e. run gdb as root on a program that fully drops privs, but then execs sudo.  Guess it&#8217;s time to go read the gdb manual some more&#8230;<\/p>\n<p style='text-align:left'>&copy; 2010, <a href=\"https:\/\/outflux.net\/blog\/\">Kees Cook<\/a>. This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">Creative Commons Attribution-ShareAlike 4.0 License<\/a>.<br \/><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><img decoding=\"async\" alt=\"CC BY-SA 4.0\" style=\"border-width:0\" src=\"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In an attempt to force an exec to totally stall so I could attach gdb to a process that does a setuid transition without freaking it out (i.e. can&#8217;t launch &#8220;sudo gdb &#8230;&#8221;), I briefly played with process priority, scheduling, and CPU affinity (pinning a process to a CPU). So far, the best attempt at [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,14,19],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/316"}],"collection":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/comments?post=316"}],"version-history":[{"count":2,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/316\/revisions"}],"predecessor-version":[{"id":318,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/316\/revisions\/318"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}