# CVE-2023-52705: nilfs2: fix underflow in second superblock position calculations

> 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, NVD) `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.31% (percentile 16, 2026-11-28)
- **CWE:** CWE-191
- **Published:** 2024-05-21T15:22:54.015Z
- **Modified:** 2026-06-17T06:43:23.430Z

## Who should check

- Anyone running Linux \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 2f7a1135b202977b82457adde7db6c390056863b; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< b96591e2c35c8b47db0ec816b5fc6cb8868000ff; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 52844d8382cd9166d708032def8905ffc3ae550f; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 0ee5ed0126a2211f7174492da2ca2c29f43755c5; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< a158782b56b070485d54d25fc9aaf2c8f3752205; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< a8ef5109f93cea9933bbac0455d8c18757b3fcb4; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 99b9402a36f0799f25feee4465bfa4b8dfa74b4d
- Anyone running Linux 2.6.30

## Description

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

nilfs2: fix underflow in second superblock position calculations

Macro NILFS\_SB2\_OFFSET\_BYTES, which computes the position of the second
superblock, underflows when the argument device size is less than 4096
bytes.  Therefore, when using this macro, it is necessary to check in
advance that the device size is not less than a lower limit, or at least
that underflow does not occur.

The current nilfs2 implementation lacks this check, causing out-of-bound
block access when mounting devices smaller than 4096 bytes:

 I/O error, dev loop0, sector 36028797018963960 op 0x0:(READ) flags 0x0
 phys\_seg 1 prio class 2
 NILFS (loop0): unable to read secondary superblock (blocksize = 1024)

In addition, when trying to resize the filesystem to a size below 4096
bytes, this underflow occurs in nilfs\_resize\_fs(), passing a huge number
of segments to nilfs\_sufile\_resize(), corrupting parameters such as the
number of segments in superblocks.  This causes excessive loop iterations
in nilfs\_sufile\_resize() during a subsequent resize ioctl, causing
semaphore ns\_segctor\_sem to block for a long time and hang the writer
thread:

 INFO: task segctord:5067 blocked for more than 143 seconds.
      Not tainted 6.2.0-rc8-syzkaller-00015-gf6feea56f66d \#0
 "echo 0 \> /proc/sys/kernel/hung\_task\_timeout\_secs" disables this message.
 task:segctord        state:D stack:23456 pid:5067  ppid:2
 flags:0x00004000
 Call Trace:
  \<TASK\>
  context\_switch kernel/sched/core.c:5293 \[inline\]
  \_\_schedule+0x1409/0x43f0 kernel/sched/core.c:6606
  schedule+0xc3/0x190 kernel/sched/core.c:6682
  rwsem\_down\_write\_slowpath+0xfcf/0x14a0 kernel/locking/rwsem.c:1190
  nilfs\_transaction\_lock+0x25c/0x4f0 fs/nilfs2/segment.c:357
  nilfs\_segctor\_thread\_construct fs/nilfs2/segment.c:2486 \[inline\]
  nilfs\_segctor\_thread+0x52f/0x1140 fs/nilfs2/segment.c:2570
  kthread+0x270/0x300 kernel/kthread.c:376
  ret\_from\_fork+0x1f/0x30 arch/x86/entry/entry\_64.S:308
  \</TASK\>
 ...
 Call Trace:
  \<TASK\>
  folio\_mark\_accessed+0x51c/0xf00 mm/swap.c:515
  \_\_nilfs\_get\_page\_block fs/nilfs2/page.c:42 \[inline\]
  nilfs\_grab\_buffer+0x3d3/0x540 fs/nilfs2/page.c:61
  nilfs\_mdt\_submit\_block+0xd7/0x8f0 fs/nilfs2/mdt.c:121
  nilfs\_mdt\_read\_block+0xeb/0x430 fs/nilfs2/mdt.c:176
  nilfs\_mdt\_get\_block+0x12d/0xbb0 fs/nilfs2/mdt.c:251
  nilfs\_sufile\_get\_segment\_usage\_block fs/nilfs2/sufile.c:92 \[inline\]
  nilfs\_sufile\_truncate\_range fs/nilfs2/sufile.c:679 \[inline\]
  nilfs\_sufile\_resize+0x7a3/0x12b0 fs/nilfs2/sufile.c:777
  nilfs\_resize\_fs+0x20c/0xed0 fs/nilfs2/super.c:422
  nilfs\_ioctl\_resize fs/nilfs2/ioctl.c:1033 \[inline\]
  nilfs\_ioctl+0x137c/0x2440 fs/nilfs2/ioctl.c:1301
  ...

This fixes these issues by inserting appropriate minimum device size
checks or anti-underflow checks, depending on where the macro is used.

## Affected and fixed versions

- Linux: \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 2f7a1135b202977b82457adde7db6c390056863b; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< b96591e2c35c8b47db0ec816b5fc6cb8868000ff; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 52844d8382cd9166d708032def8905ffc3ae550f; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 0ee5ed0126a2211f7174492da2ca2c29f43755c5; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< a158782b56b070485d54d25fc9aaf2c8f3752205; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< a8ef5109f93cea9933bbac0455d8c18757b3fcb4; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 99b9402a36f0799f25feee4465bfa4b8dfa74b4d (cvelist)
- Linux: 2.6.30 (cvelist)

## Mitigation

- Upgrade Linux to 99b9402a36f0799f25feee4465bfa4b8dfa74b4d or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2023-52705.md
Affected: Linux >= e339ad31f59925b48a92ee3947692fdf9758b8c7, < 2f7a1135b202977b82457adde7db6c390056863b; >= e339ad31f59925b48a92ee3947692fdf9758b8c7, < b96591e2c35c8b47db0ec816b5fc6cb8868000ff; >= e339ad31f59925b48a92ee3947692fdf9758b8c7, < 52844d8382cd9166d708032def8905ffc3ae550f; >= e339ad31f59925b48a92ee3…
Fixed in: Linux 2f7a1135b202977b82457adde7db6c390056863b, Linux 52844d8382cd9166d708032def8905ffc3ae550f, Linux 0ee5ed0126a2211f7174492da2ca2c29f43755c5, Linux 99b9402a36f0799f25feee4465bfa4b8dfa74b4d

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-2023-52705 being exploited?

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

### How serious is CVE-2023-52705?

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

### Which versions are affected by CVE-2023-52705?

Linux \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 2f7a1135b202977b82457adde7db6c390056863b; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< b96591e2c35c8b47db0ec816b5fc6cb8868000ff; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 52844d8382cd9166d708032def8905ffc3ae550f; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 0ee5ed0126a2211f7174492da2ca2c29f43755c5; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< a158782b56b070485d54d25fc9aaf2c8f3752205; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< a8ef5109f93cea9933bbac0455d8c18757b3fcb4; \>= e339ad31f59925b48a92ee3947692fdf9758b8c7, \< 99b9402a36f0799f25feee4465bfa4b8dfa74b4d; Linux 2.6.30.

### Is there a fix for CVE-2023-52705?

Yes. Fixed in Linux 2f7a1135b202977b82457adde7db6c390056863b, Linux 52844d8382cd9166d708032def8905ffc3ae550f, Linux 0ee5ed0126a2211f7174492da2ca2c29f43755c5, Linux 99b9402a36f0799f25feee4465bfa4b8dfa74b4d. Upgrade Linux to 99b9402a36f0799f25feee4465bfa4b8dfa74b4d or later.

### How do I check if I'm affected by CVE-2023-52705?

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/2f7a1135b202977b82457adde7db6c390056863b>
- patch: <https://git.kernel.org/stable/c/b96591e2c35c8b47db0ec816b5fc6cb8868000ff>
- patch: <https://git.kernel.org/stable/c/52844d8382cd9166d708032def8905ffc3ae550f>
- patch: <https://git.kernel.org/stable/c/0ee5ed0126a2211f7174492da2ca2c29f43755c5>
- patch: <https://git.kernel.org/stable/c/a158782b56b070485d54d25fc9aaf2c8f3752205>
- patch: <https://git.kernel.org/stable/c/a8ef5109f93cea9933bbac0455d8c18757b3fcb4>
- patch: <https://git.kernel.org/stable/c/99b9402a36f0799f25feee4465bfa4b8dfa74b4d>

## 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-2023-52705>

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