Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
Security Linux

Bug In Most Linuxes Can Give Untrusted Users Root 281

Posted by kdawson
from the patchin'-place dept.
Red Midnight and other readers brought to our attention a bug in most deployed versions of Linux that could result in untrusted users getting root access. The bug was found by Brad Spengler last month. "The null pointer dereference flaw was only fixed in the upcoming 2.6.32 release candidate of the Linux kernel, making virtually all production versions in use at the moment vulnerable. While attacks can be prevented by implementing a common feature known as mmap_min_addr, the RHEL distribution... doesn't properly implement that protection... The... bug is mitigated by default on most Linux distributions, thanks to their correct implementation of the mmap_min_addr feature. ... [Spengler] said many other Linux users are also vulnerable because they run older versions or are forced to turn off [mmap_min_addr] to run certain types of applications." The register reprints a dialog from the OpenBSD-misc mailing list in which Theo De Raadt says, "For the record, this particular problem was resolved in OpenBSD a while back, in 2008. We are not super proud of the solution, but it is what seems best faced with a stupid Intel architectural choice. However, it seems that everyone else is slowly coming around to the same solution."
This discussion has been archived. No new comments can be posted.

Bug In Most Linuxes Can Give Untrusted Users Root

Comments Filter:
  • Patch (Score:5, Informative)

    by tomtomtom (580791) on Wednesday November 04, 2009 @09:02AM (#29977430)
    For those who just want to know how to fix it, you need to apply this git commit [kernel.org] to your kernel tree and then either recompile and reboot or apply the patch using ksplice.
  • by MrMr (219533) on Wednesday November 04, 2009 @09:02AM (#29977432)
    If the result is non-zero the vulnerability doesn't exist.
    'Most deployed versions of linux'?.
    So far only some unpatched RHEL versions allow this local exploit, even the Centos rip-off doesn't have it.
  • by Xonea (637183) on Wednesday November 04, 2009 @09:03AM (#29977444)
    Nope, it is a new one, but the same old bugfix still works.

    Just type sysctl -w vm.mmap_min_addr=4096 in your box (or any other number > 0) and you are safe.
  • by Xonea (637183) on Wednesday November 04, 2009 @09:04AM (#29977462)
    It says that it was only fixed " in the upcoming 2.6.32 release candidate of the Linux kernel" - hence everything before that is vulnerable.

    But the bug is not exploitable on ubuntu, because they set vm.mmap_min_addr > 0 by default.
  • by Dareth (47614) on Wednesday November 04, 2009 @09:05AM (#29977474)

    The null pointer dereference flaw was only fixed in the upcoming 2.6.32 release candidate of the Linux kernel, making virtually all production versions in use at the moment vulnerable.

    You know you can click on the article links and actually read them.

  • Re:Patch (Score:5, Informative)

    by Xonea (637183) on Wednesday November 04, 2009 @09:15AM (#29977594)
    Or, if you want to wait for your vendor patch, set vm.mmap_min_addr manually, if it hasn't been set by your vendor already - the only distribution I have where this is necessary is debian.

    You can either do
    # sysctl -w vm.mmap_min_addr = 65536
    and redo that every reboot or do

    # echo "vm.mmap_min_addr = 65536" > /etc/sysctl.d/mmap_min_addr.conf
    # /etc/init.d/procps restart
    and be done with it.
  • by LizardKing (5245) on Wednesday November 04, 2009 @09:19AM (#29977630)
    Before people jump on Theo's comment, it's worth pointing out that it was Linus who first described the OpenBSD developers as "masturbating monkeys". That said, it's still bloody childish irrespective of who it's coming from.
  • by gzipped_tar (1151931) on Wednesday November 04, 2009 @09:29AM (#29977782) Journal

    This is from Fedora running kernel 2.6.30 with minimal customization (almost default, and no tweaking related to this one):

    $ cat /proc/sys/vm/mmap_min_addr
    65536

    The devs seem to be doing an adequate job to mitigate this problem.

  • by tayhimself (791184) on Wednesday November 04, 2009 @09:35AM (#29977850)
    This solution works, please see the links below. However I would reccomend seing what your settings are on your system
    $ sysctl -n vm.mmap_min_addr to find what your setting is.
    On Ubuntu 8.04 LTS servers (including Xen kernels) and on 9.10 desktops it is 65536. Not a big deal.
    http://wiki.debian.org/mmap_min_addr [debian.org]
    https://lists.ubuntu.com/archives/ubuntu-devel/2008-July/025805.html [ubuntu.com]
    http://www.securityfocus.com/bid/26831/info [securityfocus.com]
  • by daveewart (66895) on Wednesday November 04, 2009 @09:35AM (#29977852)

    But the bug is not exploitable on ubuntu, because they set vm.mmap_min_addr > 0 by default.

    That doesn't seem to be generally true.

    Ubuntu Hardy 8.04 LTS, 2.6.24-25-generic: vm.mmap_min_addr = 65536; Ubuntu Jaunty 9.04, 2.6.28-16-generic: vm.mmap_min_addr = 0. So, by the above logic, Ubuntu Jaunty is vulnerable, although Hardy is safe.

    Also seems like vm.mmap_min_addr = 0 for all the Debian boxes I can get my hands on...

    (All my comments above relate to the stock/packaged kernels for the distribution)

  • by robmv (855035) on Wednesday November 04, 2009 @09:40AM (#29977946)

    That is being solved with Filesystem capabilities [lwn.net]. Fedora 11 still has ping as setuid, not sure if Fedora 12 beta already switched it

  • by eparis (1289526) on Wednesday November 04, 2009 @09:48AM (#29978066)
    No, this isn't the same bug. People confuse two issues. I wrote the mmap_min_addr protections to try to mitigate the effects of a certain class of common kernel bugs which exist because of design choices by Intel. That class of bugs can be summed up as NULL pointer usage. Every time someone finds a new NULL pointer usage bug we get the same story. RHEL (and any system with SELinux enabled) did not have protections for mapping the 0 page by local authenticated users, but did have protections for network facing daemons and the like. Other distros had protections for the local authenticated user but weaker protections for network facing daemons. The mmap_min_addr protections have since been enhanced in SELinux systems such that they have stronger protections, both for local authenticated users and for network facing daemons. My old comments from the first time this came up are at http://eparis.livejournal.com/ [livejournal.com]

    But the key to remember is that mmap_min_addr implementation is not the bug that allows elevation of privilege. In this case it was a very very old bug in the implementation of pipes. Previously Spender and friends have found bugs in performance counters (one which was actually much worse as it didn't fit into the very narrow class which might be mitigated by mmap_min_addr), in network sockets, and other places. These are the bugs which cause this to be a new story. Once he finds the real bugs he applies some of the same basic techniques (plus a whole lot of thought) to create an exploit. If the Linux kernel was bug free we wouldn't need mmap_min_addr. If mmap_min_addr was bug free (over the years Spender has found multiple problems with my work) this class of bugs would be just a bit less devastating.

    Everyone in the kernel development community needs to think of invalid pointer bugs as a larger security threat then they currently do. The lesson here, keep your systems patched.
  • by sqlrob (173498) on Wednesday November 04, 2009 @09:49AM (#29978068)

    Not necessarily. You can create raw sockets with some limitations without root access on OS X. There's enough control to implement ping, but not enough to forge.

  • by 0123456 (636235) on Wednesday November 04, 2009 @09:49AM (#29978074)

    That's weird, because 9.04 gives: vm.mmap_min_addr = 65536 and so did the 9.10 desktop version a few posts up.

    You probably don't have Wine installed. AFAIR Wine needs it set to zero to run some old 16-bit applications, so installing Wine installs a config file which sets it to zero.

  • by JasterBobaMereel (1102861) on Wednesday November 04, 2009 @09:50AM (#29978096)

    So it's really a bad design on Intel chips, that all operating system have to work around, except Windows which requires it to work like this... ...and on most Linux and BSD systems it will not work even if unpatched ... and it has already been patched ... and you need to be able to get a user on the local machine to run an app to exploit it (most users install from the Package Manager and so will never run a random downloaded app), and this does not appear to be a remote exploit?

  • by eparis (1289526) on Wednesday November 04, 2009 @09:50AM (#29978100)
    Installing the wine package on ubuntu automatically sets mmap_min_addr to 0. The default install will have it set higher. Solution, remove wine.
  • by Shikaku (1129753) on Wednesday November 04, 2009 @09:50AM (#29978102)

    I have VirtualBox and Wine, and VirtualBox uses a kernel module. So it's possible that one of those could have set it to 0. I set it to 65000 just in case and it didn't break Wine or VirtualBox...

  • by 0123456 (636235) on Wednesday November 04, 2009 @09:55AM (#29978168)

    Ubuntu sets this to zero if you have wine installed.

  • by eparis (1289526) on Wednesday November 04, 2009 @10:14AM (#29978468)
    A patched kernel will fix this particular bug, but as long as wine is installed and mmap_min_addr is being set to 0 you have no protections for the next bug. Unless wine can be changed (which some smart people have told me it can't), there's nothing you can do except accept a higher security risk on your system.

    Here's a fun tag line, "Windows applications can even make Linux less secure!"
  • by True Grit (739797) * <edwcogburnNO@SPAMgmail.com> on Wednesday November 04, 2009 @10:47AM (#29979090)

    What's the beef between Linus and Theo?

    Theo is in charge of a BSD-based kernel that is only concerned with security, while Linus is in charge of a kernel that has to accommodate a much wider audience (like people who want to run Wine), and, of course, since both of them also have largish egos, they've both managed to say some silly things about each other's kernel...

    Basically, unless you're already a Linus or Theo fanboy, their 'bickering' is not that important. :)

  • by eparis (1289526) on Wednesday November 04, 2009 @11:24AM (#29979820)
    My understand in a short and simple answer: before the x86_64 architecture revolution it was possible to effectively have a separate virtual memory space for the kernel and userspace. With x86_64 segmentation was removed.

    Intel i686 processors had a pretty big performance hit if you used functionality since there was a TLB flush on every kernel trap. I don't believe many kernels made use of it. The PaX security patch set could and Red Hat's 4g/4g split kernels did (RH called them hugemem kernels, although I don't suggest them to anyone as they had their own issues.) The AMD Opteron processors actually had tagged TLBs so they didn't have to flush and performance didn't suffer nearly as badly.

    In any case, with x86_64 that ability is simply gone. SPARC is often named as an architecture which doesn't suffer from this specific class of bugs since it always had completely separate kernel space and userspace virtual memory. I heard rumour their might be a brilliant solution that will hopefully come from the PaX/grsecurity team, but I don't believe anything has materialized just yet.
  • by PitaBred (632671) <slashdot@@@pitabred...dyndns...org> on Wednesday November 04, 2009 @11:41AM (#29980162) Homepage
    Not on 8.04 (the last LTS release). Any ideas why it would do that?
  • by Tetsujin (103070) on Wednesday November 04, 2009 @12:06PM (#29980658) Homepage Journal

    Linus's comment:
    "That does not look like a kernel problem to me at all. He's running a setuid program that allows the user to specify its own modules. And then you people are surprised he gets local root?"

    Sounds reasonable to me.

    Well, here's the thing... For the exploit to work you need either mmap_min_addr to be 0, or you need your process to have CAP_SYS_RAWIO. In other words, if you were running on a system that had mmap_min_addr set to 0, you could run this exploit without already having root authority. Wine needs this, apparently...

    The workaround for mmap_min_addr (by exploiting dangerous SUID code in Pulse) was just icing on the cake.

  • Re:And? (Score:4, Informative)

    by kscguru (551278) on Wednesday November 04, 2009 @12:52PM (#29981552)
    http://en.wikipedia.org/wiki/Security_theater [wikipedia.org]

    Torvalds is absolutely correct, the whole issue is idiotic and isn't really an "exploit" because it doesn't result in ANY privilege escalation. (You must be root to run an exploit that gives you, um, root!) However, ego-starved security people get to jump up and down thumping their chests about how they h@x0r3d an extremely common Linux distribution and get their names splashed all over the press. Yeah, and instead of mmapping NULL, you can just 'insmod /my/evil.ko' and get the same effect. Sigh.

    Those of us who know anything about security just ignore these "researchers". There are far more important bugs - even far more important security bugs - than a root-to-root non-issue. I'll happily patch my system with the next set of kernel updates, but I don't intend to grab it any sooner. It's more important to me that my system stay up and avoid regressions than fix a root-can-get-root non-exploit.

  • by Senjutsu (614542) on Wednesday November 04, 2009 @12:54PM (#29981598)
    Because Wine needs access to the bottom 64k of memory in order to run 16-bit DOS programs
  • by jonbryce (703250) on Wednesday November 04, 2009 @12:56PM (#29981628) Homepage

    I have two machines with Open SuSE 11.1 One returns 0, and the other 65535. The one returning zero runs only samba and apache (+webdav module for an ical server). The one returning 65535 runs samba and xen.

  • by eparis (1289526) on Wednesday November 04, 2009 @02:25PM (#29983578)
    Most people expect that dereferencing a NULL pointer will result in some sort of fault. If you map the virtual page 0 and then do this you don't get a fault. Remember that NULL==0.
    mmap(0, ..., MAP_FIXED...
    char *p = NULL;
    *p = 'a';

    address 0 now contains the letter 'a' and the program does not fault.

    The idea is that if you do the mmap in userspace, fill that area with specially crafted information, then cause the kernel to hit a bug in the software (in this case a pipe) which dereferences a NULL pointer, you can make it operate on data you control. This is due to the fact that userspace and kernel operate in the same virtual address space. Sometimes (often?) this means you can take over the box.

    mmap_min_addr tries to address this problem by disallowing a program from mapping the low virtual address space. That means it ONLY affects the class of bugs that involve a NULL pointer. If it's a corrupt pointer instead a NULL pointer mmap_min_addr is totally useless. For either class of bugs hardware segmentation could help. It wouldn't be a security panacea, but it would eliminate the need for the specific hacks which both Linux and BSD use.
  • by dstech (807139) <darksidex3@gmail.com> on Wednesday November 04, 2009 @02:38PM (#29983848)

    Of course, if you run a maintained version of any Enterprise Linux I'd put good bets down that they'll be patched shortly. If you spun your own distro, then you made the choice to maintain it yourself anyway.

    The RHEL patch was released yesterday: https://rhn.redhat.com/errata/RHSA-2009-1548.html [redhat.com]

  • by 200_success (623160) on Wednesday November 04, 2009 @03:12PM (#29984504)

    The problem we are discussing today is CVE-2009-3547. The root cause of the vulnerability is a null pointer dereference in pipe.c. The proper fix is to patch the kernel. It just so happens that if vm.mmap_min_addr != 0 then the bug cannot be exploited to gain root access. Therefore, mmap_min_addr can be used as a stopgap measure until you are able to patch the kernel. It also happens to be a good idea to leave mmap_min_addr set to a non-zero value to guard against other null-pointer dereference bugs that may be discovered in the future.

  • by hughperkins (705005) on Wednesday November 04, 2009 @10:12PM (#29990254) Homepage
    It's only needed for 16-bit programs in Wine. You can modify the value by editing /etc/sysctl.d/wine.sysctl.conf, changing the vm.mmap_min_addr from 0 to 65536, then running /etc/init.d/procps restart. Note : your mileage may vary. Use at your own risk. Etc...

It's not so hard to lift yourself by your bootstraps once you're off the ground. -- Daniel B. Luten

Working...