linux/lib
Shakeel Butt 777a8560fd lib/buildid: use __kernel_read() for sleepable context
Prevent a "BUG: unable to handle kernel NULL pointer dereference in
filemap_read_folio".

For the sleepable context, convert freader to use __kernel_read() instead
of direct page cache access via read_cache_folio().  This simplifies the
faultable code path by using the standard kernel file reading interface
which handles all the complexity of reading file data.

At the moment we are not changing the code for non-sleepable context which
uses filemap_get_folio() and only succeeds if the target folios are
already in memory and up-to-date.  The reason is to keep the patch simple
and easier to backport to stable kernels.

Syzbot repro does not crash the kernel anymore and the selftests run
successfully.

In the follow up we will make __kernel_read() with IOCB_NOWAIT work for
non-sleepable contexts.  In addition, I would like to replace the
secretmem check with a more generic approach and will add fstest for the
buildid code.

Link: https://lkml.kernel.org/r/20251222205859.3968077-1-shakeel.butt@linux.dev
Fixes: ad41251c29 ("lib/buildid: implement sleepable build_id_parse() API")
Reported-by: syzbot+09b7d050e4806540153d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=09b7d050e4806540153d
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Jinchao Wang <wangjinchao600@gmail.com>
  Link: https://lkml.kernel.org/r/aUteBPWPYzVWIZFH@ndev
Reviewed-by: Christian Brauner <brauner@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkman <daniel@iogearbox.net>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-01-14 22:16:21 -08:00
..
842
crc
crypto lib/crypto: aes: Fix missing MMU protection for AES S-box 2026-01-08 11:14:59 -08:00
dim
fonts lib/fonts: Add Terminus 10x18 console font 2025-12-02 19:57:01 +01:00
kunit kunit: make FAULT_TEST default to n when PANIC_ON_OOPS 2025-12-15 09:27:19 -07:00
lz4
lzo
math
pldmfw
raid6 First set of RISC-V updates for v6.19-rc1 2025-12-05 16:26:57 -08:00
reed_solomon treewide: Update email address 2026-01-11 06:09:11 -10:00
test_fortify
tests Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
vdso
xz
zlib_deflate
zlib_dfltcc
zlib_inflate
zstd
.gitignore
Kconfig
Kconfig.debug Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
Kconfig.kasan
Kconfig.kcsan
Kconfig.kfence
Kconfig.kgdb
Kconfig.kmsan
Kconfig.ubsan
Makefile
alloc_tag.c
argv_split.c
ashldi3.c
ashrdi3.c
asn1_decoder.c
asn1_encoder.c
assoc_array.c
atomic64.c
atomic64_test.c
audit.c
base64.c
bcd.c
bch.c
bitmap-str.c
bitmap.c
bitrev.c
bootconfig-data.S
bootconfig.c
bsearch.c
btree.c
bucket_locks.c
bug.c bug: Hush suggest-attribute=format for __warn_printf() 2025-12-12 10:26:26 +01:00
build_OID_registry
buildid.c lib/buildid: use __kernel_read() for sleepable context 2026-01-14 22:16:21 -08:00
bust_spinlocks.c
cache_maint.c
check_signature.c
checksum.c
closure.c
clz_ctz.c
clz_tab.c
cmdline.c
cmpdi2.c
cmpxchg-emu.c
codetag.c
compat_audit.c
cpu_rmap.c
cpumask.c
ctype.c
debug_info.c
debug_locks.c
debugobjects.c treewide: Update email address 2026-01-11 06:09:11 -10:00
dec_and_lock.c
decompress.c
decompress_bunzip2.c
decompress_inflate.c
decompress_unlz4.c
decompress_unlzma.c
decompress_unlzo.c
decompress_unxz.c
decompress_unzstd.c
devmem_is_allowed.c
devres.c
dhry.h
dhry_1.c
dhry_2.c
dhry_run.c
digsig.c
dump_stack.c
dynamic_debug.c
dynamic_queue_limits.c
earlycpio.c
errname.c
error-inject.c
errseq.c
extable.c
fault-inject-usercopy.c
fault-inject.c
fdt.c
fdt_addresses.c
fdt_empty_tree.c
fdt_ro.c
fdt_rw.c
fdt_strerror.c
fdt_sw.c
fdt_wip.c
find_bit.c
find_bit_benchmark.c
find_bit_benchmark_rust.rs
flex_proportions.c
fw_table.c
genalloc.c
generic-radix-tree.c
glob.c
globtest.c
group_cpus.c
hexdump.c
hweight.c
idr.c idr: fix idr_alloc() returning an ID out of range 2025-12-23 11:23:11 -08:00
inflate.c
interval_tree.c
interval_tree_test.c
iomap.c
iomap_copy.c
iomem_copy.c
iommu-helper.c
iov_iter.c
irq_poll.c
irq_regs.c
is_single_threaded.c
kasprintf.c
kfifo.c kfifo: add kfifo_alloc_node() helper for NUMA awareness 2025-11-28 09:20:13 -07:00
klist.c
kobject.c
kobject_uevent.c
kstrtox.c
kstrtox.h
linear_ranges.c
list_debug.c
list_sort.c
llist.c
locking-selftest-hardirq.h
locking-selftest-mutex.h
locking-selftest-rlock-hardirq.h
locking-selftest-rlock-softirq.h
locking-selftest-rlock.h
locking-selftest-rsem.h
locking-selftest-rtmutex.h
locking-selftest-softirq.h
locking-selftest-spin-hardirq.h
locking-selftest-spin-softirq.h
locking-selftest-spin.h
locking-selftest-wlock-hardirq.h
locking-selftest-wlock-softirq.h
locking-selftest-wlock.h
locking-selftest-wsem.h
locking-selftest.c
lockref.c lockref: add a __cond_lock annotation for lockref_put_or_lock 2025-12-10 05:58:51 +09:00
logic_iomem.c
logic_pio.c
lru_cache.c
lshrdi3.c
lwq.c
maple_tree.c
memcat_p.c
memory-notifier-error-inject.c
memregion.c
memweight.c
min_heap.c
muldi3.c
net_utils.c
netdev-notifier-error-inject.c
nlattr.c
nmi_backtrace.c
notifier-error-inject.c
notifier-error-inject.h
objagg.c
objpool.c
of-reconfig-notifier-error-inject.c
oid_registry.c
once.c
packing.c
packing_test.c
parman.c
parser.c
percpu-refcount.c
percpu_counter.c
percpu_test.c
plist.c treewide: Update email address 2026-01-11 06:09:11 -10:00
pm-notifier-error-inject.c
polynomial.c
radix-tree.c
radix-tree.h
random32.c
ratelimit.c
rbtree.c rbtree: inline rb_last() 2025-11-27 14:24:30 -08:00
rbtree_test.c
rcuref.c
ref_tracker.c
refcount.c
rhashtable.c
sbitmap.c
scatterlist.c
seq_buf.c
sg_pool.c
sg_split.c
siphash.c
smp_processor_id.c
sort.c
stackdepot.c
stmp_device.c
string.c
string_helpers.c
strncpy_from_user.c
strnlen_user.c
sys_info.c
syscall.c
test-kstrtox.c
test_bitmap.c
test_bitops.c
test_bpf.c
test_debug_virtual.c
test_dynamic_debug.c
test_firmware.c
test_fpu.h
test_fpu_glue.c
test_fpu_impl.c
test_free_pages.c
test_hexdump.c
test_hmm.c
test_hmm_uapi.h
test_ida.c
test_kho.c test_kho: always print restore status 2025-11-27 14:24:42 -08:00
test_kmod.c
test_lockup.c
test_maple_tree.c
test_memcat_p.c
test_meminit.c
test_min_heap.c
test_module.c
test_objagg.c
test_objpool.c
test_parman.c
test_ref_tracker.c
test_rhashtable.c
test_static_key_base.c
test_static_keys.c
test_sysctl.c
test_ubsan.c
test_uuid.c
test_vmalloc.c
test_xarray.c
textsearch.c
timerqueue.c
trace_readwrite.c
ts_bm.c
ts_fsm.c
ts_kmp.c
ubsan.c
ubsan.h
ucmpdi2.c
ucs2_string.c
union_find.c
usercopy.c
uuid.c
vsprintf.c Merge branch 'for-6.19-vsprintf-timespec64' into for-linus 2025-12-01 14:14:34 +01:00
win_minmax.c
xarray.c
xxhash.c