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 lib/crc: Switch ARM and arm64 to 'ksimd' scoped guard API 2025-11-12 09:52:01 +01:00
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 lib: test_mul_u64_u64_div_u64(): test the 32bit code on 64bit 2025-11-20 14:03:42 -08:00
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 lib/xz: remove dead IA-64 (Itanium) support code 2025-11-12 10:00:15 -08:00
zlib_deflate
zlib_dfltcc
zlib_inflate
zstd
.gitignore
Kconfig standalone cache drivers for v6.19 2025-11-27 23:00:45 +01:00
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 KMSAN: Restore dynamic check for '-fsanitize=kernel-memory' 2025-10-27 16:22:02 -07:00
Kconfig.ubsan
Makefile standalone cache drivers for v6.19 2025-11-27 23:00:45 +01:00
alloc_tag.c lib/alloc_tag: use %pe format specifier 2025-11-20 13:43:57 -08:00
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 lib/base64: rework encode/decode for speed and stricter validation 2025-11-20 14:03:44 -08:00
bcd.c
bch.c
bitmap-str.c
bitmap.c cpumask: Introduce cpumask_weighted_or() 2025-11-20 12:14:54 +01:00
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 lib: Support ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION 2025-11-21 18:42:01 +00:00
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 integrity-v6.18 2025-10-05 10:48:33 -07:00
dump_stack.c
dynamic_debug.c dynamic_debug: add support for print stack 2025-11-12 10:00:16 -08:00
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 bitops: Update kernel-doc in hweight.c to fix the issues with it 2025-11-06 11:51:04 -05:00
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: Fix ITSTATIC usage for *_subtree_search() 2025-10-14 14:45:22 -07:00
interval_tree_test.c
iomap.c
iomap_copy.c
iomem_copy.c
iommu-helper.c
iov_iter.c iov_iter: Add missing speculation barrier to copy_from_user_iter() 2025-11-18 15:27:34 +01:00
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 treewide: Remove in_irq() 2025-10-24 21:39:27 +02:00
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 maple_tree: fix tracepoint string pointers 2025-11-09 21:19:45 -08:00
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 lib: ratelimit: fix spelling mistake 'seperately' 2025-11-20 14:03:45 -08:00
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 lib/strn*,uaccess: Use masked_user_{read/write}_access_begin when required 2025-11-18 15:27:35 +01:00
strnlen_user.c lib/strn*,uaccess: Use masked_user_{read/write}_access_begin when required 2025-11-18 15:27:35 +01:00
sys_info.c sys_info: add a default kernel sys_info mask 2025-11-20 14:03:43 -08:00
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 mm/hmm/test: fix error handling in dmirror_device_init 2025-11-24 15:08:50 -08:00
test_hmm_uapi.h lib/test_hmm: add large page allocation failure testing 2025-11-24 15:08:48 -08:00
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 Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
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 lib/test_vmalloc: remove xfail condition check 2025-11-16 17:27:53 -08:00
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 uaccess: decouple INLINE_COPY_FROM_USER and CONFIG_RUST 2025-11-12 10:00:16 -08:00
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 lib/xxhash: remove more unused xxh functions 2025-11-12 10:00:17 -08:00