5.5medium
nilfs2: fix underflow in second superblock position calculations
- Severity
- 5.5medium CVSS:3.1 by NVD
- Exploit likelihood
- 0.25% (higher than 17% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Linux
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
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from e339ad31f59925b48a92ee3947692fdf9758b8c7 before 2f7a1135b202977b82457adde7db6c390056863b, from e339ad31f59925b48a92ee3947692fdf9758b8c7 before b96591e2c35c8b47db0ec816b5fc6cb8868000ff, from e339ad31f59925b48a92ee3947692fdf9758b8c7 before 52844d8382cd9166d708032def8905ffc3ae550f, from e339ad31f59925b48a92ee3947692fdf9758b8c7 before 0ee5ed0126a2211f7174492da2ca2c29f43755c5, from e339ad31f59925b48a92ee3947692fdf9758b8c7 before a158782b56b070485d54d25fc9aaf2c8f3752205, from e339ad31f59925b48a92ee3947692fdf9758b8c7 before a8ef5109f93cea9933bbac0455d8c18757b3fcb4, from e339ad31f59925b48a92ee3947692fdf9758b8c7 before 99b9402a36f0799f25feee4465bfa4b8dfa74b4d, 2.6.30 Not affected: before 2.6.30, from 4.14.306 up to 4.14.*, from 4.19.273 up to 4.19.*, from 5.4.232 up to 5.4.*, from 5.10.169 up to 5.10.*, from 5.15.95 up to 5.15.* | CVE List |
| linux linux_kernel | before 4.14.306, from 4.15 before 4.19.273, from 4.20 before 5.4.232, from 5.5 before 5.10.169, from 5.11 before 5.15.95, from 5.16 before 6.1.13, 6.2 | NVD |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
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.
NVD (es)
En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: nilfs2: corrige el desbordamiento en los cálculos de la posición del segundo superbloque. La macro NILFS_SB2_OFFSET_BYTES, que calcula la posición del segundo superbloque, sufre un desbordamiento cuando el tamaño del dispositivo del argumento es inferior a 4096 bytes. Por lo tanto, al utilizar esta macro, es necesario comprobar de antemano que el tamaño del dispositivo no sea inferior a un límite inferior, o al menos que no se produzca un desbordamiento insuficiente. La implementación actual de nilfs2 carece de esta verificación, lo que provoca un acceso a bloques fuera de los límites al montar dispositivos de menos de 4096 bytes: error de E/S, dev loop0, sector 36028797018963960 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2 NILFS (loop0 ): no se puede leer el superbloque secundario (tamaño de bloque = 1024) Además, al intentar cambiar el tamaño del sistema de archivos a un tamaño inferior a 4096 bytes, este desbordamiento se produce en nilfs_resize_fs(), pasando una gran cantidad de segmentos a nilfs_sufile_resize(), corrompiendo parámetros como como el número de segmentos en supermanzanas. Esto provoca iteraciones de bucle excesivas en nilfs_sufile_resize() durante un cambio de tamaño de ioctl posterior, lo que provoca que el semáforo ns_segctor_sem se bloquee durante mucho tiempo y cuelgue el hilo de escritura: INFORMACIÓN: tarea segctord:5067 bloqueada durante más de 143 segundos. No contaminado 6.2.0-rc8-syzkaller-00015-gf6feea56f66d #0 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" desactiva este mensaje. tarea:segctord estado:D pila:23456 pid:5067 ppid:2 banderas:0x00004000 Seguimiento de llamadas: context_switch kernel/sched/core.c:5293 [en línea] __schedule+0x1409/0x43f0 kernel/sched/core.c: 6606 programación+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/segmento. c:2486 [en línea] 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 ... Seguimiento de llamadas: folio_mark_accessed+0x51c/0xf00 mm/swap.c:515 __nilfs_get_page_block fs/nilfs2/page.c:42 [en línea] 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 _get_segment_usage_block fs/nilfs2/sufile.c :92 [en línea] nilfs_sufile_truncate_range fs/nilfs2/sufile.c:679 [en línea] nilfs_sufile_resize+0x7a3/0x12b0 fs/nilfs2/sufile.c:777 nilfs_resize_fs+0x20c/0xed0 fs/nilfs2/super.c:422 nilfs_ioctl_resize f s/nilfs2 /ioctl.c:1033 [en línea] nilfs_ioctl+0x137c/0x2440 fs/nilfs2/ioctl.c:1301 ... Esto soluciona estos problemas insertando comprobaciones de tamaño mínimo de dispositivo adecuadas o comprobaciones anti-desbordamiento, dependiendo de dónde se utilice la macro .
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2023-52705 changed 2026-05-11 | CVE Terms of Use |
| NVD | CVE-2023-52705 changed 2026-06-17 | Public domain |