start	end	text
0	3900	So I'm here today to talk to you about machine check exceptions.
4220	9980	Basically what happens on your computer when something goes terribly, catastrophically wrong with the hardware.
10340	11820	So why do we want to look at that?
11820	16020	Well, it turns out that it's got some interesting applications for security that nobody's ever looked at before.
16020	22460	But in order to explore it a little bit more, we really, really want to be able to see a machine check actually happen.
22660	24880	So my setup here is on the left.
24880	27020	I've got an x86 platform.
27020	31700	And I'm going to be talking about x86 architecture today, but a lot of this will apply to other architectures as well.
31800	35980	And on the right, we've got a little program running on this machine.
36300	42040	It's just shuffling some letters around just to show us that something's actually running.
42040	46240	And I think we're all probably familiar with what happens on a computer when something goes kind of wrong.
46240	50600	We've probably seen, like, program crashes and seg faults and maybe a blue screen before.
50600	57380	But I want to look at what happens when something goes, like, catastrophically wrong with the hardware in a way that can't be recovered.
57480	63940	The problem is computers today are actually pretty resilient and things just don't go catastrophically wrong very often.
63940	68820	And we could watch this thing for, like, the next 10 years and probably not see any serious problems with the system.
68820	76660	So if we want to research this a little bit more, we've got to give the computer, like, a little nudge to try to make something go catastrophically wrong with the hardware.
76740	81300	So I thought, you know, maybe what if we rip off the heatsink from the CPU while the thing's running?
81300	84420	Maybe that'll make something go wrong with the system.
84600	89100	But if we try that, nothing really happened.
89100	91340	We didn't get so much as an error message.
91580	97120	Like I said, computers today are actually pretty resilient and things just don't go terribly wrong all that often.
97120	106480	So what probably happened here is the CPU started to overheat and then it got a proc hot signal and it decided to underclock itself to stay within the desired thermal range for that system .
106480	111160	So if we really want something to go catastrophically wrong, we're going to have to give it a bigger nudge.
111160	115420	We're going to have to make it so that the CPU can't just run away from its problems.
115580	120280	We'll see if we can overheat this thing enough that underclocking is not going to help it.
120280	123540	So we got to be a little careful here not to melt the rest of the platform.
123540	128840	But if we're precise, we can hopefully make something go wrong with the hardware.
128840	129800	And there it goes.
129800	131400	The whole thing shut down.
131500	139960	So what happened there is probably the CPU got a therm trip signal and it decided that it needed to just power off the whole platform to avoid permanent damage.
140680	144820	And if the CPU cools down a little bit, this thing will boot back up, no worse for wear.
144880	146440	But what's the point of all this?
146440	154840	Well, it turns out that in the microseconds before everything comes crashing down for the CPU, some really interesting things start to happen.
154840	160480	But in order to explore that a little bit more, we need to talk about interrupts and exceptions and how they work on a processor.
160480	164840	So the idea here is you've got some code running on the CPU.
165340	168700	You've got, you know, maybe you're setting X to 1 and Y to 2.
168740	172860	But then you've also got other devices connected to the CPU, like a PCIe device.
172860	175560	And that PCIe device might want the CPU's attention.
175560	179500	So it sends like a signal over to the CPU requesting its attention.
179500	185080	The CPU, whatever your program was doing, maybe it was setting X to 1, it's going to stop your program and interrupt it.
185080	190560	It's going to give control over to an interrupt handler instead and then that interrupt handler can service the interrupt.
190560	198480	In this case, maybe the interrupt handler writes out a value like 100 over to the hardware and then gets the hardware's response and then it's all done and so it returns.
198480	205180	The operating system gives control back to your program and your program continues executing totally unaware that it was ever interrupted in the first place.
205320	207180	At least that's how things normally go.
207180	208560	But it's not always that easy.
208560	213080	So suppose you were writing like a Linux kernel module and you wanted to be able to talk to hardware.
213080	214280	Maybe your code looks like this.
214280	219340	Maybe you write out the value 200 to some piece of hardware and then you want to get the hardware's response.
219480	224920	But meanwhile, right after you write out that value 200, some other device on the platform interrupts the CPU.
224920	228140	The CPU interrupts your program and gives control to an interrupt handler.
228140	234840	That interrupt handler writes the value 100 to the same piece of hardware you were trying to talk to and gets the hardware's response.
234840	236000	So interrupt handler's happy.
236000	242340	But when it gives control back to your program, you're trying to get the hardware's response to the value 200, but somebody just clobbered everything you were doing.
242340	246340	You get the response to the value 100 and your whole program comes falling apart.
246380	251220	So it turns out that some things on a CPU just really shouldn't be interrupted.
251220	257700	Things like privileged transitions or secure environments or all sorts of other stuff happening in the kernel, you might not want to have interrupted.
257720	260560	So the solution to this is interrupt suppression.
260560	265540	Basically, keep interrupts pending until you finish the work you need to do and then you can service the interrupts.
265540	268720	So that would look something like this if you were writing a Linux kernel module.
268720	277660	You'd put on this IRQ save and IRQ restore before and after your code and that'll keep most of the interrupts on the platform suppressed until you finish your sensitive work.
277740	290240	Now, it can be a little bit hard to know exactly which code can be safely interrupted and what can't be safely interrupted, but as long as you do everything perfectly all the time and for every fringe case, there's really no issues here.
290300	292640	It turns out that that means difficulties arise.
292740	305400	So as an example, back in 2012, Rafael showed how in the user lands a kernel transition, if you got an interrupt or exception at exactly the right point, you could get kernel level privilege escalation.
305400	308060	Peterson showed something similar in 2018.
308060	318520	He showed how you could use a pop SS instruction to delay interrupts and exception by just one instruction in order to get them to come into the kernel at exactly the wrong time, leading to kernel privilege escalation.
318520	321600	Google Project Zero showed something similar in TDX.
321600	328240	When TDX was tearing down a secure environment, they could get an interrupt or exception to occur in order to get privilege escalation there.
328240	333080	Schluter showed using unexpected interrupts to leak information from confidential VMs.
333080	338620	So what we've seen over and over and over is interrupts act as kind of a state disruptor.
338620	342600	They mess up the normal flow of execution in a program.
342600	352860	So the solution to all of those problems that we've had in the past has always been very, very heavy interrupt suppression, like make extra sure that no unexpected interrupts can possibly happen.
352860	354840	There's ways to use software to help you with that.
354920	356420	Microcode can help suppress interrupts.
356420	358400	Hardware can help you suppress interrupts.
358480	376320	So when you see some of these secure environments set up, you'll see things like clear the interrupt flag, clear the trap flag, clear DR7, latch non-maskable interrupts, latch SMIs, mask inits, clear debug control, etc., etc., etc., just going through all these hoops trying to make sure that no interrupts or exceptions can possibly occur when you don't want them to.
376440	379280	But then that raises the question, like, can we break through this?
379280	380760	And what would happen if we did?
380760	389220	Well, it turns out that there's one interrupt that generally cannot be delayed or suppressed or latched or anything else, and that's called the machine check exception.
389400	401000	So machine checks are supposed to happen when there's unpredictable hardware failures, things like memory corruptions or cache errors, and they're caused by aging devices or signal integrity, heat issues, like if somebody holds a blowtorch to your CPU.
401000	404860	Even high-energy particles from the sun can cause machine check exceptions.
404860	408980	What happens is the CPU detects the problem, and it generates this MC exception.
408980	414000	MC is going to give control to the 18th interrupt handler in the interrupt descriptor table, which is installed by the OS.
414000	415300	And that looks something like this.
415300	416880	You've got your CPU running.
416960	420240	Something bad happens on that CPU, and the CPU detects a problem.
420240	421520	Maybe it's a bit-flipping SRA.
421520	423320	Maybe it's a thermal limit violated.
423320	428460	The CPU can assert a pin called catastrophic error to let the rest of the platform know things are going really wrong.
428460	430700	Then the CPU will generate a machine check exception.
430700	437160	It goes to this table in memory called the interrupt descriptor table, which is just a list of pointers that the operating system installed.
437160	443680	And one of those pointers, the 18th one, points to a handler that the operating system wants to run to handle machine check exceptions.
443700	445980	So we had a hardware failure happen.
445980	448080	The machine check was generated by the CPU.
448080	449640	Now the operating system has control.
449640	451360	So what does the operating system do?
451360	458360	Well, if we want to find out, we can dive into Linux kernel source and documentation, and we'll find things like this.
458360	465180	It'll tell you that machine checks can be delivered at any time, even in a critical section when all normal interrupts are suppressed.
465180	467580	They must be handled immediately.
467580	469100	The system is already unstable.
469100	470880	They will cause a machine panic.
470880	473200	The kernel will always panic on a machine check.
473200	474660	It's a bad idea to continue.
474660	475580	There's no way out.
475580	477560	There's no idea what we were executing.
477580	478880	There's no chance to recover.
478880	479860	You must die.
479860	481280	No need to fumble too much.
481280	482200	Just die.
482200	483760	So I think we get the gist here.
483880	487100	The kernel will determine the source of the error if it can.
487160	489020	It'll print a message if it can.
489020	494000	But the most important thing from the kernel's perspective is shut down the system before things get worse.
494080	496280	So why shut down and not fix the problem?
496300	500460	Well, usually with machine checks, you know that something went wrong, but you don't know quite what.
500520	504640	You might know that a bit got flipped, but you don't know which bit, so you don't know how to fix it.
504640	510000	And the safest thing to do, then, is to just reset, because if you ignore the problem, it's just going to snowball into bigger and bigger problems.
510000	511560	And there's some caveats to this.
511640	515100	On more recent platforms, there's correctable machine checks, and it gets really complex.
515100	516940	But traditionally, this is the strategy.
516940	519160	Shut down as fast as possible.
519200	524580	So all of this makes machine checks entirely unique amongst all the interrupts and exceptions on a platform.
524580	533280	They demand immediacy, and they represent this unexpected critical hardware failure that can't be masked or delayed or deprioritized or preempted in any way.
533280	539180	So the only way to avoid handling machine checks is to disable them in what's called the CR4 register.
539400	547620	And what happens if you do that is if a machine check does come in while they're disabled, while handling them is disabled, then the CPU will just reset.
547660	555680	So if you're writing some kernel code, your options are basically either handle machine checks immediately or be reset when one is received.
556100	561580	So what all this means is that our normal solution to interrupt suppression doesn't work anymore.
561580	572480	All those heavy-handed techniques for protecting code don't apply to machine checks, because machine checks hit the CPU entirely unexpectedly, and they can break through all normal interrupt defenses.
572520	575180	So all of this gives us a neat opportunity.
575180	579780	Maybe we can use this to build some sort of hammer to break through these interrupt defenses.
579860	581220	But we've got a challenge.
581220	583660	Machine checks are just exceedingly rare.
583660	587660	They're supposed to be this sporadic and unpredictable hardware failures.
587660	595120	And to see exactly how rare they are, you can actually go into proc interrupts on a Linux system, and you can watch interrupts and exceptions coming into the platform on real time.
595120	599740	And you'll see hundreds of interrupts and exceptions occurring every single second on the platform.
599780	602800	But that highlighted line, machine checks, that'll stay zero.
602800	608260	You could watch this for 10 years, and you won't see on a normal system a machine check actually received, because they're so rare.
608420	610000	Well, that's no good for us.
610000	611380	That's no good for exploitation.
611500	613780	We can't just wait 10 years for a machine check to come in.
613780	617040	So then we have to wonder, can we generate these on demand?
617120	619240	There's some way to simulate machine checks.
619240	623300	There's like a tool out there called MCE Inject, but all that does is call the operating system handler.
623820	625660	But that doesn't interrupt anything.
625660	630100	We need real physical machine checks if we want to use these for security purposes.
630520	632920	So I'm diving into that a little bit more.
632920	634460	We need to know how machine checks work.
634460	640360	So the gist behind machine checks is they've got these registers that track them, that are arranged in what they call banks.
640380	643400	And you've got different banks devoted to different sources of machine checks.
643400	648040	You'll have a bank for the L2 cache, and a bank for the decode unit, and a bank for the execution unit.
648040	651840	And there's just many, many options for these different machine check sources.
651840	656360	And you can start dumping all these different banks to see what types of things can cause machine checks.
656360	668140	And then there's extended banks, and it turns out that there's dozens of banks capturing hundreds of registers across thousands of bits, all of which represent different sources of these errors that can occur that the CPU can detect.
668140	679180	And if you want to know exactly what are these individual bits, you can start diving into Linux kernel source, and it'll tell you things like some of these are main tag parity errors, and some are for instruction buffer, and some are for the micro-op queue.
679180	681960	And the list just goes on and on and on and on and on.
681960	687620	There are hundreds and hundreds of different sources of these different types of problems on a CPU.
687860	692180	And if we want to dive into this, well, it's hard to know where to begin, but we've got to start somewhere.
692520	700200	So when I was reading through some of this documentation, I noticed that some platforms are reserving the fourth machine check bank for logging errors from the north bridge.
700200	705180	And that seemed interesting because the north bridge seemed a little bit more configurable than some of the other things I could access.
705180	711860	Like, I don't have a lot of control over parity errors in the L2 cache, but the north bridge has registers that we can actually reach.
712020	714680	So maybe we could start there, and then we can expand on this later.
714680	719960	And all these details are going to vary across different generations of CPUs, but it gives us a starting point.
720080	727080	So diving into the data sheets here, they suggest that machine check exceptions can be generated from master abort signals arriving from the north bridge.
727080	736060	So I thought this was super interesting because master abort is what happens when one PCI device is trying to talk to another PCI device, and that other device doesn't respond.
736060	738540	That's perfect because that's something we can control.
738540	745600	Even just from the Linux command line, if we use set PCI to try to access a device on the PCI bus that doesn't exist, we should get a master abort.
745600	748340	So we can try that, and nothing really happens.
748340	751340	We probably get a master abort, but we don't get a machine check here.
751340	752600	And that's not too surprising.
752600	759480	That would kind of defeat the purpose of machine checks if they just came about from these totally benign things like accessing a non-existing device.
759540	765400	But still, the data sheets suggest there's some way for a master abort to cause a machine check exception.
765620	769140	So maybe we can figure this out by diving into the north bridge a little bit more.
769140	783100	So I went through hundreds of pages of north bridge documentation trying to find out how can I generate a machine check here, and I found all these different registers that look like maybe they control in some abstract way the different kinds of errors that can be reported from the north bridge,
783100	788080	but none of these had enough information to decide conclusively how do I get a machine check out of this.
788140	799840	So I tried going through and flipping each of these bits one by one and accessing a non-existing device on the PCI space to see if I get a machine check, and a lot of those configurations were crashing or hanging the system, but I never did get a machine check.
799980	803600	And I thought, you know, maybe it's more than one bit that I need to change.
803600	811440	Maybe I need to change several of these bits, but that gets to be too many permutations to try by hand, and there's just not enough information in the specs to move forward here.
811620	818960	But I find any time you're stuck in CPU exploitation, a good strategy is just start smashing things and see what happens.
818960	833500	So I built a north bridge fuzzer here, and this fuzzer, basically, you'll specify which bits in the north bridge you're interested in, and in this case, there are about 25 or 24 different bits I thought might impact machine checks, and it's just going to start randomly flipping bits in the north bridge,
833500	838440	and if it gets a crash or a hang, we can just power cycle the system and try again.
838440	849060	On the other hand, if we don't get a crash or hang, we'll go ahead and try to access a non-existent device on the PCI space, and from that, we can see if we got any machine checks.
849060	852140	We'll look at those MCA banks to see if any machine checks got logged.
852200	859640	Now, the platform might reset with the machine check, but the neat thing about these banks is that they're what are called sticky, which means that they persist across the system reset.
859640	867880	So even after the reset, we can check the MCA banks to see if we get any machine check issues, and we'll just repeat this over and over and over, seeing if we can generate a machine check.
867880	869480	So that looks something like this.
869480	881620	On the right side, I've got the console on my computer, and on the left side, I'm going to fire up the north bridge fuzzer, and I had to censor out some of the different bit names that it's looking at here, since this issue I'm going to talk about is not actually patched yet,
881620	890220	but it's going to start flipping random bits in the north bridge and then trying to access a non-existing PCI device to see if we happen to get a machine check issue.
890720	899040	And eventually, if we let this run a little bit, we'll get an error that very, very briefly spits out on the console window, and then the system's going to reset.
899040	906600	But like I said, those MCA bank bits are sticky, so now we can look at the boot logs and see that, sure enough, we got a machine check log.
906600	908400	So this was super exciting.
908400	918640	I don't think anybody's ever found a way to generate machine checks on demand before, and what the fuzzer found was two specific bits in the north bridge, where if we flip those bits, now we can generate machine checks.
918640	920140	But we've got a problem.
920220	931760	Those machine checks are being delivered to the same core that generated the master abort, and from an exploitation perspective, it's not super useful to have a core that can just target itself with a machine check.
931760	934320	All that lets us do is interrupt our own code.
934580	938020	Basically, we have a hammer now, but we can only hit ourselves with it.
938020	939860	So we need to improve this a little bit.
939860	944520	We need a way for one core to attack a different core with machine checks.
944520	946420	Basically, we need to add a handle to our hammer.
946620	951500	So we can modify the fuzzer a bit here and start looking for more complex bit configurations.
951780	958720	Still the same idea, generate a PCI abort from one core, but then look at the other cores to see if they got the machine check exception.
958980	968900	And it takes a bit longer, but if you let the fuzzer run for a few hours, eventually it will find a different configuration of bits that lets us target different cores with the machine check exception.
968900	975000	So it finds three bits in the north bridge, where if we flip them, we can attack core zero from any other core on the processor.
975000	977940	But we've still got an issue, because the platform's still resetting.
978000	981860	So basically at this point, we just need to be a little bit more careful with our hammer.
982280	988360	So interrupting core zero from core one is neat, but it doesn't help us for exploitation if the system just goes down right away.
988480	991520	So what we need to do is figure out, you know, why does the system go down?
991520	993300	It's not actually because of the machine checks.
993300	998120	It's because the operating system decides that's the safest thing to do when it gets a machine check.
998140	1004120	So to get around that, we can hijack the CPU interrupt descriptor table and install like a first pass machine check handler.
1004220	1005340	So what that looks like is this.
1005340	1010880	So normally the operating system sets up this IDT, which is the table that describes how to handle different interrupt events.
1010880	1014420	And one of those entries tells the CPU how to handle a machine check.
1014420	1019360	What we want to do is replace that interrupt descriptor table with our own, with a hijack IDT.
1019380	1022940	And the hijack IDT is going to get control first whenever there's any interrupt event .
1022940	1031640	And usually what I have the hijack IDT do is just kind of pre-process the event to see if there's anything about it that we want to change, and then hand off control to the operating system's IDT .
1031640	1035460	That way we get first dibs on any interrupts or exceptions happening on the platform.
1035460	1045320	So what I had the handler do, our hijack IDT, is just going to indiscriminately clear any of the log machine checks that it finds in the MCA banks before giving control to the operating system.
1045320	1049960	That way the operating system won't reset the platform because it can't figure out what caused the machine check to begin with.
1049960	1050880	So that's kind of dangerous.
1050880	1055520	Usually you want the system to reset if you get a machine check, but it's good enough for research and exploitation.
1055880	1057380	So collectively that looks something like this.
1057380	1072020	Up at the top we've got our, we're watching the machine checks come in, and down here at the bottom what I'm going to do is I'm going to insert a hijack IDT onto the processor, and then we're going to poison the north bridge so that it'll turn any small error into a really big error.
1072020	1077040	And then I'm going to use the set PCI command to try to access a non -existent PCI device on the bus.
1077040	1085220	I'm going to try to access it from core 1, and you'll see that the machine check gets received on core 0, and best of all the whole system stays running.
1085220	1086180	So this is great.
1086180	1088300	This gives us like a state disruptor tool.
1088300	1094200	It gives us a way to do on-demand generation of machine check exceptions entirely from software.
1094320	1108120	So moving forward, I'm going to keep using this north bridge approach for generating these machine checks, and the configuration specifics of that are going to vary by what platform you're working on, but there's lots and lots of different ways to explore for generating machine checks beyond what I'm looking at here.
1108120	1112140	But the next question then is, well, what do we want to target with this?
1112140	1116880	So we basically have a great hammer now, we just need to find a nail.
1116940	1125940	So the current machine check approach is using ring 0 for north bridge reconfiguration, which means we need to find targets that are more privileged than ring 0, and we can revisit that requirement later.
1125940	1127740	I think there's a lot of ways around that.
1127740	1131120	But for now, let's look at something more privileged than the kernel, than ring 0.
1131120	1137640	So a lot of people think that once you gain code execution inside of the kernel or ring 0, that it's basically game over, you have everything you need.
1137640	1143140	But it turns out on modern platforms, it actually gets much, much deeper than just the kernel and ring 0.
1143180	1149880	So some of the different things we might look at are like hypervisors and secure guests and enclaves and secure loaders, the list goes on and on and on here.
1149980	1154240	What I settled on for exploitation here was system management mode as a really appealing target.
1154300	1157540	I almost didn't pick system management mode just because it's been done before.
1157540	1163700	But it turns out SMM has some really interesting properties that make it a great case study for machine check exploitation.
1164060	1168880	So if you're not familiar with SMM, it's actually a pretty neat mode of execution on x86 processors.
1168880	1170700	It's been around for like 35 years.
1170700	1175340	It's invisible to the operating system and hypervisor, it can preempt anything that's running on the system.
1175360	1180760	And because it's got all these neat permissions, a lot of people think of more privilege than ring 0 or the kernel.
1180760	1183840	It's often called ring minus 2, negative 2.
1183920	1187000	It's critical to platform security and server reliability.
1187120	1191820	And one of the neatest aspects is it usually has read and write access to a platform's firmware.
1191820	1197580	So you can use it to persist implants down to firmware, which can survive a hard drive wipe or an OS reinstall.
1197580	1199760	But all of that looks something like this.
1199760	1206880	So the gist is when your computer first starts up, firmware has control before the operating system starts, and you've got some RAM on that system.
1206880	1210540	So firmware's going to start partitioning that memory space into some different regions.
1210540	1219160	It's going to pick a specific region inside of your memory to call SM RAM, system management RAM, and it's going to track SM RAM by a pointer called SM base.
1219420	1231140	Then firmware's going to drop a whole bunch of code into SM RAM for handling system management interrupts later on, and then it's going to lock down SM RAM so that nobody ever gets to see what's inside of SM RAM again.
1231180	1241100	Later on, when your operating system or your user code is running, some IO device on the system's going to trigger something called an SMI, a system management interrupt, which is then going to hand control to microcode.
1241340	1243820	Microcode's going to open up SM RAM temporarily.
1243820	1250000	It's going to save the CPU state, load a new SMM state, and then jump to the handler that firmware installed inside of SM RAM.
1250100	1253420	So inside of SM RAM, all this code is executing that you never get to see.
1253420	1259740	And when it's all done, it's going to execute this magic resume instruction, which gives control back to microcode, which does the reverse of the process.
1259740	1264360	It restores the CPU state, it closes SM RAM, and it jumps back to the original code.
1264360	1270820	Now, your original code that got interrupted has no idea that a whole bunch of stuff just ran underneath it that we never even got to see.
1270920	1274380	So a demo for system management mode is a little bit anticlimactic.
1274380	1278980	If we want to understand what is inside of this SM RAM, it might be a little unsettling.
1278980	1282080	There's this whole region of memory on our computers we never get to see.
1282080	1286700	We can figure out where that memory is by reading a very specific register from the CPU.
1286780	1294900	But then if we try to access that memory, even if we're running inside of the kernel with ring zero level privileges, if we ask the CPU, hey, what's at this memory?
1294900	1296940	The CPU comes back and says, oh, just Fs.
1296940	1297980	Don't worry about it.
1297980	1299240	Nothing to see here.
1299240	1304540	So, you know, it's a little bit concerning when there's stuff on our computers that we have no insight or control over.
1304540	1307860	So it's always nice to try to break into these things.
1307860	1308820	So how could we do that?
1308820	1311020	How can we compromise this ring minus two?
1311120	1312440	There's a couple things to keep in mind here.
1312440	1315820	One is that SMM code is running inside of SM RAM.
1315820	1324980	And if we could corrupt or hijack the normal control flow of that code, then maybe we could use that to execute a malicious payload but inside of SMM with ring minus two privileges.
1324980	1328340	And that payload then could unlock system management RAM for us.
1328740	1331940	So moving forward with this, there's another key aspect we need to understand.
1331940	1337100	And that's that different CPU modes have to share resources with differently privileged modes.
1337100	1345540	So like if you're switching from user LAN down to the kernel, some of the CPU registers are going to be shared in between those two different execution modes.
1345540	1350740	Ideally, what we'd like to do is we just reset all the CPU registers anytime we change modes.
1350740	1354120	That way we don't have to worry about what was in those registers before.
1354120	1359560	But when there's thousands of different registers on the CPU, we don't really have the luxury of resetting them all.
1359560	1367880	So what architects have to do is they have to carefully decide which registers have to stay the same, and which registers do I need to change when I switch modes.
1367880	1373820	And if you do that all correctly, then even from a less privileged mode, you can't really impact a more privileged mode.
1373820	1380420	So in investigating this, I started to look into the AMD documentation on how they implement system management mode.
1380420	1384280	And if you dive deep enough into that documentation, you'll see a chart like the chart on the right.
1384280	1389820	And it shows you exactly which registers get changed when you enter system management mode and which registers stay the same.
1389820	1394880	It'll also tell you that they suppress all the normal interrupts when they enter system management mode, just like we talked about earlier.
1394880	1398800	We don't want to have interrupts unexpectedly firing when we're entering secure modes.
1398800	1405280	But one of the things in this chart caught my attention, and that's this IDTR is marked as unmodified.
1405280	1406100	So why does that matter?
1406100	1415620	Well, IDTR is the register that points to the interrupt descriptor table, the table that tells the CPU how to handle any interrupts or exceptions that occur on the processor.
1415800	1430960	Leaving that unmodified on entry to system management mode is a bit of a curious choice for implementing a secure mode, because it means that any interrupt or exception that does occur inside of system management mode is going to be delivered on an untrusted handler.
1430960	1438540	And that's not just for interrupts, it's even pretty benign exceptions, like have a divide by zero error, call the untrusted code to deal with that.
1438540	1448740	In fact, it's kind of like throwing all your code into a main function and then wrapping main in a try except, and then in your except block, just pop a shell for the attacker.
1448740	1454620	So like anything at all that goes wrong in your code leads to immediate privilege escalation for somebody else.
1454620	1463880	In fact, the, the CPU design documents say that because of this implementation, they strongly recommend that you write all your code without bugs in it.
1463880	1469220	And I, I guess that's, that's okay, but it seems like maybe we could be doing something better than that.
1469220	1475900	So when I reached out to the vendor about this and kind of expressed my concerns here, they, they really didn't want to call this a vulnerability.
1475900	1478700	And I had to get these slides through all sorts of legal and other reviews.
1478700	1482760	So we're going to call this a feature instead, and then we'll talk about how to exploit the feature.
1483000	1489440	Because there's, there's lots of ways to approach this when anything at all that goes wrong is going to lead to privilege escalation.
1489440	1492700	We just have to make something, anything go wrong on the CPU.
1492700	1500040	Well, it's convenient then that we've actually got this tool to throw machine checks at other cores and cause things to go catastrophically wrong.
1500260	1504380	So we've got a problem though, if we want to use machine checks to exploit this issue.
1504460	1513720	And that's that microcode does clear out this CR4 register, which means that machine check handling is temporarily disabled on entry to system management mode.
1513820	1517760	So to understand what we can do about that, we need to dive into SMM code a little bit more.
1517760	1520900	So the source of this code is called EDK2.
1520900	1526260	EDK2 is like an open source implementation or reference implementation for EFI firmware.
1526260	1530460	It's basically showing everybody, here's one way to implement the EFI specification.
1530460	1535740	And then vendors can take that EDT, EDK2 code and then adapt it for their platforms as needed.
1535740	1542120	So this is how EDK2 shows you could implement an SMI handler in system management mode.
1542120	1547300	There's a lot of code here, but the parts we're most interested in are right here with this CR4 load.
1547320	1551020	EDK2 is going to enable handling of machine check exceptions.
1551080	1554420	And then over here later on, we see an instruction called LIDT.
1554420	1559100	That's going to reload a new interrupt table inside of system management mode.
1559100	1562920	So collectively that gives us a couple of different attack windows inside of SMM.
1562920	1576880	So the first attack window we've got is basically for any exception at all, other than machine checks, if you can cause something to go wrong before that LIDT instruction, it'll be handled on an untrusted interrupt descriptor table.
1576880	1582680	On the other hand, if you want to look at machine checks specifically like I was doing for this research, your window's a little bit narrower.
1582800	1588540	Your attack window's in between that CR4 reload and the upcoming LIDT instruction.
1588540	1591200	So our machine check attack might look something like this.
1591200	1603500	If we can create a machine check from a thread that's outside of SMM and receive that machine check on a thread that's inside of SMM exactly within that narrow attack window, then we could get privilege escalation.
1603500	1605760	But we've got yet another hurdle to overcome.
1605760	1611720	The system management mode design basically has all threads entering and exiting system management mode simultaneously.
1611720	1619620	So what happens is a thread will generate a system management interrupt through some hardware event, and then that signal gets sent to all the different threads on the platform.
1619820	1625780	And then each thread gets to finish its current instruction, and then microcode's going to pull those threads into system management mode.
1625780	1627120	And that's called thread quiescing.
1627120	1630880	It basically ensures that all threads are inside of SMM at the same time.
1630980	1636340	And indirectly, that prevents a non-SMM thread from attacking an SMM thread.
1636340	1640560	And it's a pretty common pattern in designing these privileged execution modes.
1640580	1649160	So our challenge here then, we need a victim thread that's in SMM, and an attacking thread that's outside of SMM, but all threads enter SMM at the same time.
1649160	1655700	Well, there's an observation here, and it's that threads do not technically all enter system management mode at the same time.
1655700	1667360	Each thread gets to finish the instruction that it was currently working on before it gets pulled into SMM, which means that an attacking thread has one instruction with which to complete an attack here.
1667360	1669920	So what if we had an attack that looked like this?
1669920	1675100	We begin some sort of magic instruction, and I don't know what this instruction is at this point, on an attacking thread.
1675100	1678540	And then on a victim thread, the victim thread is going to trigger a system management interrupt.
1678540	1681000	On x86, you can do that by writing to port B2.
1681000	1689120	Both threads are going to get the system management interrupt, and now microcode is going to force them to both enter, like finish up the instruction they're working on, and then enter system management mode.
1689120	1693220	So our victim thread is going to finish its instruction, then get pulled into system management mode.
1693220	1699780	It's not going to change its IDT, since that's the behavior on these processors, but it is going to disable handling of machine checks.
1699780	1705940	It's going to start executing its handler, and then at some point in the future, the victim thread is going to enable handling machine checks.
1706000	1718920	And if, at exactly this point, thread one, that instruction that it began at the beginning, if right here, thread one generated that machine check exception, received by thread zero, we would get code execution on the victim thread here.
1719000	1729860	Eventually, the thread one attacking thread will end its current instruction, then get sucked into system management mode as well, and if we miss the machine check window, thread zero, the victim is going to load up a new safe interrupt descriptor table,
1729860	1731780	so that you can't attack it anymore.
1731840	1733980	So this is where we're at.
1733980	1744080	We need some sort of magic instruction that can begin, and then 10,000 cycles later, I actually measured how long this would take, it would take 10,000 cycles before that attack window opens up.
1744260	1751840	And if you can, after 10,000 cycles, then get a machine check to be delivered on the victim thread, within a hundred cycle attack window, you'll get execution.
1751960	1769060	But right now, this is what we have, as far as how we generate machine checks right now, it only takes about 700 cycles for an attacking instruction to generate a machine check, which means we, we undershoot our attack window, the machine check is received on the victim before machine check handling is actually enabled,
1769060	1770900	and the whole platform is going to reset.
1770900	1775600	So the question then is, does this magic instruction actually exist?
1775600	1783180	Is there an instruction that can generate a machine check exception after 10,000 cycles, but still be precise enough to hit it in a hundred cycle window?
1783180	1789720	Essentially, what we need here is some sort of fuse, a way to delay, start the process, but delay the actual machine check.
1789760	1791640	So how do we build this fuse?
1791640	1793760	Well, we've got a lot of challenges to overcome.
1793760	1797220	One is that we need an instruction that can actually generate a master abort.
1797220	1801140	And master aborts are being done through MMIO on PCI space.
1801140	1806180	The architecture requires that accessing MMIO follows a very specific form.
1806180	1810400	You have to use a specific instruction and specific registers to access MMIO.
1810400	1820980	So in looking at how long that, that instruction takes, it's like six cycles if you're hitting cache, or 250 cycles if you're hitting RAM, and 700 if you're hitting PCI MMIO.
1821400	1830360	700 cycles is still an order of magnitude away from the 10,000 that we need for this fuse instruction to hit the actual attack window, which means the attack won't work.
1830360	1832180	It's basically fundamentally broken.
1832420	1836600	So I started thinking about this when I thought, like, maybe there's no way forward here.
1836600	1841340	And eventually it occurred to me that, you know, not all MMIO is going to be exactly the same.
1841380	1849260	Maybe the, the address I'm using right now for my machine checks takes 700 cycles, but surely there's other things on the PCI bus that take longer.
1849260	1859280	So I built a little tool to actually measure the MMIO space and how long different accesses take, and started looking for anything on the PCI space that takes an unusually long time to access.
1859280	1864500	So what I found is that most things are taking like 700 cycles, but some things are taking like 4,000.
1864500	1867640	And that's starting to get a little bit closer than where we were before.
1867640	1869740	So I started wondering, can we increase this somehow?
1869740	1883060	And I started looking at adding additional MMIO traffic, or underclocking the CPU, or doing weird PCI topologies, and all of those could increase it a little bit, but nothing got me to the 10,000 cycles we needed, and the attack was becoming less and less practical.
1883220	1885160	But then I realized I was doing something stupid.
1885160	1891400	I was following the CPU specs, and when you're trying to exploit something, that's the opposite of what you want to do.
1891540	1898160	So the specs say you have to, if you want to access MMIO configuration space, you have to use instructions of the following form.
1898160	1899720	It has to be a move instruction.
1899880	1902200	It has to be either EAX, AX, or AL.
1902200	1904540	That's a 4-byte, 2-byte, and 1-byte register.
1904640	1907660	And you have to use some memory addressing form to do that.
1907660	1909800	And it says nothing else is allowed.
1909920	1914780	So this is what our instruction would normally look like for accessing MMIO space.
1915080	1922860	But what if instead of the EAX register like it tells us, what if we use a register that it tells us we can't use, like RAX is an 8-byte register?
1922980	1928600	Well, if we try that, it turns out it works, and the access time jumps from 4,000 cycles to 8,000 cycles.
1928600	1935960	And I think what's happening is behind the scenes, it's actually breaking this into two 4-byte accesses, which doubles the access time for that MMIO device.
1936120	1939360	So I start to think, what else can we violate in the CPU specs?
1939360	1940500	Well, there's another thing it tells us.
1940500	1945100	It says all such accesses are required not to cross any naturally aligned DWORD boundary.
1945100	1947340	And if you do, you'll get undefined behavior.
1947340	1948320	Well, that sounds awesome.
1948320	1950980	Let's find out what undefined behavior looks like in this case.
1950980	1952460	So this is what our instruction looked like.
1952460	1960480	We're accessing this on an aligned boundary, and if we unalign it just by one byte, all of a sudden, our access time jumps from 8,000 to 12,000 cycles.
1960620	1963000	So we've got the pieces that we need here.
1963000	1968200	All we need is a high access time on an existing PCI device, followed by a non-existing device.
1968200	1971980	That non-existing device is what's going to give us the master abort that'll generate the MCE.
1972160	1984160	And when we issue that instruction behind the scenes, it's going to do a 4-byte access here, taking 4,000 cycles, another 4-byte access taking 4,000 cycles, and it's going to take 4,000 cycles, but finally it's going to realize, hey, this last byte you asked for,
1984160	1987040	it doesn't even exist, and it's going to generate that master abort.
1987180	1988800	So we've got all the pieces now.
1988800	1990320	We've got this fuse instruction.
1990320	2004260	All we needed was an unaligned 8-byte PCIe access that straddles a slow PCIe device and a non-existing device where the CPU is going to perform three separate 4-byte MMIO accesses, and the final 4-byte MMIO access is going to hit a non-existing PCIe device,
2004260	2007140	then no device is going to claim that request, resulting in a master abort.
2007140	2016800	The master abort is going to be changed to a machine check by the north bridge that's going to be received by the CPU, which is going to send it to the victim core all 10,000 cycles after that instruction initially began.
2016800	2024300	So we're getting close, but we've got one last problem, and that's that we don't really have control over how long this fuse instruction takes.
2024360	2028220	But we still need that machine check to arrive in a really precise attack window.
2028220	2035580	So we wanted the attack to look something like this, where exactly 10,000 cycles after the fuse instruction begins, the machine check's received.
2035580	2036820	And what we got was this.
2036820	2043960	It takes 12,000 cycles instead, and we overshoot the attack window, and the machine check's not going to be delivered on an untrusted interrupt descriptor table.
2043960	2050040	We can fix this, though, by going to the victim thread and just adding a little bit of a delay before it starts triggering system management mode.
2050040	2054620	We can shift that attack window down in order to get the MCE to arrive at the right time.
2054620	2061320	So with that, we can actually deliver now these cross -core machine checks to victim threads at very, very precise times.
2061320	2063600	So we've got all the pieces now.
2063620	2066440	We've got a fantastic tool available to us.
2066440	2070340	The last thing we need is just a name for our tool, and it's kind of staring us in the face.
2070340	2072440	We built a hammer out of machine checks.
2072440	2074280	We built an MC Hammer.
2074580	2081160	So let's see what this whole tool is going to look like in action, because it gets a little bit convoluted.
2081280	2084920	But you've got your CPU, and you've got some different devices attached to your CPU.
2084920	2088260	And then on the right side, you've got your RAM, some MMIO space, and other stuff.
2088260	2090840	While your CPU is booting, the firmware has control.
2090840	2096560	The firmware's going to partition out some RAM, call that SM RAM, and it's going to drop a whole bunch of code into SM RAM.
2096560	2102660	The firmware's going to lock down SM RAM so nobody gets to see it anymore, and then it's going to hand control off to the operating system.
2102660	2110180	The operating system's going to install its own interrupt descriptor table, a list of pointers to different functions for handling interrupt and exception events.
2110220	2116740	Meanwhile, we're going to start a victim thread on thread zero and an attacking thread on thread one.
2116900	2129400	The attacking thread is going to reconfigure the north bridge with those magic bits that the fuzzer found to essentially poison the north bridge so that any small problem that the north bridge finds is going to escalate into a very big problem for the CPU.
2129420	2139640	Next, the attacking thread is going to install a hijack interrupt descriptor table on top of the victim thread so that the hijack IDT will get control before the victim thread's normal interrupt descriptor table does.
2139640	2144500	Inside of that hijack IDT, our machine check pointer points to a function that we want to run.
2144500	2147860	It's going to be the malicious code that we want to run when a machine check is received.
2147880	2151320	Now both threads are going to start this piece at exactly the same time.
2151320	2159980	Thread zero, the victim, is going to start a carefully calibrated delay loop to shift down the attack window just a little bit, while the attacking thread is going to start its fuse instruction.
2160040	2168960	So the victim thread is going to sit in a loop for just a little while to move that attack window down, and the attacking thread is going to send that address that it's trying to access over to the CPU.
2168960	2171520	The CPU decodes that address, sends it to the north bridge.
2171520	2174920	The north bridge decodes that address and sends it to the PCI bus.
2174920	2183020	The PCI bus is very, very slowly going to start responding to that first four byte chunk, the next four byte chunk, and eventually the last chunk that doesn't actually exist.
2183020	2188520	And effectively what we've done is we've started a timer on the PCI device that's going to come back later on.
2188520	2195080	Meanwhile, the victim thread is going to finish up its carefully calibrated loop and it's going to write to port B2 to trigger a system management interrupt.
2195180	2204460	The SMI request goes to the CPU, gets routed to some sort of external device, that IO device generates the system management interrupt, which gets sent to the attacking thread and the victim thread.
2204480	2211180	Now microcode's going to make sure that both of these threads get to finish the instruction that they're on and then they get sucked into system management mode.
2211180	2216180	Well, the victim thread's going to finish its out instruction very quickly and it moves over to system management mode.
2216340	2219540	Microcode unlocks SMRAM for the victim thread.
2219540	2220840	Only the victim thread can see this.
2220840	2222880	Everybody else still can't see inside of SMRAM.
2222880	2227580	The victim thread's going to start executing the handler that was installed by the, uh, by the firmware.
2227580	2234460	So the victim thread's going to execute, execute, execute, execute, and eventually the victim thread is going to write to that CR4 register.
2234620	2236200	This opens up our attack window.
2236200	2239640	It enables handling of machine checks inside of system management mode.
2239640	2245140	So our attack window has begun, but very shortly the victim thread is going to load a new interrupt descriptor table.
2245140	2252200	That's going to overwrite our hijack table and we won't gain execution if our machine check arrives after that LIDT instruction.
2252380	2259200	But, um, so the victim thread's going to execute, execute, and execute, and what we're hoping is that the MCE is going to arrive before we hit that LIDT.
2259200	2267980	And if we've timed everything correctly, all of a sudden that PCIe device that we were trying to access is going to realize, hey, that last byte you asked for, that doesn't exist.
2267980	2269340	Nobody's claiming that.
2269340	2271140	So it's going to create the master abort.
2271140	2274560	And PCIe parlance, that's an unsupported request, gets sent to the north bridge.
2274560	2280980	The north bridge, because it's been poisoned, translates that into a very serious error, a CPU read data error sent to the CPU.
2280980	2284260	The CPU gets that and translates that as a machine check exception.
2284260	2291600	And even though thread one was the one that caused the machine check exception, that exception is delivered to thread zero, which is currently sitting inside of system management mode.
2291600	2294680	Now thread zero needs to figure out how do I handle a machine check exception?
2294680	2300500	Well, it looks up a handler inside of the interrupt descriptor table, the IDT that we poisoned before the whole process began.
2300520	2305100	It follows the 18th entry in the IDT and begins executing the code that that points to.
2305100	2310960	Meanwhile, eventually the attacking thread is going to finish up its fuse instruction, microcode sucks it into system management mode as well.
2310960	2313060	We have no more control of the attacking thread here.
2313060	2315220	It's just going to execute its handler like normal.
2315220	2326720	And eventually it will resume and SMRAM gets locked up from the attacking thread's view, but that's okay because over here we now have our payload executing inside of system management mode with SMM privileges.
2327000	2329880	So a full demo of this looks a little bit something like this.
2329880	2335480	We fire up the MC hammer tool and it's going to replace all the interrupt descriptor tables on each core.
2335480	2337660	It's going to load up some MC kernel modules.
2337660	2342820	It's going to do a bunch of timing on different PCI devices to find that fuse instruction that it needs .
2342820	2346500	It'll poison the north bridge so that small errors become really big errors.
2346500	2352980	And when we're ready, we'll go ahead and launch a system management interrupt and that fuse instruction at exactly the same time.
2352980	2357120	And if we time them right, we gain code execution inside of system management mode.
2357120	2365320	And what I've got here is the malicious code that I executed inside of system management mode is a little command and control payload.
2365380	2368920	And that gives us a way to talk to system management mode from the kernel.
2368920	2378260	And what we can ask our C2 payload to do is to copy out SMRAM, that memory that we've never been able to touch before, we can copy that to a place where we can actually see it now.
2378260	2380500	So that's the, uh, the memory that dumped on the bottom here.
2380500	2394900	And the really neat thing is that on, on this platform, they left a whole bunch of build strings inside of system management RAM, which means that we can understand some of the capabilities that are inside of system management mode without ever having to do any sort of reverse engineering of the code.
2394900	2405020	So if we look for some of these build strings that were in the protected SMRAM that we could never see before, we can get an idea of some of the things that, uh, that can, uh, that system management mode can do.
2405020	2408780	So we can see that system management mode on the system has access to the platform flash.
2408780	2414380	We can see it's got all sorts of USB drivers built into it for reasons I don't really understand.
2414380	2422020	Um, if we scroll down, eventually we'll see that system management mode is able to persist, persist variables, uh, across boot by writing to the spy flash.
2422060	2426340	Um, and we'll see the lock box is a way of storing secrets inside of system management mode.
2426340	2431340	We'll see the S3 save state gives you access to all sorts of registers on the CPU you can't normally touch.
2431340	2440420	We'll even see that system management mode on this platform has special, uh, doorbell registers to the platform security processor, the PSP, that we can't normally access from anywhere else.
2440440	2446480	So it's, it's absolutely astounding how many different capabilities have been tossed into system management mode.
2446480	2451240	And once you gain code execution, you get access to all of those things that we could never touch before.
2451300	2454560	So where does that leave us as far as mitigations?
2454560	2464960	Well, uh, the, the idea that the malicious interrupt descriptor table is allowed in system management mode, that is a feature on all AMD CPUs to date.
2465360	2470900	Um, on the other hand, the machine check exploit that I developed, I developed this on pre-zen CPUs.
2470900	2473760	So at least one of these things we can fix ourselves.
2473760	2479240	So to mitigate the machine check path, um, we can change the way EDK2 works.
2479280	2484860	EDK2 is who's providing, uh, some of the code that ends up on our, on our firmware for our, our different platforms.
2484860	2491980	So even though that EDK2 SMM code is correct, it does assume that the IDT was being made safe by microcode.
2491980	2502740	So on platforms that are leaving the IDT in an untrusted state, when entering system management mode, uh, EDK2 can be changed to basically reload the IDT at an earlier point.
2502740	2508580	So I submitted a patch to EDK2 to remove the machine check vector, and that's still sort of trickling its way through the ecosystem.
2508640	2520840	But meanwhile, the IDT, um, feature remains where, uh, essentially any small problem that occurs in early system management mode will be handled on untrusted, uh, interrupt handlers.
2520840	2522620	And I think there's still a lot to explore there.
2523160	2524900	But back to the machine check piece.
2524900	2529180	I think this is a really exciting piece moving forward, uh, more so than the SMM piece.
2529180	2536000	Uh, what we kind of find is that machine checks turn out to be this, like, really powerful thing for exploitation that have never been explored before.
2536160	2540200	And I think there's a whole bunch of interesting ways that we can take this research.
2540200	2544780	So one is we could start looking at other, uh, sources of machine check exceptions.
2544780	2547860	Remember, there are hundreds of different ways to cause these different issues.
2548160	2550660	I looked at one of them coming from the North Bridge.
2550660	2556420	Uh, we could also look at ECC injection, different processor or rata are documented to cause machine check exceptions.
2556420	2561140	We could look at doing, like, row hammer style bit flips in DRAM to cause machine check exceptions.
2561320	2569940	We could look at other ways of doing asynchronous machine check exceptions, like there's a memory scrubber in ECC, uh, RAM that can cause asynchronous, uh, events.
2569940	2575200	We could look at other MMIO devices to cause asynchronous MCEs or how to do this with no MMIO devices.
2575220	2581440	The holy grail here would be finding a way to generate machine checks from user land from, from ring three.
2581500	2586280	Uh, if you, uh, you could, you could, you could look at, like, ring three or rata that are related to machine checks.
2586280	2591080	You could start looking at accessing faulty devices from user land to see if you can generate machine checks that way.
2591100	2603980	The neat part about this is if somebody can find a way to generate machine checks from ring three, all those vulnerabilities that I talked about at the beginning of the presentation that were fixed with more aggressive interrupt and exception, uh, suppression,
2603980	2608860	all those become viable, again, if you can use machine checks to break through those defenses.
2608860	2614280	We could start looking at other exploit targets like hypervisors and secure guests and enclaves and secure loaders.
2614280	2626100	And I think most exciting of all, we can start looking at other architectures because, uh, most of the major architectures out there have this idea of hardware error reporting and there's so much left to explore in ARM and RISC-V and MIPS and Power.
2626180	2633440	And I think we're really just, you know, at the tip of the iceberg here as far as where we can take this kind of, kind of research.
2633440	2643940	So anytime I do this, I feel like I'm standing on the shoulders of giants and, uh, people sometimes ask, you know, how can, how can they learn more and get up to, uh, uh, start doing some more of this type of research.
2643940	2646620	So I wanted to give a couple of, uh, resources here.
2646620	2652840	I wanted to give a big shout out to the fantastic int31 team who helped springboard and support a lot of these ideas in the early stages.
2652840	2657360	I wanted to give a big thanks to the DazzleCat team, namely Stephanie, who always gives me ideas on how to move forward.
2657360	2664260	And there is a huge slew of fantastic research papers on how to use interrupts in unexpected ways for privilege escalation.
2664260	2667460	And I only got to talk about a couple of those early on in the presentation.
2667620	2675500	And then after that, you can start diving into kernel source code to see how machine checks are handled in different situations and the different places machine checks can come from.
2675620	2680860	But, um, I've got a lot, lot more to share, uh, with this research and there'll be a lot more to come.
2680860	2685180	You can find me on most platforms under XOR, EAX, EAX, EAX.
2685180	2689040	Um, right now I've shared some bare bones stuff on the MC Hammer GitHub repo.
2689040	2692700	And I'll start pushing more and more stuff there as this issue is better mitigated.
2692700	2696820	Um, but definitely check that out because, um, like I said, it's just the tip of the iceberg.
2696820	2698140	So thanks everyone.
