back to article How Google's Project Zero made Apple refactor its kernel

When Apple shipped its security bug-fixes earlier this week, one patch mostly passed under the radar. Ian Beer of Google Project Zero, who found a deep-down vulnerability in the XNU kernel, first reported it to Apple in February this year, and it took until now to clean it up properly. It took eight months, apparently, …

  1. Anonymous Coward
    WTF?

    As a non-programmer can I just quote Snatch?

    Turkish: Yeah, that's perfectly clear, Mickey. Yeah... just give me one minute to confer with my colleague.

    Turkish: Did you understand a single word of what he just said?

    1. Anonymous Coward
      Anonymous Coward

      Re: As a non-programmer can I just quote Snatch?

      All you need to know, previously apply took the fast lane, now they have to drive safely. Expect a notice increase in iPhone lag...

      Good job iOS is still so basic, still not supporting proper multitasking and background service processes, otherwise it would be even worse.

      1. Anonymous Coward
        Anonymous Coward

        Re: As a non-programmer can I just quote Snatch?

        iOS most certainly supports full multitasking. It just doesn't expose the full ability to apps.

    2. Daggerchild Silver badge

      Re: As a non-programmer can I just quote Snatch?

      Non-technical summary as follows:

      Remember the famous 'Fools and Horses' clip (youtu.be/63rcdLeXiU8) with Del-Boy and the bar counter? The OS is Del-boy. The hacker is the barman.

  2. Warm Braw

    This isn't an easy bug class to fix

    The Mach kernel had a reputation for being slow - it had a slight overhead in being a message-based kernel, but most of its performance deficit came from rights checking.Sumarising the blog post, it would seem that XNU (the NextStep and then MacOS and iOS kernel based on Mach) got round all of that by adding direct system calls that simply bypassed the message-passing and the slow checks and kept pointers to structures that would otherwise have been considered transient.

    Of course, ironically, it was precisely the message-passing that made the transience clear and those access checks that were designed to stop this kind of problem arising in the first place.

    I think this one needs to be filed under "layer violation considered harmful".

    1. Charlie Clark Silver badge

      Re: This isn't an easy bug class to fix

      Yeah, but context-switching is so damn slow on x86. Any idea of the performance on ARM?

      1. Brewster's Angle Grinder Silver badge

        Re: This isn't an easy bug class to fix

        If the performance issue was x86 specific then it would show up on Linux and Windows.

        But it appears it's the hardware task switch which is slow on 32 bit processes. However that's only used for transitioning between kernel and user land. (See stackoverflow.)

        1. Kristian Walsh Silver badge

          Re: This isn't an easy bug class to fix

          In any case, NeXTStep's kernel was first written for Motorola 68030 CPUs, not x86. From there it went to x86, then PowerPC, then x86 again.

          If my memory hasn't failed me, 68030 still had only two execution contexts that it had inherited from 68000: User and Supervisor, but moving between them was only a matter of a stack push and a status register bit flip (you couldn't do it explicitly: you had to generate an exception, usually via the TRAP instruction, to enter Supervisor mode, or use the RTE instruction to leave it)

      2. Wensleydale Cheese

        Re: This isn't an easy bug class to fix

        "Yeah, but context-switching is so damn slow on x86. Any idea of the performance on ARM?"

        Patience, Grasshopper.

      3. Warm Braw

        Re: This isn't an easy bug class to fix

        > Any idea of the performance on ARM?

        Well, actually, it wasn't the context-switching that was the issue, it was the IPC (messaging and permissions) which reportedly was responsible for about 70% of the cost, so CPU effects were minor by comparison.

        More modern microkernels are a lot less complicated than Mach, but that just ends up punting elsewhere the problems Mach was supposed to solve.

        1. Dazed and Confused

          Re: This isn't an easy bug class to fix

          > Well, actually, it wasn't the context-switching that was the issue, it was the IPC (messaging and permissions) which reportedly was responsible for about 70% of the cost

          In classic Unix IPC (think SYSV msg queues, sockets, locks, pipes, you name it) the majority of the time is taken up in the switch from userland to kernel land. Whether you want to consider this to be a context switch or not is kind of up to you but there are a lot of similarities. Where you can replace full kernel entry high level code system calls with a lightweight assembler don't need to state save, don't need a kernel stack etc. calls then massive performance improvements are possible, massive as in many orders of magnitude not a few tens of percent.

    2. Daggerchild Silver badge

      Re: This isn't an easy bug class to fix

      We all know this has come about because they don't have a raging Linus.

      "WTF is *THIS* ****ing %@#*! Find him! I will cut his heart out with a SPOOOOOOOOOOON!"

    3. JLV

      Re: This isn't an easy bug class to fix

      QNX, the BB10 ancestor, claims to supposedly have a clever optimization of message passing, which, again claimed, made it a better microkernel than its predecessors (such as MACH).

      This is old tech, QNX was around (in 4MB RAM on 386s) in the early 90s, so the patents have lapsed.

      Is any of that applicable to this kinda problems?

  3. Charlie Clark Silver badge

    Where's all the snark?

    Fanbois have in the past been only too happy to pour scorn over Google for this kind of research.

    1. Anonymous Coward
      Anonymous Coward

      Re: Where's all the snark?

      No snark here. Google found a bug. Apple accepted it and set about the task of fixing it.

      Some bugs are easy, some are hard. This one sounds like a lot of work to me especially if this practice had used been in the kernel for a long time

      Apple have fixed it (apparently) so kudos to them and kudos to Google for finding it in the first place.

      I've just found a bug with a piece of software. Took me several weeks to track down and document. It took longer than it should have done because the behaviour changed between release versions. It is exceedingly boring and painstaking work especially documenting all the test cases.

      The software maker has accepted my findings and will be sorting it out. Because it is a possible security hole I'm posting AC.

      1. Charlie Clark Silver badge

        Re: Where's all the snark?

        Because it is a possible security hole I'm posting AC.

        Why would that matter? It's not as if you posting an exploit here.

        I also take the time to document bugs and inform the relevant developers. I've recently informed Apple of a bug in their handling of OOXML files but I won't be holding my breath for a response. This is only too often the case with them so kudos for Google for holding back from publishing. I wonder if the naming and shaming of Microsoft earlier in the year helped focus Apple's attention on this?

        1. Robert Carnegie Silver badge
          Black Helicopters

          Re: Where's all the snark?

          Publishing an exploit publicly is one thing. Keeping it secret but publishing your name and address so that "Honest Ron" can pop round and use friendly persuasion to get the details out of you or your spouse and children, is another. Name and address also might be the clue that it is worth asking about e.g. A.Banker@BritishVirginIslands.com

          The anonymous way, "Honest Ron" has to use friendly persuasion on The Register first, which I'm not betting on being impossible, unless "Anonymous Coward' actually is untraceable even by the Reg. But also there's no definite indication, besides the coyness itself, that anyone else would actually be interested in abusing the system.

          "A Friend"

          (Black helicopter seems unlikely for Ron but I'll put it on anyway)

        2. Wensleydale Cheese

          Re: Where's all the snark?

          "Why would that matter? It's not as if you posting an exploit here."

          Someone might know be able to put two and two together and work out who he is.

          Obligatory XKCD

    2. Anonymous Coward
      Anonymous Coward

      Re: Where's all the snark?

      This time it's seems Google actually realised it was difficult to fix and didn't act like a bunch of dicks by releasing the exploit before the patch was ready and pushed out.

      1. Anonymous Coward
        Anonymous Coward

        Re: Where's all the snark?

        Google engineers didn't want to upset their hardware provider...

      2. Anonymous Coward
        Anonymous Coward

        Re: Where's all the snark?

        This time it was Apple, not Microsoft. So Google was a gentleman this time.

  4. Anonymous Coward
    Thumb Up

    Karma baby

    So let me get this straight: Apple had the XNU kernel (i.e. big chunks of Mach) and found that doing things the proper way (y'know, message passing as the Mach design intended) was too slow, so they bypassed it. And now Google (Google! of all people) have identified what a security risk that is.

    Meanwhile, in an office in Redmond, Rick Rashid is laughing his head off.

    Strange times we live in.

  5. Slx

    I don't really see the big deal to be quite honest.

    Most complicated software, including operating systems, will inevitably have potential security holes that, despite tons of very competent developers, will go unnoticed.

    The key thing here is Apple closed the security hole and it does not seem like it was an easy fix by any means. You can't really go mucking about with a fundamental issue in a kernel and expect to be able to release the finished product to millions upon millions of devices without going through a whole load of testing and polishing.

    I know people like to bash Apple, MS, Google and other big IT companies but it gets a bit tiresome at after a while.

    1. Adam 1

      And kudos to slurp for not trying any 90 day crap in spite of the fact that either iOS becoming unstable due to a rushed fix or remaining knowingly insecure would both commercially benefit them.

  6. hellwig

    Simple Solution: Circular Reasoning

    Apple's can't get viruses, so a kernel vulnerability that would enable viruses isn't necessary to fix. -QED

    I'm sure it was difficult, but eight months? I guess if they put only one person on this problem.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like