The Linux kernel makes considerable use of Berkeley Packet Filter (BPF) to allow user-written BPF applications to execute in the kernel space. BPF employs a verifier to statically check the security of user-supplied BPF code. Recent attacks show that BPF programs can evade security checks and gain unauthorized access to kernel memory, indicating that the verification process is not flawless. In this paper, we present MOAT, a system that isolates potentially malicious BPF programs using Intel Memory Protection Keys (MPK). Enforcing BPF program isolation with MPK is not straightforward; MOAT is carefully designed to alleviate technical obstacles, such as limited hardware keys and supporting a wide variety of kernel BPF helper functions. We have implemented MOAT in a prototype kernel module, and our evaluation shows that MOAT delivers low-cost isolation of BPF programs under various real-world usage scenarios, such as the isolation of a packet-forwarding BPF program for the memcached database with an average throughput loss of 6%.
翻译:Linux内核广泛使用Berkeley包过滤器(BPF)允许用户编写的BPF应用程序在内核空间执行。BPF通过一个验证器静态检查用户提供的BPF代码的安全性。最近的攻击表明,BPF程序能够绕过安全检查并获取对内核内存的未授权访问,这表明验证过程并非无懈可击。在本文中,我们提出MOAT,一个利用英特尔内存保护密钥(MPK)隔离潜在恶意BPF程序的系统。使用MPK实施BPF程序隔离并非易事;MOAT经过精心设计以缓解技术障碍,例如有限的硬件密钥以及对多种内核BPF辅助函数的支持。我们在一个原型内核模块中实现了MOAT,评估表明,在多种真实世界使用场景下(例如隔离用于memcached数据库的数据包转发BPF程序,平均吞吐量损失为6%),MOAT能够以低成本实现BPF程序的隔离。