# CVE-2021-46957: riscv/kprobe: fix kernel panic when invoking sys\_read traced by kprobe

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.21% (percentile 6, 2026-11-28)
- **Published:** 2024-02-27T18:46:58.701Z
- **Modified:** 2026-06-17T04:15:58.807Z

## Who should check

- Anyone running Linux \>= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, \< fd0f06590d35c99f98d12c7984897ec4201a6263; \>= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, \< b1ebaa0e1318494a7637099a26add50509e37964
- Anyone running Linux 5.12

## Description

In the Linux kernel, the following vulnerability has been resolved:

riscv/kprobe: fix kernel panic when invoking sys\_read traced by kprobe

The execution of sys\_read end up hitting a BUG\_ON() in \_\_find\_get\_block
after installing kprobe at sys\_read, the BUG message like the following:

\[   65.708663\] ------------\[ cut here \]------------
\[   65.709987\] kernel BUG at fs/buffer.c:1251!
\[   65.711283\] Kernel BUG \[\#1\]
\[   65.712032\] Modules linked in:
\[   65.712925\] CPU: 0 PID: 51 Comm: sh Not tainted 5.12.0-rc4 \#1
\[   65.714407\] Hardware name: riscv-virtio,qemu (DT)
\[   65.715696\] epc : \_\_find\_get\_block+0x218/0x2c8
\[   65.716835\]  ra : \_\_getblk\_gfp+0x1c/0x4a
\[   65.717831\] epc : ffffffe00019f11e ra : ffffffe00019f56a sp : ffffffe002437930
\[   65.719553\]  gp : ffffffe000f06030 tp : ffffffe0015abc00 t0 : ffffffe00191e038
\[   65.721290\]  t1 : ffffffe00191e038 t2 : 000000000000000a s0 : ffffffe002437960
\[   65.723051\]  s1 : ffffffe00160ad00 a0 : ffffffe00160ad00 a1 : 000000000000012a
\[   65.724772\]  a2 : 0000000000000400 a3 : 0000000000000008 a4 : 0000000000000040
\[   65.726545\]  a5 : 0000000000000000 a6 : ffffffe00191e000 a7 : 0000000000000000
\[   65.728308\]  s2 : 000000000000012a s3 : 0000000000000400 s4 : 0000000000000008
\[   65.730049\]  s5 : 000000000000006c s6 : ffffffe00240f800 s7 : ffffffe000f080a8
\[   65.731802\]  s8 : 0000000000000001 s9 : 000000000000012a s10: 0000000000000008
\[   65.733516\]  s11: 0000000000000008 t3 : 00000000000003ff t4 : 000000000000000f
\[   65.734434\]  t5 : 00000000000003ff t6 : 0000000000040000
\[   65.734613\] status: 0000000000000100 badaddr: 0000000000000000 cause: 0000000000000003
\[   65.734901\] Call Trace:
\[   65.735076\] \[\<ffffffe00019f11e\>\] \_\_find\_get\_block+0x218/0x2c8
\[   65.735417\] \[\<ffffffe00020017a\>\] \_\_ext4\_get\_inode\_loc+0xb2/0x2f6
\[   65.735618\] \[\<ffffffe000201b6c\>\] ext4\_get\_inode\_loc+0x3a/0x8a
\[   65.735802\] \[\<ffffffe000203380\>\] ext4\_reserve\_inode\_write+0x2e/0x8c
\[   65.735999\] \[\<ffffffe00020357a\>\] \_\_ext4\_mark\_inode\_dirty+0x4c/0x18e
\[   65.736208\] \[\<ffffffe000206bb0\>\] ext4\_dirty\_inode+0x46/0x66
\[   65.736387\] \[\<ffffffe000192914\>\] \_\_mark\_inode\_dirty+0x12c/0x3da
\[   65.736576\] \[\<ffffffe000180dd2\>\] touch\_atime+0x146/0x150
\[   65.736748\] \[\<ffffffe00010d762\>\] filemap\_read+0x234/0x246
\[   65.736920\] \[\<ffffffe00010d834\>\] generic\_file\_read\_iter+0xc0/0x114
\[   65.737114\] \[\<ffffffe0001f5d7a\>\] ext4\_file\_read\_iter+0x42/0xea
\[   65.737310\] \[\<ffffffe000163f2c\>\] new\_sync\_read+0xe2/0x15a
\[   65.737483\] \[\<ffffffe000165814\>\] vfs\_read+0xca/0xf2
\[   65.737641\] \[\<ffffffe000165bae\>\] ksys\_read+0x5e/0xc8
\[   65.737816\] \[\<ffffffe000165c26\>\] sys\_read+0xe/0x16
\[   65.737973\] \[\<ffffffe000003972\>\] ret\_from\_syscall+0x0/0x2
\[   65.738858\] ---\[ end trace fe93f985456c935d \]---

A simple reproducer looks like:
	echo 'p:myprobe sys\_read fd=%a0 buf=%a1 count=%a2' \> /sys/kernel/debug/tracing/kprobe\_events
	echo 1 \> /sys/kernel/debug/tracing/events/kprobes/myprobe/enable
	cat /sys/kernel/debug/tracing/trace

Here's what happens to hit that BUG\_ON():

1) After installing kprobe at entry of sys\_read, the first instruction
   is replaced by 'ebreak' instruction on riscv64 platform.

2) Once kernel reach the 'ebreak' instruction at the entry of sys\_read,
   it trap into the riscv breakpoint handler, where it do something to
   setup for coming single-step of origin instruction, including backup
   the 'sstatus' in pt\_regs, followed by disable interrupt during single
   stepping via clear 'SIE' bit of 'sstatus' in pt\_regs.

3) Then kernel restore to the instruction slot contains two instructions,
   one is original instruction at entry of sys\_read, the other is 'ebreak'.
   Here it trigger a 'Instruction page fault' exception (value at 'scause'
   is '0xc'), if PF is not filled into PageTabe for that slot yet.

4) Again kernel trap into page fault exception handler, where it choose
   different policy according to the state of running kprobe. Because
   afte 2) the state is KPROBE\_HIT\_SS, so kernel reset the current kp
---truncated---

## Affected and fixed versions

- Linux: \>= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, \< fd0f06590d35c99f98d12c7984897ec4201a6263; \>= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, \< b1ebaa0e1318494a7637099a26add50509e37964 (cvelist)
- Linux: 5.12 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2021-46957. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-46957.md
Affected: Linux >= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, < fd0f06590d35c99f98d12c7984897ec4201a6263; >= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, < b1ebaa0e1318494a7637099a26add50509e37964; Linux 5.12
Fixed in: no fixed version listed yet

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2021-46957 being exploited?

There is no confirmed exploitation: CVE-2021-46957 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.21% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2021-46957?

Medium: CVSS 5.5 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2021-46957?

Linux \>= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, \< fd0f06590d35c99f98d12c7984897ec4201a6263; \>= c22b0bcb1dd024cb9caad9230e3a387d8b061df5, \< b1ebaa0e1318494a7637099a26add50509e37964; Linux 5.12.

### Is there a fix for CVE-2021-46957?

No fixed version is listed in the sources yet. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2021-46957?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/fd0f06590d35c99f98d12c7984897ec4201a6263>
- patch: <https://git.kernel.org/stable/c/b1ebaa0e1318494a7637099a26add50509e37964>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2021-46957>

HTML: <https://flawdb.com/CVE-2021-46957> · JSON: <https://flawdb.com/api/v1/entries/CVE-2021-46957>
