PT-2026-163478
CVE-2026-139437
·
Publicado
2026-11-30
·
Atualizado
2026-11-30
Descrição por
Pontuação
N/A
Não disponívelNão há classificações de severidade ou métricas disponíveis. Quando houver, atualizaremos as informações correspondentes na página.
In the Linux kernel, the following vulnerability has been resolved:
block: take i rwsem for the direct I/O write fallback
Commit c0e473a0d226 ("block: fix race between set blocksize and read
paths") closed a race between set blocksize() and block device I/O: with
large sector size support, set blocksize() can change i blkbits and the
mapping's minimum folio order while a concurrent reader still holds a
folio of the old, smaller order, leading to crashes. In particular, it
made blkdev write iter() wrap buffered writes in inode lock shared().
However, the direct I/O fallback path was missed in that conversion.
blkdev write iter() passes blkdev buffered write() as an argument to
direct write fallback() with no lock held. A direct write that completes
only partially then finishes as a buffered write with no protection.
This can cause a BUG by racing partial direct writes against
ioctl(BLKBSZSET). Writer threads issue O DIRECT pwritev() with a
two-segment iovec whose second segment is an unreadable PROT NONE
mapping. The direct path then writes the first segment, fails to pin the
second, and returns short, entering the fallback. A second thread keeps
toggling the second segment's protection so that some fallbacks get past
fault in iov iter readable() and reach the page cache, a third thread
populates the page cache with folios of the current block size via
pread() and readahead(), and a fourth thread toggles the block size
between 512 bytes and 64K with BLKBSZSET. The minimum folio order only
moves with block sizes above PAGE SIZE, i.e. with
CONFIG TRANSPARENT HUGEPAGE raising BLK MAX BLOCK SIZE to 64K.
On a CONFIG DEBUG VM kernel this yields the following BUG:
page dumped because: VM BUG ON FOLIO(folio order(folio) < mapping min folio order(mapping))
kernel BUG at mm/filemap.c:858!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
RIP: 0010: filemap add folio+0x860/0x8d0
Call Trace:
filemap add folio+0xc9/0x1f0
filemap get folio mpol+0x240/0x660
iomap write begin+0xa87/0xd70
iomap file buffered write+0x304/0x6a0
blkdev write iter+0x255/0x510
do iter readv writev+0x23d/0x3c0
vfs writev+0x211/0x7d0
do pwritev+0x121/0x190
do syscall 64+0x121/0x630
entry SYSCALL 64 after hwframe+0x77/0x7f
The same workload also trips WARN ON ONCE(pos >= folio pos(folio) +
fsize) in iomap trim folio range().
Fix this by calling blkdev buffered write() in the fallback path under
inode lock shared(), matching the plain buffered-write branch. With the
fix the same workload runs clean.
A short IOCB NOWAIT direct write reaches the same fallback. Taking
i rwsem there can now block behind set blocksize(), and the fallback
already blocks on writeback of the data it copied in
direct write fallback(). blkdev write iter() already rejects a purely
buffered IOCB NOWAIT write with -EOPNOTSUPP, so do not enter the
fallback for IOCB NOWAIT at all: return the bytes the direct path
already wrote, or -EAGAIN if none, and let the caller retry.
The reproducer used was written by an LLM, and is available at [1].
Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾