1 00:00:00,060 --> 00:00:04,580 Okay, sorry for that. 2 00:00:05,060 --> 00:00:07,040 Good afternoon, everyone. 3 00:00:07,180 --> 00:00:08,640 My name is Xuexin. 4 00:00:08,640 --> 00:00:11,200 I'm the manager of Android Red team. 5 00:00:11,400 --> 00:00:23,640 Today I'm really honored to present you the way to Android root exploiting your GPU on smartphone with these two gentlemen. 6 00:00:25,700 --> 00:00:29,040 This is Xilin Gong, our security researcher. 7 00:00:29,040 --> 00:00:35,180 And he actually did most of the work, technical work, so big credit to him. 8 00:00:35,480 --> 00:00:39,000 And also next to Xilin is our tech lead, Eugene Rodionov. 9 00:00:39,100 --> 00:00:44,280 Eugene did a lot of work to help us create the slides and making sure the demo runs smoothly. 10 00:00:44,680 --> 00:00:45,980 Big shout out to him. 11 00:00:47,720 --> 00:00:55,600 So our story dated back to the earliest year when Xilin decided to take a look at Qualcomm GPU drivers. 12 00:00:58,040 --> 00:01:02,840 But before we go into details, here's a brief introduction of our team. 13 00:01:02,840 --> 00:01:05,580 So we are the Android Red team. 14 00:01:05,740 --> 00:01:09,820 Our goal is to increase the Android and pixel security. 15 00:01:09,820 --> 00:01:16,980 And we do this by simulating adversaries attacking Android key features. 16 00:01:17,060 --> 00:01:21,560 And our work can be broken down into a couple of different ways. 17 00:01:21,580 --> 00:01:31,300 Most obviously, we do offensive security research review to verify our breaking security assumptions, which means finding bugs. 18 00:01:31,500 --> 00:01:39,440 And we scale our work by developing tools such as continuous fuzzing or static analysis. 19 00:01:40,160 --> 00:01:52,220 And once we find issues, we develop proof of concept just to show the real world impact as some issues are not so straightforward to see their impact. 20 00:01:52,880 --> 00:02:02,200 Lastly, while we're developing the exploits, we're also assessing the efficacy of the security mitigations that our feature team implemented. 21 00:02:03,860 --> 00:02:11,320 The more pain we experience during our work, the more security our end user will gain. 22 00:02:11,320 --> 00:02:16,980 So we are literally making our work harder to help end users. 23 00:02:19,170 --> 00:02:21,170 So here's today's agenda. 24 00:02:21,170 --> 00:02:24,990 We'll first talk about the GPU and security background. 25 00:02:25,470 --> 00:02:33,770 And then we'll go through the Qualcomm Adrena GPU introduction, talking about its architecture and where the issue patterns are. 26 00:02:33,770 --> 00:02:43,670 And then we'll dive into a very technical details for the CVE-2024-23380 and how we exploit to gain root privilege. 27 00:02:44,110 --> 00:02:48,750 Lastly, we'll conclude our talk with the methodology discussions. 28 00:02:51,820 --> 00:03:00,260 So before we jump into engagement, usually we need to ask ourselves questions. 29 00:03:00,260 --> 00:03:02,520 Why do we look into this one? 30 00:03:05,580 --> 00:03:08,500 The answer is because our team is very small. 31 00:03:08,520 --> 00:03:12,740 So we want to spend our time into the most impactful areas. 32 00:03:13,740 --> 00:03:15,520 So why GPU drivers? 33 00:03:15,880 --> 00:03:18,860 Here we think these are the answers to that question. 34 00:03:18,860 --> 00:03:26,200 The biggest one is there is no permission required for applications to look into GPU driver. 35 00:03:27,260 --> 00:03:30,020 On the right side you can see a diagram. 36 00:03:30,260 --> 00:03:43,760 And the unprivileged applications, whatever user space library they call, OpenGL, Vulkan, anything else, those libraries talk into the device node directly in the applications process. 37 00:03:43,760 --> 00:03:48,240 So that means this device driver has to be exposed to the application. 38 00:03:48,340 --> 00:03:50,700 So no permission required. 39 00:03:50,700 --> 00:03:53,220 This is the biggest problem. 40 00:03:53,220 --> 00:03:56,460 And this is why researchers love GPU drivers. 41 00:03:57,220 --> 00:03:58,940 Next one. 42 00:03:59,300 --> 00:04:02,960 GPU driver performance is the key. 43 00:04:02,960 --> 00:04:07,760 And because of that, they need to have some powerful functions to do this. 44 00:04:07,980 --> 00:04:21,420 The most important one is that they usually have access to the system physical RAMs so that they can map memories from user space to kernel space and to the hardware without copying them. 45 00:04:21,520 --> 00:04:25,440 This is a very powerful primitive and attackers want that. 46 00:04:26,400 --> 00:04:29,860 We'll explain more later why it's powerful. 47 00:04:29,940 --> 00:04:38,160 And lastly, again, because of the performance requirement, this involves high complexity code in the GPU driver. 48 00:04:39,020 --> 00:04:44,300 And because of that, it's really, really hard to develop bug-free code. 49 00:04:44,300 --> 00:04:46,840 I'm not sure if anybody here writes bug-free code. 50 00:04:46,840 --> 00:04:48,500 Raise your hand if you did. 51 00:04:48,620 --> 00:04:50,560 Wow, very brave. 52 00:04:51,760 --> 00:04:55,360 Anyway, and it's even harder to fix an issue. 53 00:04:55,360 --> 00:05:00,740 And it's very common that you fix an issue, but it's not 100% fixed. 54 00:05:00,740 --> 00:05:02,880 There's still something left over. 55 00:05:02,880 --> 00:05:08,040 And even worse, you fix one issue, you introduce another new issue. 56 00:05:08,040 --> 00:05:09,360 Or two issues. 57 00:05:10,940 --> 00:05:15,840 So this high complexity is another reason one look into this area. 58 00:05:20,880 --> 00:05:23,320 Hello? 59 00:05:24,140 --> 00:05:26,240 Hello? 60 00:05:26,680 --> 00:05:27,900 Sorry. 61 00:05:27,900 --> 00:05:30,120 That's not your problem. 62 00:05:37,450 --> 00:05:42,380 Hello? 63 00:05:45,860 --> 00:05:47,440 Hello? 64 00:05:47,440 --> 00:05:49,480 I can use this one. 65 00:05:54,590 --> 00:05:57,970 Okay, we have issues, so we fix them. 66 00:05:59,850 --> 00:06:01,950 So, why Qualcomm? 67 00:06:01,950 --> 00:06:06,290 Qualcomm is one of the most important smartphone SoC vendors. 68 00:06:06,630 --> 00:06:09,890 And many devices use Qualcomm SoCs. 69 00:06:09,890 --> 00:06:14,170 And on those SoCs, Arduino GPU is the one used the most. 70 00:06:14,510 --> 00:06:24,010 And last one is, this applies to all GPUs, that GPU is a very actively developing area. 71 00:06:24,010 --> 00:06:31,450 Because of all the requirements, all the games keep having high resolutions, faster speed, faster FPS. 72 00:06:31,510 --> 00:06:37,750 So there's lots of development happening that involves revolutions in architecture. 73 00:06:37,750 --> 00:06:39,570 Hardware, software. 74 00:06:39,670 --> 00:06:46,970 And coincidentally, we noticed that there is a new architecture recently in the Qualcomm GPU. 75 00:06:46,970 --> 00:06:50,990 New architecture, new software means new bugs. 76 00:06:50,990 --> 00:06:56,370 So we want to take a look and see what's the difference and is there any issues there. 77 00:06:59,340 --> 00:07:13,620 And another study we did before we look into our source code, I mean, our Qualcomm source code, is to check the security bulletins and is there any historical issues. 78 00:07:13,980 --> 00:07:18,760 And here's a chart that we manually created from the Qualcomm security bulletin. 79 00:07:19,380 --> 00:07:25,600 The size of the bars might look a little bit scary, but you can see the numbers actually are single digits. 80 00:07:25,600 --> 00:07:36,260 So there's not a lot of issues, but my point here is that you can see this is more like constant issues happening every quarter. 81 00:07:36,420 --> 00:07:44,940 So this chart gives us a little bit of confidence that if we look into the code, we might as well find issues. 82 00:07:45,580 --> 00:07:52,240 Oh, by the way, I forgot to mention, all our work is based on open source Qualcomm drivers, so everything is public. 83 00:07:52,240 --> 00:07:54,700 There's no private information involved. 84 00:07:56,040 --> 00:08:03,900 Among all those issues, there are quite some high profile issues disclosed and talked by previous security researchers. 85 00:08:04,120 --> 00:08:09,000 These talks are great, and we learn a lot from the talks. 86 00:08:09,000 --> 00:08:14,600 Really big credit to them for helping us to jump into an area we've never looked at before. 87 00:08:16,740 --> 00:08:20,800 And now we look back into just the recent three months. 88 00:08:20,800 --> 00:08:26,840 Here are all the issues reported to Qualcomm security, disclosed by Qualcomm security bulletin. 89 00:08:27,740 --> 00:08:35,700 Our security researcher, Xilin, did a little bit of analysis and focused on the last two columns. 90 00:08:35,700 --> 00:08:41,800 You can see the tech area, mostly many of the issues are focusing on IOMMUs. 91 00:08:41,800 --> 00:08:47,060 That matches our previous assumption that physical memory is the key. 92 00:08:47,260 --> 00:08:55,980 And also, very subjective, but based on Xilin's experience, most of the issues are easy to exploit. 93 00:08:55,980 --> 00:09:00,300 And once exploited, they are pretty stable. 94 00:09:00,300 --> 00:09:02,160 Attackers want the stability. 95 00:09:02,160 --> 00:09:04,740 They want their code to be good. 96 00:09:06,460 --> 00:09:12,200 Over the course of our engagement, Xilin has identified more than nine issues. 97 00:09:12,860 --> 00:09:15,980 We report all the issues to Qualcomm immediately. 98 00:09:16,460 --> 00:09:20,680 And today we're going to talk about CVE-2024-23380. 99 00:09:20,680 --> 00:09:22,780 This is one of the issues we reported. 100 00:09:23,060 --> 00:09:28,780 This issue has been patched and published in the security bulletin of July 2024. 101 00:09:29,260 --> 00:09:35,320 And Qualcomm communicated to all the device vendors in April before the disclosure. 102 00:09:35,440 --> 00:09:38,620 So, go to the security bulletins. 103 00:09:38,620 --> 00:09:40,640 You can see what's affecting devices. 104 00:09:40,740 --> 00:09:45,180 But don't worry if your device is affected and check your security patch level. 105 00:09:45,180 --> 00:09:47,480 If it's July or later, it's fixed. 106 00:09:48,840 --> 00:09:56,400 And from here, I'll hand over to Xilin to talk about technical details and how we exploit to gain root privilege. 107 00:10:01,560 --> 00:10:03,520 Yeah, thank you, Xilin. 108 00:10:03,940 --> 00:10:13,280 So, I'll quickly introduce the basic knowledge of Andrino GPU. 109 00:10:13,320 --> 00:10:15,960 So, here is the basic architecture. 110 00:10:16,160 --> 00:10:24,620 You can see in the middle is the KGSL driver, which is the glue between the user space and the hardware. 111 00:10:24,620 --> 00:10:31,280 So, from the perspective of the user space, we will have a set of interfaces. 112 00:10:31,280 --> 00:10:42,960 The first one is the context, which is used to identify user space applications and also to manage the GPU driver or hardware resources. 113 00:10:43,000 --> 00:10:48,020 And also, the user space may want to share memory with the GPU hardware. 114 00:10:48,020 --> 00:10:50,300 So, we will have memory interfaces. 115 00:10:50,420 --> 00:10:52,380 There are three types of memory. 116 00:10:52,380 --> 00:10:56,320 The basic memory, the user space memory, the DMA memory. 117 00:10:56,320 --> 00:10:59,400 And previously, we also have the sparse memory. 118 00:10:59,400 --> 00:11:03,920 But now, this sparse memory is already not used anymore. 119 00:11:04,120 --> 00:11:09,900 And the user space also wants to send the customer GPU commands to the GPU hardware. 120 00:11:09,900 --> 00:11:13,320 So, we will have some command interfaces. 121 00:11:13,320 --> 00:11:18,420 And also, the user space wants to get synced with the GPU hardware. 122 00:11:18,420 --> 00:11:21,480 So, we will have synchronization interfaces. 123 00:11:21,480 --> 00:11:31,320 To accomplish these tasks in the GPU driver, we will have a command queue, which receives commands from the user space. 124 00:11:31,320 --> 00:11:44,380 And then, the software dispatcher will get the command from the queue and add the necessary information and maybe modify the GPU command and then send them to the RAM buffer. 125 00:11:44,860 --> 00:11:53,460 There is a simple firmware in the GPU hardware, which will receive commands from the RAM buffer and send the command to the hardware. 126 00:11:53,460 --> 00:11:57,960 So, GPU customer commands will be run in the GPU hardware. 127 00:11:57,960 --> 00:12:05,900 Also, we will have something like the global buffer, the registers to control the GPU hardware. 128 00:12:05,900 --> 00:12:16,920 For memory management, we will have memory pool and MMU for the user space memory and IOMMU for controlling the GPU memory. 129 00:12:16,920 --> 00:12:25,600 So, this is the new architecture starting from generation 7 and the later generation. 130 00:12:25,600 --> 00:12:30,420 You can see we have a lot of new stuff in red color. 131 00:12:30,420 --> 00:12:41,380 The most important change is the software dispatcher is replaced by the hardware scheduler, which means the GPU command comes from the user space. 132 00:12:41,380 --> 00:12:44,960 It will not be sent to the RAM buffer directly by the driver. 133 00:12:44,960 --> 00:12:48,400 The driver will not touch the RAM buffer anymore. 134 00:12:48,400 --> 00:12:54,960 Instead, the driver will send this command directly to a HiFi command queue. 135 00:12:54,960 --> 00:13:05,480 So, there is a simple firmware and this firmware will take over and finish the job previously finished by the driver. 136 00:13:05,480 --> 00:13:11,240 So, a lot of software dispatcher jobs will be moved to the firmware. 137 00:13:11,240 --> 00:13:13,680 So, we don't have the source code of the firmware. 138 00:13:13,680 --> 00:13:21,860 So, I can just guess that this job previously finished by the software dispatcher will move to the firmware. 139 00:13:21,860 --> 00:13:28,520 But how it works and whether there are any vulnerabilities, I have no idea now. 140 00:13:28,520 --> 00:13:37,140 And also, to coordinate with these new features, some other new features like the hardware fence is added. 141 00:13:37,140 --> 00:13:39,760 Previously, we only had the software fence. 142 00:13:39,760 --> 00:13:52,400 Now, we also have a hardware fence that will introduce a lot of new code, new features, and also a new hardware fence queue and new hardware fence event here. 143 00:13:52,400 --> 00:13:58,100 For the memory, we will have a new virtual buffer object. 144 00:13:58,100 --> 00:14:00,700 You can see here, this is a new VBO. 145 00:14:00,760 --> 00:14:06,540 And the previously ARM IOMMU will be replaced by the Qualcomm-owned IOMMU. 146 00:14:06,540 --> 00:14:18,040 So, these new features will, of course, enhance the GPU capability, but also will introduce a lot of new attack surfaces. 147 00:14:19,680 --> 00:14:27,100 If you want to look into some new vulnerability, you can start from the new features. 148 00:14:27,640 --> 00:14:30,640 Here, I'll also introduce the memory management. 149 00:14:30,720 --> 00:14:36,040 You can see here is the basic memory management called a basic memory object. 150 00:14:36,080 --> 00:14:44,920 So, it's used in most of the cases you want to share some memory to the GPU from the user space, you will request a basic memory object. 151 00:14:44,920 --> 00:14:48,240 It's a basic, so it's used in most of the cases. 152 00:14:48,240 --> 00:14:55,060 You call this our control, and you set a parameter to tell the driver how many physical pages you want. 153 00:14:55,060 --> 00:14:59,500 Then, the driver will allocate this number of physical pages for you. 154 00:14:59,540 --> 00:15:06,600 And then, the second step, the driver will allocate an address range in the GPU virtual address space. 155 00:15:06,600 --> 00:15:10,920 So, you can see here, we have this virtual GPU address. 156 00:15:11,120 --> 00:15:17,100 And then, the GPU driver will set this physical to virtual mapping for you. 157 00:15:17,100 --> 00:15:25,360 So, at this time, the GPU hardware will be able to access to the physical page using this GPU virtual address. 158 00:15:25,960 --> 00:15:31,700 And in most of the cases, the user space will also want to access to the physical page. 159 00:15:31,700 --> 00:15:37,140 So, the user space will do memory map on this basic memory object. 160 00:15:37,140 --> 00:15:45,620 And then, the driver will help you to set up the physical page to virtual mapping through the MMU. 161 00:15:45,620 --> 00:15:53,620 So, at this time, the physical page can be accessed from both the GPU hardware and the user space. 162 00:15:53,620 --> 00:15:55,560 So, that's the basic memory object. 163 00:15:55,560 --> 00:16:02,380 The driver will manage all the objects in the kernel and also manage the backend physical memory. 164 00:16:02,860 --> 00:16:05,740 And here is the second type of memory object. 165 00:16:05,740 --> 00:16:07,920 It's called the user space memory. 166 00:16:07,920 --> 00:16:21,120 So, suppose you already have a user space memory, you have a backend physical memory, you can use this user space memory object to import memory from the user space into the GPU hardware. 167 00:16:21,120 --> 00:16:24,560 And here is the third type of memory. 168 00:16:24,560 --> 00:16:26,520 It's called the virtual buffer object. 169 00:16:26,540 --> 00:16:32,120 From the name virtual, you may guess that it's virtual. 170 00:16:32,400 --> 00:16:39,220 So, for this type of memory, it doesn't have its own backend physical memory. 171 00:16:39,220 --> 00:16:42,380 So, you call this out control with this flag. 172 00:16:42,380 --> 00:16:48,020 Then, the driver will simply allocate a GPU virtual address for you. 173 00:16:48,020 --> 00:16:53,260 And then, it will map this virtual address to a dummy ZeroPage. 174 00:16:53,260 --> 00:16:55,160 So, it's a dummy ZeroPage. 175 00:16:55,160 --> 00:16:56,940 It's just a placeholder. 176 00:16:57,640 --> 00:17:03,880 Of course, you can access it to the virtual memory in the GPU hardware, but it's no effect. 177 00:17:03,880 --> 00:17:06,820 Whatever you read or write will have no effect. 178 00:17:06,820 --> 00:17:08,740 It's just a ZeroPage. 179 00:17:08,740 --> 00:17:10,080 It will have no effect. 180 00:17:10,080 --> 00:17:13,340 So, how to use this virtual buffer object? 181 00:17:13,340 --> 00:17:19,580 You can actually map a basic memory object into this VBO. 182 00:17:19,580 --> 00:17:24,620 So, suppose you already have two basic memory objects, A and B. 183 00:17:24,620 --> 00:17:28,360 Both of them have their own backend physical memory. 184 00:17:28,360 --> 00:17:32,640 You can bind these two basic memory objects into this VBO. 185 00:17:32,640 --> 00:17:35,240 So, you call this bindRangeOutControl. 186 00:17:35,240 --> 00:17:37,660 Then, the driver will do the work. 187 00:17:37,660 --> 00:17:42,540 The first step, the driver will remove any existing mapping from the VBO. 188 00:17:42,540 --> 00:17:46,200 Here, we already mapped the ZeroPage to the VBO. 189 00:17:46,200 --> 00:17:48,340 So, this mapping will be removed. 190 00:17:48,340 --> 00:17:57,200 If you have previously mapped any other basic memory object to this VBO, these maps will also be removed. 191 00:17:57,620 --> 00:18:02,840 So, the first step, we will remove any existing mapping from the VBO. 192 00:18:02,960 --> 00:18:09,960 And then, we will get a connection between this basic memory object and the VBO. 193 00:18:09,960 --> 00:18:13,340 So, the driver will know that there is a connection. 194 00:18:13,340 --> 00:18:16,360 Somebody is using this basic memory object. 195 00:18:16,360 --> 00:18:18,840 So, this object cannot be freed. 196 00:18:19,200 --> 00:18:25,200 And also, the driver will help you to find out the physical memory page of this basic memory object. 197 00:18:25,260 --> 00:18:29,680 And then, the driver will help you to set up this connection. 198 00:18:30,320 --> 00:18:33,900 So, you can see here is the physical memory to virtual mapping. 199 00:18:33,900 --> 00:18:40,980 We will map this physical page into the VBO's region at a specified offset. 200 00:18:41,420 --> 00:18:46,140 And also, the driver will continue these two steps. 201 00:18:46,140 --> 00:18:49,900 Find all the basic memory objects you want. 202 00:18:49,900 --> 00:18:54,580 And get all the connections between the basic memory object and the VBO. 203 00:18:54,580 --> 00:18:59,140 And then, map all the physical pages to this VBO. 204 00:18:59,140 --> 00:19:01,540 So, that's the basic memory object. 205 00:19:02,420 --> 00:19:04,420 Binding to the VBO. 206 00:19:04,420 --> 00:19:08,800 It's very powerful and flexible. 207 00:19:08,800 --> 00:19:11,480 But also, very vulnerable. 208 00:19:11,480 --> 00:19:16,960 You can see here we have this CVE-2024-23380. 209 00:19:16,960 --> 00:19:22,640 Which happens when you bind a basic memory object into a VBO. 210 00:19:22,640 --> 00:19:24,920 So, we will take a look at the code. 211 00:19:24,920 --> 00:19:32,520 You can see when we do the binding, we will get a connection between this basic memory object and the VBO. 212 00:19:32,520 --> 00:19:37,220 So, the connection is finished by this function, intervalTreeInsert. 213 00:19:37,220 --> 00:19:41,240 So, insert this basic memory object into the VBO. 214 00:19:42,200 --> 00:19:48,440 Then, we will get a physical page and virtual address mapping. 215 00:19:48,440 --> 00:19:52,120 We will set up this mapping using this function. 216 00:19:53,560 --> 00:19:54,680 MMUMapChild. 217 00:19:55,620 --> 00:20:00,900 So, of course, we will have to protect our global status. 218 00:20:00,980 --> 00:20:05,920 So, we will use this mutex lock to protect the intervalTree. 219 00:20:05,920 --> 00:20:09,400 So, this intervalTree is a global status. 220 00:20:09,520 --> 00:20:12,080 This will be protected by the lock. 221 00:20:12,080 --> 00:20:14,520 And when we finish, we will do unlock. 222 00:20:14,660 --> 00:20:17,240 And here, the vulnerabilities. 223 00:20:17,580 --> 00:20:21,440 This physical to virtual mapping is also a global resource. 224 00:20:21,440 --> 00:20:24,340 So, it should also be protected by the lock. 225 00:20:24,340 --> 00:20:28,880 But you can see here, this physical to virtual mapping is outside of the lock. 226 00:20:29,020 --> 00:20:33,300 So, it's possible from the driver's perspective. 227 00:20:33,400 --> 00:20:38,680 We already have this basic memory object connected to the VBO. 228 00:20:38,800 --> 00:20:44,860 When we do the physical to virtual mapping, this connection might be removed by somebody else. 229 00:20:44,860 --> 00:20:46,580 So, that's the vulnerability. 230 00:20:47,620 --> 00:20:49,540 Let's take a look at the fix. 231 00:20:49,540 --> 00:20:55,860 You can see the fix simply moves this physical to virtual mapping inside of the lock. 232 00:20:55,860 --> 00:20:57,940 It's very simple fix. 233 00:20:57,940 --> 00:21:00,600 It just protects this mapping. 234 00:21:00,800 --> 00:21:03,480 So, that's the vulnerability. 235 00:21:03,480 --> 00:21:06,560 Let's take a look at how to trigger this vulnerability. 236 00:21:06,700 --> 00:21:08,520 We will need two threads. 237 00:21:08,520 --> 00:21:11,660 One to the mapping, to the binding. 238 00:21:11,660 --> 00:21:14,380 Binding a basic memory object to the VBO. 239 00:21:14,380 --> 00:21:18,000 And at the same time, somebody else to the unbinding. 240 00:21:18,000 --> 00:21:19,480 So, look at the code. 241 00:21:19,480 --> 00:21:23,720 You can see when do the binding, we are getting into this add range. 242 00:21:23,720 --> 00:21:26,200 This is the function we just read. 243 00:21:26,200 --> 00:21:27,980 You can see we have the lock. 244 00:21:27,980 --> 00:21:33,300 We will insert the basic memory object into the VBO. 245 00:21:33,300 --> 00:21:35,840 Then we unlock and do the physical mapping. 246 00:21:35,980 --> 00:21:39,160 And another thread to the unbinding. 247 00:21:39,360 --> 00:21:42,760 You can see it's just the reverse of the binding. 248 00:21:42,760 --> 00:21:44,200 You will have a lock. 249 00:21:44,200 --> 00:21:48,920 And then you remove the binding. 250 00:21:48,920 --> 00:21:50,640 And then you do the unlock. 251 00:21:51,320 --> 00:21:54,380 So, here is how we trigger the vulnerability. 252 00:21:54,380 --> 00:21:55,400 We have two threads. 253 00:21:55,400 --> 00:21:58,300 Thread A running and lock. 254 00:21:58,300 --> 00:22:02,320 And then onto the tree insert and do the unlock. 255 00:22:03,600 --> 00:22:07,140 And at the same time, we can run thread B. 256 00:22:07,140 --> 00:22:10,800 Because it's unlock, so the thread B can run in. 257 00:22:10,800 --> 00:22:14,580 Then we get the lock removed and unlock. 258 00:22:14,580 --> 00:22:17,000 And finally, we do the mapping. 259 00:22:17,040 --> 00:22:21,520 So, here is the detailed vulnerability. 260 00:22:21,780 --> 00:22:23,400 We run thread A. 261 00:22:23,400 --> 00:22:25,360 We acquire the mutex. 262 00:22:25,360 --> 00:22:26,320 Then we connect. 263 00:22:26,320 --> 00:22:29,100 You can see this connection is set up. 264 00:22:29,100 --> 00:22:34,220 So, we connect the basic memory object to the VBO and release the lock. 265 00:22:34,220 --> 00:22:36,380 Then we get to thread B. 266 00:22:36,380 --> 00:22:39,040 Thread B also acquires the same mutex. 267 00:22:39,040 --> 00:22:44,760 And you can see this connection between the basic memory object and the VBO is removed. 268 00:22:44,760 --> 00:22:47,240 So, this is thread B. 269 00:22:47,240 --> 00:22:50,260 Unbinding and release the mutex. 270 00:22:50,580 --> 00:22:53,620 Then we get back to thread A. 271 00:22:53,620 --> 00:23:00,040 The thread A will map the victim's physical page to this virtual address. 272 00:23:00,040 --> 00:23:10,500 So, from the driver's perspective, the basic memory object already has no connection with the VBO. 273 00:23:10,500 --> 00:23:12,060 So, it can be freed. 274 00:23:12,060 --> 00:23:16,060 So, we can delete the basic memory object in the driver. 275 00:23:16,060 --> 00:23:21,220 So, all the resources related with this basic memory object will be freed. 276 00:23:21,220 --> 00:23:23,440 As well as the backend physical memory. 277 00:23:23,440 --> 00:23:26,000 You can see this page has been freed. 278 00:23:26,000 --> 00:23:33,020 By the connection here, the connection between the physical memory and the virtual address is still mapped. 279 00:23:33,040 --> 00:23:34,460 So, it's still there. 280 00:23:34,460 --> 00:23:35,740 That's the vulnerability. 281 00:23:35,780 --> 00:23:41,080 So, we have run this code sequence and triggered the vulnerability. 282 00:23:44,160 --> 00:23:48,240 It's a physical page used after free. 283 00:23:48,240 --> 00:23:52,100 So, we can read and write to free the physical page. 284 00:23:52,100 --> 00:23:59,200 You can read and write to this free the physical page from the GPU's virtual address. 285 00:23:59,320 --> 00:24:01,940 And also, it's a worst condition issue. 286 00:24:02,240 --> 00:24:07,720 We require the two threads to bind and unbind at the same time. 287 00:24:08,720 --> 00:24:13,300 And here, let's summarize the exploit primitive. 288 00:24:13,300 --> 00:24:16,140 We have a physical page used after free. 289 00:24:16,140 --> 00:24:18,900 We return this physical virtual mapping. 290 00:24:18,900 --> 00:24:23,140 So, we can access free the physical page. 291 00:24:23,140 --> 00:24:26,120 And this vulnerability is pretty stable. 292 00:24:26,500 --> 00:24:36,100 Usually, when we trigger used after free issue or worst condition issue, we have to trigger it multiple times. 293 00:24:36,100 --> 00:24:44,680 So, it's very dangerous to trigger this issue because it will cause the system status, you know, wrong status, maybe crash the kernel. 294 00:24:44,680 --> 00:24:46,740 But this issue is pretty stable. 295 00:24:46,740 --> 00:24:53,640 You can trigger it multiple times without worrying about it fails or causing any crash. 296 00:24:53,640 --> 00:25:00,080 And also, we have a method to get a feedback whether this issue is triggered or not. 297 00:25:00,080 --> 00:25:03,030 If it's not triggered, we will get this feedback. 298 00:25:03,300 --> 00:25:10,560 And if it's triggered, then we know the result so that we can know exactly how many pages we have controlled. 299 00:25:10,560 --> 00:25:13,460 This will make our exploit more stable. 300 00:25:13,460 --> 00:25:15,600 And this issue is pretty easy to trigger. 301 00:25:16,600 --> 00:25:24,320 Without any special tricks, you don't have to adjust the thread priority or add more entries to the list. 302 00:25:24,320 --> 00:25:27,400 You can easily trigger this issue. 303 00:25:27,400 --> 00:25:32,480 So , this is a pretty nice exploit primitive. 304 00:25:32,680 --> 00:25:38,660 So, so far, we have tricked the vulnerability. 305 00:25:38,660 --> 00:25:43,280 We have controlled a lot of physical memory pages. 306 00:25:43,280 --> 00:25:47,520 The question becomes the following question. 307 00:25:47,520 --> 00:25:51,920 Suppose we already controlled a large amount of physical memory page. 308 00:25:51,920 --> 00:25:53,300 What are we going to do? 309 00:25:53,300 --> 00:25:58,120 There are lots of answers and solutions for an experienced kernel hacker. 310 00:25:58,120 --> 00:26:06,520 For example, we can supply lots of this structure created into the kernel heap and then modify the UID and GID. 311 00:26:06,520 --> 00:26:12,960 We can also supply lots of structure file and then modify the file permission. 312 00:26:12,960 --> 00:26:17,660 And also, we can use this kernel-based memory mirroring attack. 313 00:26:17,660 --> 00:26:23,520 So, we can modify and control the GPU page table and then do the mirroring. 314 00:26:24,060 --> 00:26:27,140 Here, we will introduce our new method. 315 00:26:27,220 --> 00:26:33,600 So, we are spraying structure KGS memory description. 316 00:26:34,280 --> 00:26:41,220 So, you can see on the right, we are spraying this structure KGS memory entry. 317 00:26:41,220 --> 00:26:44,640 It contains the target structure we want to spray. 318 00:26:44,640 --> 00:26:47,180 It contains the memory description structure. 319 00:26:47,180 --> 00:26:49,720 Also, it contains metadata. 320 00:26:49,940 --> 00:26:55,480 And for this memory description, we can see it has a physical address and a size. 321 00:26:55,560 --> 00:26:58,160 So, why are we using this method? 322 00:26:58,160 --> 00:27:00,880 The first reason is that it is easy to spray. 323 00:27:00,880 --> 00:27:05,220 You can simply call this GPU allocator control. 324 00:27:05,220 --> 00:27:09,360 Then, you can spray a large amount of this structure in the kernel. 325 00:27:09,360 --> 00:27:15,340 And also, because we have this metadata, this is fully controlled by the user space. 326 00:27:15,340 --> 00:27:22,040 So, the user space can set a unique metadata so that you can find it easily in the memory. 327 00:27:22,440 --> 00:27:25,620 And it's easy to use and very useful. 328 00:27:25,940 --> 00:27:33,660 You can spray this structure and then modify the physical address and then do memory map in the user space. 329 00:27:33,660 --> 00:27:39,460 When you do memory map, you will be able to map the physical address to user space. 330 00:27:39,460 --> 00:27:45,660 And also, if you check the result of the memory map, then you know whether your exploit is working or not. 331 00:27:45,660 --> 00:27:50,880 So, you can easily know how the exploit works. 332 00:27:51,240 --> 00:27:53,460 And there's one extra bonus. 333 00:27:53,460 --> 00:27:57,900 It's possible you use this method to bypass the KSR directly. 334 00:27:57,900 --> 00:28:03,020 Even if you don't have a KSR, you can use this method to bypass the KSR. 335 00:28:03,020 --> 00:28:04,980 We will discuss this later. 336 00:28:05,540 --> 00:28:11,240 Now, suppose we already have a physical page controlled. 337 00:28:11,240 --> 00:28:13,560 Like this, we control this physical page. 338 00:28:13,560 --> 00:28:27,880 And in this page, we have our package structure, memory entry, which contains the metadata, so that we can find this metadata and then we find this memory description structure. 339 00:28:27,880 --> 00:28:35,180 In this structure, it will have a physical address and a size and ops. 340 00:28:35,180 --> 00:28:37,420 We will modify these three fields. 341 00:28:37,420 --> 00:28:45,420 We will modify the physical address of the kernel and the size to the kernel size. 342 00:28:45,420 --> 00:28:52,040 And also, we will modify the ops from the KSR ops to this continuous ops. 343 00:28:52,800 --> 00:28:56,940 While we modify these ops, look at the new ops. 344 00:28:56,940 --> 00:28:59,060 You can see it has a VM folder. 345 00:28:59,060 --> 00:29:01,040 This is used when we do... 346 00:29:10,860 --> 00:29:19,560 We will modify these ops and get a new continuous ops, which contains a new VM folder. 347 00:29:19,560 --> 00:29:33,040 So when the user space do memory mapping on this memory object, it will get a user space virtual address, which the user space can access to the virtual address. 348 00:29:33,040 --> 00:29:43,600 But at the first time, when the user space access to the address, because the physical to virtual mapping is not set up yet, so it will get into a VM folder. 349 00:29:43,600 --> 00:29:48,380 So the driver will get into the VM folder to set up the physical to virtual mapping. 350 00:29:48,380 --> 00:29:49,680 And look at the code. 351 00:29:49,680 --> 00:29:52,100 You can see this mapping is quite simple. 352 00:29:52,100 --> 00:29:55,640 It just gets the physical address we just modified. 353 00:29:55,640 --> 00:30:02,580 So it will use the physical address we want and then map this physical address to the user space. 354 00:30:02,580 --> 00:30:15,020 So if we modify this physical address to the kernel physical address, then the kernel memory will be mapped to the user space, so we can do arbitrary read-write to the kernel memory. 355 00:30:15,020 --> 00:30:23,060 So that's why we use this structure memory description and how the exploit works. 356 00:30:23,520 --> 00:30:26,320 Let's summarize the exploitation. 357 00:30:26,320 --> 00:30:31,520 So we trigger the vulnerability, and then we get a controlled physical page. 358 00:30:31,520 --> 00:30:38,880 We repeat this step 200 times, then we get 200 physical pages controlled. 359 00:30:38,880 --> 00:30:41,660 Then we can get to the next step. 360 00:30:41,660 --> 00:30:45,960 We can force the system memory into a low memory status. 361 00:30:45,960 --> 00:30:55,320 So all the kernel memory, all the caches will be returned to the system, including the physical pages that we controlled. 362 00:30:55,320 --> 00:31:00,540 So the 200 pages will also be returned to the kernel. 363 00:31:00,940 --> 00:31:02,740 Then we get to the next step. 364 00:31:02,740 --> 00:31:07,300 We do kernel heap spray using the structure we just described. 365 00:31:07,300 --> 00:31:14,160 So if we are lucky, some of the entries will be located in the controller page. 366 00:31:14,160 --> 00:31:25,220 So we can find these structures in the controller page using the metadata we just set. 367 00:31:25,220 --> 00:31:31,740 So we can scan the controller memory and find the structure, and then we get this structure. 368 00:31:31,740 --> 00:31:40,220 You can see on the right, we get the memory description structure, which contains the physical address set and the ops we want to modify. 369 00:31:40,220 --> 00:31:45,500 And here, one thing you can see, the ops is a pointer. 370 00:31:45,500 --> 00:31:49,720 It's pointing to something in the kernel memory. 371 00:31:49,720 --> 00:31:55,960 So if we read this ops out, then we can get the KSL information. 372 00:31:55,960 --> 00:32:00,920 So in our exploit, we bypass the KSL at this step. 373 00:32:00,920 --> 00:32:05,480 So we can bypass the KSL here, and then get to the next step. 374 00:32:05,480 --> 00:32:10,640 We can modify the physical address, modify the size, modify the ops. 375 00:32:10,760 --> 00:32:16,660 We will modify the physical address to the kernel physical address, and the size to the kernel size. 376 00:32:16,660 --> 00:32:21,000 Then finally, we can map the whole kernel memory to the user space. 377 00:32:21,000 --> 00:32:25,220 Then we can do arbitrary read-write to the kernel memory in the user space. 378 00:32:25,300 --> 00:32:27,520 So that's the exploit. 379 00:32:28,440 --> 00:32:34,140 We can actually expand this method to a more generic case. 380 00:32:34,140 --> 00:32:47,300 Suppose you have a kernel heap buffer overflow, or you have a risk condition issue, you can also use this method to make your exploit easier. 381 00:32:47,440 --> 00:32:56,500 The first step, you can spray a large amount of this memory descript into the kernel heap, and then you trigger your vulnerability. 382 00:32:56,500 --> 00:33:05,280 Suppose you have a kernel heap overflow issue, you can overflow it from here into this ops. 383 00:33:05,280 --> 00:33:09,760 Then you can control the physical address and ops. 384 00:33:09,760 --> 00:33:14,580 And then you can try to do memory map on this memory object. 385 00:33:15,060 --> 00:33:22,600 If you are lucky, you succeed, then you can map the whole kernel physical memory to the user space. 386 00:33:22,600 --> 00:33:27,320 But if you are not lucky, you can try it again and again until you succeed. 387 00:33:27,380 --> 00:33:32,320 So that's how we expand this method to a more generic case. 388 00:33:32,520 --> 00:33:39,580 And maybe you remember we have a bonus, which we can bypass the case using this method. 389 00:33:39,580 --> 00:33:42,800 So look at the structure carefully. 390 00:33:42,800 --> 00:33:51,240 You may find that there are lots of kernel points, like the page table is a pointer and the host PTR. 391 00:33:51,240 --> 00:33:53,320 And also we have the HTTP. 392 00:33:53,320 --> 00:33:58,280 You might think, oh, we will need to get KSR information first. 393 00:33:58,280 --> 00:34:03,560 We have to point this point to a digital address. 394 00:34:03,560 --> 00:34:16,000 But in fact, you don't have to worry about this field, because in most of the cases, if you don't call some special R control by yourself, these fields are not used in most of the cases. 395 00:34:16,000 --> 00:34:22,560 So you can just overwrite these fields with a capital value or whatever you want. 396 00:34:22,560 --> 00:34:27,720 You can just overwrite the page table, the host PTR, and the GPU address. 397 00:34:27,720 --> 00:34:29,720 All this stuff is not used. 398 00:34:30,580 --> 00:34:36,200 The only thing you care about is the physical address, the size, and the ops. 399 00:34:36,200 --> 00:34:39,000 You might all think, oh, here we have the ops. 400 00:34:39,000 --> 00:34:40,780 It's also a pointer. 401 00:34:40,780 --> 00:34:46,880 So you have to know the original value, or you have to know the ASR information. 402 00:34:46,900 --> 00:34:51,820 But actually, no, you don't have to know the KSR information. 403 00:34:51,820 --> 00:34:54,180 You look at the original value carefully. 404 00:34:54,180 --> 00:35:00,540 You can see this is the original value, and this is the target value we want to modify. 405 00:35:01,140 --> 00:35:05,100 You can see that the high bytes are actually the same. 406 00:35:05,260 --> 00:35:06,560 Why are they the same? 407 00:35:06,560 --> 00:35:10,780 Because the KSR is based on the page. 408 00:35:10,780 --> 00:35:12,080 It's page-based. 409 00:35:12,080 --> 00:35:20,480 So if the two function points are in the same page, so they have the same high bytes that are in the same page. 410 00:35:20,480 --> 00:35:22,800 So all these bytes are the same. 411 00:35:22,800 --> 00:35:29,840 So you can actually ignore these bytes and overwrite from the beginning to the lowest byte, overwrite it to here. 412 00:35:29,840 --> 00:35:32,920 Then you don't have to care about the KSR. 413 00:35:32,920 --> 00:35:35,500 So that's how we bypass the KSR. 414 00:35:35,500 --> 00:35:41,720 And one thing here, you can see the lowest byte is already known from the kernel firmware. 415 00:35:41,720 --> 00:35:45,580 So you don't have to acquire additional information. 416 00:35:45,580 --> 00:35:49,620 You can bypass the KSR and get the expert working. 417 00:35:49,620 --> 00:35:54,760 You just overwrite to the lowest byte and ignore the high bytes. 418 00:35:55,620 --> 00:35:57,960 Yeah, that's how we bypass KSR. 419 00:35:57,960 --> 00:36:01,220 And in some cases, maybe you are not so lucky. 420 00:36:01,220 --> 00:36:04,300 You get the following situation. 421 00:36:04,300 --> 00:36:09,280 You can see it's not in the same page, but in the source code, they are near each other. 422 00:36:09,280 --> 00:36:15,160 So in most of our case, the original value is near the target value. 423 00:36:15,160 --> 00:36:18,160 So it's just like a 4-bit difference. 424 00:36:18,160 --> 00:36:21,420 So for 4-bit, it's just a 16 possibility. 425 00:36:21,420 --> 00:36:23,720 You can try 16 times. 426 00:36:23,720 --> 00:36:27,140 So you can undo the brute force for 16 times. 427 00:36:27,140 --> 00:36:29,080 Then you can bypass the KSR. 428 00:36:29,080 --> 00:36:33,400 So that's how we bypass the KSR and that's the exploit. 429 00:36:33,400 --> 00:36:36,720 Okay, we'll get to the demo. 430 00:36:36,960 --> 00:36:38,620 The demo is online. 431 00:36:38,620 --> 00:36:41,840 You can view the demo online. 432 00:36:41,840 --> 00:36:43,620 Also, we'll play it here. 433 00:36:43,620 --> 00:36:46,800 You can see here. 434 00:36:46,800 --> 00:37:01,560 When we record this demo, we are recording it on a pretty famous smartphone using the latest Qualcomm SoC, using Snapdragon generation 8 with the latest security patching. 435 00:37:02,660 --> 00:37:05,220 We'll start with the share user. 436 00:37:05,220 --> 00:37:08,160 Of course, you can also use the uncharged application user. 437 00:37:08,160 --> 00:37:09,660 There's no difference. 438 00:37:09,720 --> 00:37:11,960 So we are trying to get a load share. 439 00:37:12,360 --> 00:37:17,020 Of course, we don't have a load privilege now, so this fails. 440 00:37:17,100 --> 00:37:19,220 So we will start our exploit. 441 00:37:19,320 --> 00:37:26,240 And the first step is to trigger the vulnerability and control a large amount of physical pages. 442 00:37:26,400 --> 00:37:29,080 So we trigger the vulnerability again and again. 443 00:37:29,080 --> 00:37:32,660 And here we think we have enough pages. 444 00:37:33,300 --> 00:37:37,180 So now you can see we have controlled enough physical pages. 445 00:37:37,180 --> 00:37:39,120 Then we go to the next step. 446 00:37:39,120 --> 00:37:41,680 We trigger a system no memory. 447 00:37:41,680 --> 00:37:45,380 We allocate a lot of memory from the user space. 448 00:37:45,400 --> 00:37:53,560 So all the cached memory or the system memory unused system memory will be returned to the kernel. 449 00:37:53,660 --> 00:37:55,980 So we can do heap spray. 450 00:37:55,980 --> 00:37:59,740 We create a lot of these VBO entries. 451 00:38:00,020 --> 00:38:01,800 And then we are lucky. 452 00:38:01,800 --> 00:38:06,820 Some of the VBO entries will be located in the controller page. 453 00:38:06,820 --> 00:38:09,460 So we scan the controller page. 454 00:38:09,460 --> 00:38:13,920 And then we can find this controller object. 455 00:38:13,920 --> 00:38:18,820 You can see we found one controlled memory description object. 456 00:38:18,820 --> 00:38:23,520 So this object has a physical address, size, and ops we want. 457 00:38:23,520 --> 00:38:27,660 So we can patch this structure. 458 00:38:27,800 --> 00:38:30,580 The ops will modify the physical address. 459 00:38:30,580 --> 00:38:36,440 You can see this A801 is actually the kernel physical address. 460 00:38:36,440 --> 00:38:38,320 And the size is the kernel size. 461 00:38:38,320 --> 00:38:41,700 So we have patched the structure. 462 00:38:41,700 --> 00:38:47,220 And now we can map this structure to the user space. 463 00:38:47,220 --> 00:38:50,700 So we can map the whole kernel memory to the user space. 464 00:38:50,700 --> 00:38:53,280 And patch the kernel memory. 465 00:38:53,280 --> 00:38:55,660 Here we have patched the kernel version. 466 00:38:55,740 --> 00:38:59,300 And also we patched some of the code in the kernel. 467 00:38:59,300 --> 00:39:00,840 So we can get a root. 468 00:39:00,840 --> 00:39:03,900 So you can see now we are the root user. 469 00:39:04,200 --> 00:39:05,560 So that's the demo. 470 00:39:09,500 --> 00:39:10,880 Thank you. 471 00:39:10,880 --> 00:39:13,680 I will transfer to Eugene for the next content. 472 00:39:14,760 --> 00:39:16,320 Thank you very much, Shiling. 473 00:39:16,320 --> 00:39:21,500 And with that, I will be speaking about the last section of this presentation. 474 00:39:21,500 --> 00:39:23,200 How we found this vulnerability. 475 00:39:23,340 --> 00:39:28,160 Which methodology is applicable when you are doing bug hunting for GPU kernel modules. 476 00:39:28,160 --> 00:39:35,500 And what we can do to improve security of the GPU in the mobile space. 477 00:39:35,520 --> 00:39:40,780 Well, first of all, we identified this vulnerability via manual code review when we were doing patch analysis. 478 00:39:40,780 --> 00:39:47,300 And by patch analysis, essentially we use a collective term where we look at the security fixes. 479 00:39:47,540 --> 00:39:50,700 Which are published in the Android Qualcomm security bulletin. 480 00:39:50,700 --> 00:39:54,980 We also look at the security research published by other security researchers. 481 00:39:55,140 --> 00:39:58,780 And this is very important for such complex cases and big targets such as GPU. 482 00:39:59,120 --> 00:40:00,740 Because the state is very big. 483 00:40:00,740 --> 00:40:04,580 And as Shiling explained earlier in this presentation, there is a lot of moving parts. 484 00:40:04,580 --> 00:40:18,400 In order to have a holistic understanding, it's important to read others' blog reports to better understand the domain in this area. 485 00:40:18,400 --> 00:40:25,660 Originally, we wanted to put on the slide a very cool chain of vulnerabilities which we did variant analysis for. 486 00:40:25,660 --> 00:40:29,800 So, for example, Qualcomm internally identified one of the issues. 487 00:40:29,800 --> 00:40:32,160 They published a fix in their security bulletin. 488 00:40:32,160 --> 00:40:35,660 Then a security researcher looked at this fix. 489 00:40:35,940 --> 00:40:39,080 They found another related issue in this area. 490 00:40:39,080 --> 00:40:42,200 They wrote a blog post and published it. 491 00:40:42,200 --> 00:40:51,340 While looking at these two fixes by Qualcomm and the security researcher, we managed to identify another problem in the related area. 492 00:40:51,340 --> 00:41:02,180 But later we decided to remove this information because the issue might still be under remediation and not to tip off the folks working on the other side of the fence. 493 00:41:02,220 --> 00:41:08,300 We decided to put this quote here, which I think reflects the idea which we would like to convey in the slide. 494 00:41:10,260 --> 00:41:13,800 While speaking about methodologies, we cannot skip fuzzing. 495 00:41:13,800 --> 00:41:16,980 Because fuzzing is one of the essential methodologies we use. 496 00:41:16,980 --> 00:41:24,420 This is one of the most efficient and productive ways of finding bugs in the modern complicated software and the firmware. 497 00:41:24,540 --> 00:41:29,720 And there is a lot of benefits, I think, quite obvious for fuzzing. 498 00:41:29,720 --> 00:41:35,800 So on this slide, particularly, we will focus on challenges applicable to fuzzing GPU targets. 499 00:41:37,880 --> 00:41:43,700 And think about how can we overcome those or how can we solve them. 500 00:41:43,700 --> 00:41:53,780 So first of all, to enable efficient fuzzing of the GPU drivers, there is a lot of dependence on the hardware. 501 00:41:53,780 --> 00:41:58,620 As we have seen, this particular vulnerability is in the misconfiguration of the IOMMU. 502 00:41:58,620 --> 00:42:03,580 So in order to theoretically find this vulnerability, we would need to do on-device fuzzing. 503 00:42:03,580 --> 00:42:08,220 And although this is possible, this makes fuzzing a little bit less scalable. 504 00:42:08,220 --> 00:42:15,680 Because we would actually need to run it on the hardware versus, let's say, pure software fuzzing, which can scale with the number of the fuzzing cores. 505 00:42:15,900 --> 00:42:21,700 This is not a limitation, but this is one of the interesting observations. 506 00:42:21,700 --> 00:42:29,540 Because I know that there are some other GPU vendors which enable building their kernel-mode components in the architecture-independent way. 507 00:42:29,540 --> 00:42:39,980 So basically, there is a separation between software and hardware logic, so it's possible to build driver and run it without the hardware. 508 00:42:39,980 --> 00:42:45,320 To be able to test and fuzz the generic functionality implemented in the software. 509 00:42:45,420 --> 00:42:49,740 And another approach is using the emulation-based fuzzing to have an emulator for that. 510 00:42:49,740 --> 00:42:56,960 But I guess this is a little bit more complicated approach, because this requires manual work in order to understand how the hardware actually works. 511 00:42:56,960 --> 00:43:03,220 In order to be able to emulate it in the emulator. 512 00:43:03,700 --> 00:43:09,160 This particular issue was identified in the MMU and IUMMU domain. 513 00:43:09,160 --> 00:43:13,980 And this is actually a very common pattern in the GPU bugs reported these days. 514 00:43:13,980 --> 00:43:18,880 Where the physical pages for the backend storage are released back to the kernel. 515 00:43:18,920 --> 00:43:29,040 While at the same time there is a mapping in the IUMMU for the GPU which maps these released pages back to the virtual address space of the GPU. 516 00:43:29,060 --> 00:43:32,700 And this is very difficult to detect with fuzzing, because this doesn't lead to any crash. 517 00:43:32,700 --> 00:43:45,700 Even if we are lucky enough to hit the race condition here, still there is no sanitizers which would report us that, hey, you have dangling MMU entries in the page tables. 518 00:43:45,720 --> 00:43:46,840 This is one thing. 519 00:43:46,840 --> 00:43:52,080 Probably manual instrumentation of the driver with such checks would help. 520 00:43:52,240 --> 00:43:55,220 But again, this is manual work which makes it less scalable. 521 00:43:55,400 --> 00:43:57,820 GPU has a very complicated state machine. 522 00:43:57,820 --> 00:44:09,600 As we've seen, there is multiple components and sometimes in order to hit certain functions we would need to have a set of syscalls executed in a very precise sequence. 523 00:44:09,600 --> 00:44:16,020 Or if we're speaking about fuzzing with syscaller, probably this is additional custom syscalls which needs to be written for that. 524 00:44:16,020 --> 00:44:22,200 And of course, fuzzing concurrent code is not straightforward. 525 00:44:23,340 --> 00:44:29,780 Because there are some problems with reproducing and problems with hitting those vulnerabilities. 526 00:44:32,320 --> 00:44:36,420 Probably the final slide before we wrap it up, the ultimate mitigations question mark. 527 00:44:36,420 --> 00:44:37,240 Why question mark? 528 00:44:37,240 --> 00:44:43,060 Because, well, I guess suggesting mitigations for GPU is really not straightforward. 529 00:44:43,060 --> 00:44:51,460 And this is more about thinking employees about how can we make GPU security better in the mobile space. 530 00:44:51,460 --> 00:44:58,500 First of all, one of the major points why GPU is so attractive is because it is widely accessible to untrusted code. 531 00:44:58,740 --> 00:45:04,180 Because the untrusted code can directly open the driver and send arbitrary data to it. 532 00:45:04,340 --> 00:45:10,240 Android is very known for using IPC and binder in order to isolate components. 533 00:45:10,240 --> 00:45:15,560 So maybe one of the ideas is to move GPU from in-process hull into the out-of-process hull. 534 00:45:15,560 --> 00:45:20,280 I know this will impact performance and performance is very important for GPU. 535 00:45:20,280 --> 00:45:24,320 This might create some backward compatibility issues, but this is one of the ideas to think about. 536 00:45:24,360 --> 00:45:42,900 And additionally, the usage of memory-safe languages in the driver, I think, based on our experience, they might mitigate the majority of root causes, which lead to problems such as integer overflows, or in this particular case, integer race conditions. 537 00:45:43,820 --> 00:45:47,380 And I think with that, we hit almost the end of our time. 538 00:45:47,380 --> 00:45:50,140 And last slide, thank you very much for your attention. 539 00:45:50,160 --> 00:45:52,720 A small, shameless marketing plug. 540 00:45:52,720 --> 00:45:58,760 Here we have our Android offset with Google.com, where we publish our security research. 541 00:45:59,220 --> 00:46:08,780 And with that, yeah, I think we're happy to take any questions here on stage or offline using this contact information here. 542 00:46:08,780 --> 00:46:09,780 Thank you very much.