{"id":230,"date":"2009-07-31T11:47:38","date_gmt":"2009-07-31T19:47:38","guid":{"rendered":"http:\/\/www.outflux.net\/blog\/?p=230"},"modified":"2009-07-31T11:58:13","modified_gmt":"2009-07-31T19:58:13","slug":"blocking-module-loading","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2009\/07\/31\/blocking-module-loading\/","title":{"rendered":"blocking module loading"},"content":{"rendered":"<p>New for Linux 2.6.31 (and Ubuntu 9.10) is the ability to <a href=\"http:\/\/git.kernel.org\/?p=linux\/kernel\/git\/torvalds\/linux-2.6.git;a=commitdiff;h=3d43321b7015387cfebbe26436d0e9d299162ea1\">throw a one-way toggle<\/a> to block module loading via <code>\/proc\/sys\/kernel\/modules_disabled<\/code>:<\/p>\n<p><code># <strong>uname -a<\/strong><br \/>\nLinux sec-karmic-amd64 2.6.31-4-generic #23-Ubuntu SMP Mon Jul 27 18:39:59 UTC 2009 x86_64 GNU\/Linux<br \/>\n# <strong>lsmod | head -n3<\/strong><br \/>\nModule                  Size  Used by<br \/>\nbinfmt_misc            10220  1<br \/>\nppdev                   8200  0<br \/>\n# <strong>cat \/proc\/sys\/kernel\/modules_disabled<\/strong><br \/>\n0<br \/>\n# <strong>modprobe usb-storage<\/strong><br \/>\n# <strong>lsmod | head -n3<\/strong><br \/>\nModule                  Size  Used by<br \/>\nusb_storage            65600  0<br \/>\nbinfmt_misc            10220  1<br \/>\n# <strong>echo 1 &gt; \/proc\/sys\/kernel\/modules_disabled<\/strong><br \/>\n# <strong>rmmod usb-storage<\/strong><br \/>\nERROR: Removing 'usb_storage': Operation not permitted<br \/>\n# <strong>modprobe zlib_deflate<\/strong><br \/>\nFATAL: Error inserting zlib_deflate (\/lib\/modules\/2.6.31-4-generic\/kernel\/lib\/zlib_deflate\/zlib_deflate.ko): Operation not permitted<br \/>\n# <strong>echo 0 &gt; \/proc\/sys\/kernel\/modules_disabled<\/strong><br \/>\nbash: echo: write error: Invalid argument<br \/>\n# <strong>cat \/proc\/sys\/kernel\/modules_disabled<\/strong><br \/>\n1<br \/>\n<\/code><\/p>\n<p>The intent is for this to allow paranoid server admins (or other people not expecting to hot-plug new hardware or kernel services) the ability to block module loading without compiling a monolithic kernel.<\/p>\n<p>This kind of thing <a href=\"http:\/\/www.debian.org\/doc\/manuals\/securing-debian-howto\/ch10.en.html#s-proactive\">used to be available<\/a> through the &#8220;lcap&#8221; utility modifying the global capability bounding set (which was removed in 2.6.25), but init could always be made to turn it back on.<\/p>\n<p>Combined with the <a href=\"https:\/\/wiki.ubuntu.com\/Security\/Features#\/dev\/kmem%20disabled\">removal of \/dev\/kmem<\/a> and the <a href=\"https:\/\/wiki.ubuntu.com\/Security\/Features#\/dev\/mem%20protection\">hardening of \/dev\/mem<\/a>, this closes another kernel rootkit door.  It&#8217;s not a cure-all, but it&#8217;s another layer.<\/p>\n<p>Now we just have to figure out ways to stamp out unexpected ioport-triggered DMA access.<\/p>\n<p style='text-align:left'>&copy; 2009, <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>New for Linux 2.6.31 (and Ubuntu 9.10) is the ability to throw a one-way toggle to block module loading via \/proc\/sys\/kernel\/modules_disabled: # uname -a Linux sec-karmic-amd64 2.6.31-4-generic #23-Ubuntu SMP Mon Jul 27 18:39:59 UTC 2009 x86_64 GNU\/Linux # lsmod | head -n3 Module Size Used by binfmt_misc 10220 1 ppdev 8200 0 # cat \/proc\/sys\/kernel\/modules_disabled [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,18,6,14,19],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/230"}],"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=230"}],"version-history":[{"count":7,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions"}],"predecessor-version":[{"id":236,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions\/236"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}