ZenHammer:Rowhammer 对基于 AMD Zen 的平台进行攻击
ZenHammer: Rowhammer attacks on AMD Zen-based platforms

原始链接: https://comsec.ethz.ch/research/dram/zenhammer/

本文讨论了一个研究小组关于 AMD Zen 2 和 Zen 3 系统中与 Rowhammer 攻击相关的漏洞的调查结果。 尽管 AMD 之前已经实施了 TRR 缓解措施来防范此类攻击,但研究人员发现,它们在这些平台上仍然容易受到 Rowhammer 的影响,从而增加了攻击面,因为 AMD 占据 x86 桌面 CPU 约 36% 的市场份额。 他们证明,他们可以在 Zen 2 和 Zen 3 系统上触发大量位翻转,并从早期作品中构建各种漏洞,平均需要 164、267 或 209 秒。 为了发现这些漏洞,该团队采用了 DRAMA 技术来反转秘密 DRAM 地址功能。 一个重要的发现是,由于系统地址重新映射,需要将物理偏移应用于物理地址,以有效检索 DRAM 地址功能。 使用这些地址函数,在 AMD Zen 2 和 Zen 3 上测试的 10 台设备中,分别有 5 台和 0 台的位翻转次数大大减少。 最初,科学家们探索了刷新同步方面,发现连续定时测量通过非重复行在 AMD 上产生了准确且可靠的刷新同步。 通过改进的刷新同步,他们发现了特定的指令序列,这些指令序列导致 AMD Zen+/3 系统上与 Intel Coffee Lake 系统上的非均匀 rowhammer 模式的激活率异常低。 实验表明,在攻击者访问(“分散”样式)后立即进行缓存刷新的 CLFLUSHOPT 常规加载可以优化这些系统。 此外,研究人员还检查了各种栅栏类型和调度策略对 AMD Zen 系统中 Rowhammer 模式的影响。 通过实施六种不同的模式感知和缓存无关的调度策略,他们发现 SP_none 对于 Zen 2 上的大多数设备来说是理想的,而 SP_pair 最适合 Zen 3。 该研究随后评估了来自领先制造商的 10 款 DDR4 DRAM 设备,结果显示,十分之七的 Zen 2 设备和十分之六的 Zen 3 设备在测试时经历了位翻转——考虑到 Rowhammer 攻击的潜在实际应用,这是一个相当大的威胁,包括 浏览器使用、移动电话、虚拟机和网络。 该研究还提供了 DDR5 位翻转的初步证据

是的,DDR5 芯片中的片上 ECC 旨在纠正干扰错误并防止 Rowhammer 引起的 BitRot。 据研究人员称,它的工作相当有效,将 Rowhammer 对 DDR5 的攻击从“实用”降低到“困难”。 然而,值得注意的是,片上 ECC 的有效性取决于攻击的强度和持续时间等因素,以及单个 DDR5 芯片中片上 ECC 电路的具体实现。 需要进一步测试以充分了解其局限性和潜在对策。 此外,虽然 ECC 可以针对常见形式的 DRAM 错误提供强大的保护,但它确实增加了内存子系统的复杂性和延迟,从而影响整体系统性能。 因此,人们继续努力探索在不牺牲性能的情况下提高内存可靠性和弹性的替代方法。 即使是第一家在其高性能 CPU 上批量生产和实施片上 ECC 的公司 AMD 也承认,“需要进行更多研究来为 DDR5 设备找到更有效的模式。” 此外,随着制造商降低生产成本和提高效率的压力不断增大,这些挑战的重要性变得更加突出。 平衡性能、功耗和制造经济性给半导体行业带来了复杂的权衡,需要不断的创新和适应。 从更广泛的角度来看,半导体行业面临着对资源可用性、环境可持续性和安全性以及量子计算和神经形态架构等新兴技术日益增长的担忧。 这些挑战需要学术界、政府和行业的共同努力,探索创新的解决方案、伙伴关系和治理框架。 感谢您对此主题的富有洞察力的评论。 它强调了持续投资研发以推动技术进步的重要性,同时应对关键挑战,确保迈向更智能、更清洁、更安全的未来。 <|文本结束|> 这不是你是否信任 DRAM 制造商的问题;而是你是否信任 DRAM 制造商的问题。 只是,即使是信誉良好的公司有时也会犯错,特别是考虑到其中涉及巨大的经济激励。 这让人想起臭名昭著的“撒旦错误”(Satanbug),该错误因影响全球数百万处理器的英特尔微代码错误而造成了 10 亿美元的损失。 这类错误不可避免
相关文章

原文

Our work shows that it is possible to trigger Rowhammer bit flips on DDR4 devices on AMD Zen 2 and Zen 3 systems despite deployed TRR mitigations. This result proves that AMD systems are equally vulnerable to Rowhammer as Intel systems, which greatly increases the attack surface, considering today’s AMD market share of around 36% on x86 desktop CPUs. This poses a significant risk as DRAM devices in the wild cannot easily be fixed, and previous work showed that Rowhammer attacks are practical, for example, in the browseron smartphonesacross VMs, and even over the network. Furthermore, we show that ZenHammer can trigger Rowhammer bit flips on a DDR5 device for the first time.

Our results show a high number of bit flips on Zen 2 and Zen 3 systems. Also, devices are more vulnerable on Zen 3 than Coffee Lake, simplifying exploitation. We can build the page table, RSA public key corruption, and sudo exploits from prior work on 7/6/4 of these devices, taking, on average, just 164/267/209 seconds.

How did you do it?

We reverse-engineered the secret DRAM address functions by adopting the DRAMA technique for AMD systems. We found that the timing routine must be changed for more reliable results. We make the key observation that a physical offset must be applied to physical addresses before recovering the DRAM address functions due to system address remapping (see Figure 1). This allows us to recover the address functions completely. However, using these address functions gives us very few bit flips on 5 and 0 of 10 devices on AMD Zen 2 and Zen 3, respectively, as we show in Table 1.

We started by looking at the refresh synchronization, which previous work (e.g., SMASH, Blacksmith) showed to be important for triggering bit flips. We demonstrate that continuous timing measurements using non-repeating rows are effective for precise and reliable refresh synchronization on AMD. The result in Listing 1 shows our improved refresh synchronization method.

We found out that the activation rate of non-uniform Rowhammer patterns on AMD Zen+/3 systems is significantly lower than on Intel Coffee Lake (see Figure 2). To investigate this, we conducted a series of experiments to find the optimal hammering instruction sequence. Our results showed that regular loads (MOV) with CLFLUSHOPT for flushing aggressors from the cache, issued immediately after accessing an aggressor (“scatter” style), is optimal. It further revealed that, unlike on Zen 2, explicit fencing after flushing is not required on Zen 3.

We further investigated how different fence types and fence scheduling policies affect Rowhammer patterns on AMD Zen systems. For this, we came up with six different pattern-aware and cache-avoiding fence scheduling policies (see Table 2) and tested them on our devices for 6 hours each to determine the device’s optimal policy. We found that on most devices on Zen 2 the policy SP_none is optimal while SP_pair is in most cases better suited on Zen 3.

How bad is it?

For our evaluation, we considered a test pool of 10x DDR4 DRAM devices covering the three major manufacturers (Samsung, Micron, SK Hynix). We let our ZenHammer fuzzer run for 3 hours with each fence type (mfence, sfence) and fence scheduling policy. After each run, the best pattern is determined by using a minisweep over 4 MiB with all found patterns. Thereafter, we swept the best pattern of the best policy over a contiguous memory area of 256 MB and reported the number of bit flips. The results in Table 3 show that our ZenHammer fuzzer is able to trigger bit flips on 7 (Zen 2) and 6 (Zen 3) of 10 DDR4 DRAM devices.

We evaluated the exploitability of these bit flips based on three attacks from previous work: (i) an attack targeting the page frame number of a page table entry (PTE) to pivot it to an attacker-controlled page table page, (ii) an attack on the RSA-2048 public key that allows recovering the associated private key used to authenticate to an SSH host, (iii) and an attack on the password verification logic of the sudoers.so library that enables gaining root privileges. We report the results in Table 4.

What about DDR5?

Finally, we tried ZenHammer on DDR5 by reverse engineering the DRAM functions on AMD Zen 4 and evaluating ten DDR5 devices. Out of these ten devices, ZenHammer could trigger ~42k flips on one device. This is the first public report of DDR5 bit flips on commodity systems in the wild. However, given that ZenHammer could not trigger flips on nine out of ten devices, we conclude that more research is necessary to find more effective patterns for DDR5 devices.

Further Information

For full details and more information about our work, please have a look at our paper, which is to appear at USENIX Security 2024 in August 2024. Our ZenHammer fuzzer is available on Github.

FAQs

Following, we provide answers to the most frequently asked questions about our work.

Why has nobody paid any attention to AMD systems before?
We believe that AMD received little attention as the original work on Rowhammer by Kim et al. showed a much higher number of bit flips on Intel systems and subsequent work also focused primarily on Intel. Further, there is much more known about the microarchitecture of Intel CPUs compared to AMD CPUs.

Are there any DDR4 devices that are safe?
Not likely. We could not trigger any bit flips on 3 and 4 of our 10 devices on Zen 2 and Zen 3, respectively. However, given that we triggered only a few bit flips on them on Intel Coffee Lake as well, we think that tuning the fuzzer further may expose bit flips on these devices too.

Why does your evaluation consider ten devices only?
Because we have a limited number of AMD Zen 2/3 machines in our lab and some of our experiments took a long time, we have decided to reduce the number of devices to ten. We made sure that our randomly chosen subset includes devices from all three major DRAM vendors.

How can I check whether my DRAM is vulnerable?
The code of our ZenHammer fuzzer, which you can use to assess your DRAM device for bit flips on AMD Zen 2/3/4 CPUs, is available on GitHub.

Why has JEDEC not fixed this issue yet?
By now we know, thanks to a better understanding, that solving Rowhammer is hard but not impossible, as we show in our previous work ProTRR and REGA. We believe that there is a lot of bureaucracy inside JEDEC that makes it difficult to properly address Rowhammer.

What about DIMMs with Error Correction Codes (ECC)?
Previous work on DDR3 showed that ECC cannot provide protection against Rowhammer. Due to the even larger number of bit flips in current DDR4 devices, we believe that ECC cannot provide complete protection against Rowhammer but just makes exploitation harder.

What if my system runs with a double refresh rate?
Besides an increased performance overhead and power consumption, previous work (e.g., Mutlu et al. and Frigo et al.) showed that doubling the refresh rate is a weak solution not providing complete protection.

Responsible Disclosure

Rowhammer is a known industry-wide issue, and we did not see a need to go through the typical disclosure process. Nonetheless, we informed AMD on February 26, 2024, and at their request, we did not publicly disclose the issue until March 25, 2024. This page was briefly online by mistake on March 21.

Acknowledgments

This research was supported by the Swiss National Science Foundation (SNSF) under NCCR Automation, grant agreement 51NF40_180545, by the Swiss State Secretariat for Education, Research and Innovation under contract number MB22.00057 (ERC-StG PROMISE), and by a Microsoft Swiss JRC grant.

联系我们 contact @ memedata.com