漏洞信息
# 龙架构:BPF:修正build_prologue()中的off-by-one错误
## 漏洞描述
### 概述
在Linux内核中,LoongArch架构的BPF功能存在一个off-by-one错误,在`build_prologue()`函数中。
### 影响版本
未具体列出影响版本,请参考官方安全公告或内核更新日志以确定受影响的版本范围。
### 细节
Vincent报告了当在LoongArch上运行带有尾调用(tailcalls)的BPF程序时,会导致内核硬锁死。调试此问题揭示了JIT编译后的代码缺少一个`jirl`指令,在退出序列的末尾位置。
JIT编译包括两个阶段:
1. 第一阶段设置标志。
2. 第二阶段基于这些标志生成JIT代码。
当BPF程序同时使用bpf2bpf和tailcalls时,`build_prologue()`函数在第一阶段中会生成N条指令,而在第二阶段则生成N+1条指令。这导致了退出序列偏移(epilogue_offset)出现一个off-by-one错误,从而跳跃到一些不预期的指令位置并引发锁死问题。
该漏洞通过插入一条`nop`指令来修复此问题。
### 影响
当在LoongArch上运行带有尾调用的BPF程序时,会导致内核硬锁死。
备注
尽管我们采用了先进的大模型技术,但其输出仍可能包含不准确或过时的信息。
神龙会尽力确保数据准确,但也请结合实际情况进行甄别与判断。
神龙祝您一切顺利!
漏洞标题
LoongArch: BPF: Fix off-by-one error in build_prologue()
漏洞描述信息
In the Linux kernel, the following vulnerability has been resolved:
LoongArch: BPF: Fix off-by-one error in build_prologue()
Vincent reported that running BPF progs with tailcalls on LoongArch
causes kernel hard lockup. Debugging the issues shows that the JITed
image missing a jirl instruction at the end of the epilogue.
There are two passes in JIT compiling, the first pass set the flags and
the second pass generates JIT code based on those flags. With BPF progs
mixing bpf2bpf and tailcalls, build_prologue() generates N insns in the
first pass and then generates N+1 insns in the second pass. This makes
epilogue_offset off by one and we will jump to some unexpected insn and
cause lockup. Fix this by inserting a nop insn.
CVSS信息
N/A
漏洞类别
N/A