Hello,

This is an upstream regression in the 6.1.y stable series, and a fix is
already queued for 6.1.193. Details, an independent reproduction on
arm64 and a short reproducer follow.

We hit the same oops independently today on arm64, on
debian-12-genericcloud-arm64 with only the kernel package changed
(linux-image-6.1.0-55-cloud-arm64, 6.1.192-1):

  pc : ext4_mb_load_buddy_gfp+0xac/0x454
  Unable to handle kernel NULL pointer dereference at virtual address 0

6 oopses in 6 attempts on 6.1.192-1; none on 6.1.190-1 or 6.1.187-1 with
the same virtual machine and filesystem.

Cause. 6.1.191 backported the folio conversion of mballoc

  d34e4fd4e73f ext4: convert bd_bitmap_page to bd_bitmap_folio
  862483175d3d ext4: convert bd_buddy_page to bd_buddy_folio

The converted code tests the result of __filemap_get_folio() with
IS_ERR(), but in 6.1 that function returns NULL on failure (an ERR_PTR
only since v6.4, commit 66dabbb65d67). In ext4_mb_load_buddy_gfp() the
fast-path lookup has no FGP_CREAT, so a page-cache miss returns NULL, the
IS_ERR() test passes, and folio_test_uptodate(NULL) reads address 0. The
task dies holding a journal handle, so the journal stops committing and
later writers to that filesystem block. This is not a Debian change.

Fix. Upstream has it queued for 6.1.193:

  ext4: fix NULL folio dereference in mballoc

https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/tree/queue-6.1/ext4-fix-null-folio-dereference-in-mballoc.patch
  (also in linux-stable-rc.git, branch linux-6.1.y, as of 6.1.193-rc1)

Reproducer, as root, first attempt on 6.1.192-1 (2 CPUs, 2 GiB, no swap,
root on ext4):

  # dd if=/dev/zero of=/var/tmp/a bs=1M count=8 conv=fsync
  # sync
  # echo 3 > /proc/sys/vm/drop_caches
  # dd if=/dev/zero of=/var/tmp/b bs=1M count=8 conv=fsync
  Segmentation fault

drop_caches is only the quickest way to evict the bitmap page. The same
oops happens under ordinary memory pressure, which matches the two
machines in the original report.

No privilege is needed: it reproduces as an ordinary user, and from
inside an unprivileged container with a memory limit.

It does not seem to depend on ext4 features or mount options: a second
filesystem made with -b 1024 -O quota,project,^flex_bg and mounted
prjquota,data=journal oopses the same way.

Could the fix be included in the next bookworm-security upload, either
by moving to 6.1.193 once it is released or by cherry-picking the patch
above?

Thank you.

Reply via email to