sst-linux/lib
Andrii Nakryiko f9d0a13727 lib/buildid: Handle memfd_secret() files in build_id_parse()
commit 5ac9b4e935dfc6af41eee2ddc21deb5c36507a9f upstream.

>From memfd_secret(2) manpage:

  The memory areas backing the file created with memfd_secret(2) are
  visible only to the processes that have access to the file descriptor.
  The memory region is removed from the kernel page tables and only the
  page tables of the processes holding the file descriptor map the
  corresponding physical memory. (Thus, the pages in the region can't be
  accessed by the kernel itself, so that, for example, pointers to the
  region can't be passed to system calls.)

We need to handle this special case gracefully in build ID fetching
code. Return -EFAULT whenever secretmem file is passed to build_id_parse()
family of APIs. Original report and repro can be found in [0].

  [0] https://lore.kernel.org/bpf/ZwyG8Uro%2FSyTXAni@ly-workstation/

Fixes: de3ec364c3c3 ("lib/buildid: add single folio-based file reader abstraction")
Reported-by: Yi Lai <yi1.lai@intel.com>
Suggested-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Link: https://lore.kernel.org/bpf/20241017175431.6183-A-hca@linux.ibm.com
Link: https://lore.kernel.org/bpf/20241017174713.2157873-1-andrii@kernel.org
[ Chen Linxuan: backport same logic without folio-based changes ]
Fixes: 88a16a1309 ("perf: Add build id data in mmap2 event")
Signed-off-by: Chen Linxuan <chenlinxuan@deepin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-03-28 21:58:57 +01:00
..
842
crypto
dim linux/dim: Do nothing if no time delta between samples 2023-05-24 17:32:31 +01:00
fonts
kunit kunit: Fix timeout message 2024-07-11 12:47:08 +02:00
livepatch
lz4
lzo
math bitmap: introduce generic optimized bitmap_size() 2024-08-29 17:30:14 +02:00
mpi crypto: lib/mpi - Fix unexpected pointer access in mpi_ec_init 2024-02-23 09:12:49 +01:00
pldmfw
raid6
reed_solomon
test_fortify
vdso
xz xz: cleanup CRC32 edits from 2018 2024-10-17 15:20:58 +02:00
zlib_deflate
zlib_dfltcc
zlib_inflate
zstd zstd: Fix array-index-out-of-bounds UBSAN warning 2023-12-13 18:39:04 +01:00
.gitignore
argv_split.c
ashldi3.c
ashrdi3.c
asn1_decoder.c
asn1_encoder.c
assoc_array.c
atomic64_test.c
atomic64.c
audit.c
base64.c
bcd.c
bch.c
bitfield_kunit.c
bitmap.c lib/bitmap: drop optimization of bitmap_{from,to}_arr64 2023-07-19 16:21:58 +02:00
bitrev.c
bootconfig-data.S
bootconfig.c bootconfig: Fix the kerneldoc of _xbc_exit() 2024-10-17 15:22:10 +02:00
bsearch.c
btree.c
bucket_locks.c
bug.c cpuidle: lib/bug: Disable rcu_is_watching() during WARN/BUG 2023-03-10 09:33:47 +01:00
build_OID_registry
buildid.c lib/buildid: Handle memfd_secret() files in build_id_parse() 2025-03-28 21:58:57 +01:00
bust_spinlocks.c
check_signature.c
checksum.c
clz_ctz.c lib/clz_ctz.c: Fix __clzdi2() and __ctzdi2() for 32-bit kernels 2023-08-30 16:11:08 +02:00
clz_tab.c
cmdline_kunit.c lib/cmdline: Fix an invalid format specifier in an assertion msg 2024-03-26 18:20:28 -04:00
cmdline.c
cmpdi2.c
compat_audit.c
cpu_rmap.c lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release() 2023-06-14 11:15:22 +02:00
cpumask_kunit.c
cpumask.c
crc4.c
crc7.c
crc8.c
crc16.c
crc32.c
crc32defs.h
crc32test.c
crc64-rocksoft.c
crc64.c
crc-ccitt.c
crc-itu-t.c
crc-t10dif.c
ctype.c
debug_info.c
debug_locks.c
debugobjects.c debugobjects: Fix conditions in fill_pool() 2024-10-17 15:21:22 +02:00
dec_and_lock.c
decompress_bunzip2.c decompress_bunzip2: fix rare decompression failure 2024-08-03 08:49:38 +02:00
decompress_inflate.c
decompress_unlz4.c
decompress_unlzma.c
decompress_unlzo.c
decompress_unxz.c
decompress_unzstd.c
decompress.c
devmem_is_allowed.c
devres.c
digsig.c
dump_stack.c
dynamic_debug.c dyndbg: fix old BUG_ON in >control parser 2024-05-17 11:56:20 +02:00
dynamic_queue_limits.c
earlycpio.c
errname.c parisc: Drop the HP-UX ENOSYM and EREMOTERELEASE error codes 2023-12-08 08:51:15 +01:00
error-inject.c
errseq.c
extable.c
fault-inject-usercopy.c
fault-inject.c
fdt_addresses.c
fdt_empty_tree.c
fdt_ro.c
fdt_rw.c
fdt_strerror.c
fdt_sw.c
fdt_wip.c
fdt.c
find_bit_benchmark.c
find_bit.c
flex_proportions.c
fortify_kunit.c
gen_crc32table.c
gen_crc64table.c
genalloc.c
generic-radix-tree.c lib/generic-radix-tree.c: Fix rare race in __genradix_ptr_alloc() 2024-09-12 11:10:25 +02:00
glob.c
globtest.c
group_cpus.c genirq/affinity: Only build SMP-only helper functions on SMP kernels 2024-01-10 17:10:36 +01:00
hexdump.c
hweight.c
idr.c ida: Fix crash in ida_free when the bitmap is empty 2024-01-20 11:50:09 +01:00
inflate.c
interval_tree_test.c
interval_tree.c
iomap_copy.c
iomap.c
iommu-helper.c
iov_iter.c
irq_poll.c
irq_regs.c
is_signed_type_kunit.c
is_single_threaded.c
kasprintf.c
Kconfig
Kconfig.debug lockdep: Fix upper limit for LOCKDEP_*_BITS configs 2025-02-21 13:49:29 +01:00
Kconfig.kasan
Kconfig.kcsan
Kconfig.kfence
Kconfig.kgdb
Kconfig.kmsan
Kconfig.ubsan
kfifo.c
klist.c
kobject_uevent.c kobject_uevent: Fix OOB access within zap_modalias_env() 2024-08-03 08:49:39 +02:00
kobject.c kobject: Add sanity check for kset->kobj.ktype in kset_register() 2023-09-23 11:11:07 +02:00
kstrtox.c
kstrtox.h
libcrc32c.c
linear_ranges.c
list_debug.c
list_sort.c
list-test.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
logic_iomem.c
logic_pio.c
lru_cache.c
lshrdi3.c
Makefile genirq/affinity: Move group_cpus_evenly() into lib/ 2024-01-10 17:10:33 +01:00
maple_tree.c maple_tree: simplify split calculation 2025-02-21 13:49:55 +01:00
memcat_p.c
memcpy_kunit.c lib: memcpy_kunit: Fix an invalid format specifier in an assertion msg 2024-03-26 18:20:28 -04:00
memory-notifier-error-inject.c
memregion.c
memweight.c
muldi3.c
net_utils.c
netdev-notifier-error-inject.c
nlattr.c netlink: add nla be16/32 types to minlen array 2024-03-06 14:45:06 +00:00
nmi_backtrace.c
notifier-error-inject.c
notifier-error-inject.h
objagg.c mlxsw: spectrum_acl_erp: Fix object nesting warning 2024-08-03 08:49:05 +02:00
of-reconfig-notifier-error-inject.c
oid_registry.c
once.c
overflow_kunit.c
packing.c
parman.c
parser.c
pci_iomap.c pci_iounmap(): Fix MMIO mapping leak 2024-04-03 15:19:25 +02:00
percpu_counter.c
percpu_test.c
percpu-refcount.c
plist.c
pm-notifier-error-inject.c
polynomial.c
radix-tree.c radix tree: remove unused variable 2023-08-30 16:11:08 +02:00
random32.c
ratelimit.c
rbtree_test.c
rbtree.c
ref_tracker.c
refcount.c
rhashtable.c
sbitmap.c lib/sbitmap: define swap_lock as raw_spinlock_t 2024-10-17 15:21:10 +02:00
scatterlist.c
seq_buf.c
sg_pool.c
sg_split.c
show_mem.c
siphash.c
slub_kunit.c mm/slub, kunit: Use inverted data to corrupt kmem cache 2024-06-12 11:03:04 +02:00
smp_processor_id.c
sort.c
stackdepot.c stackdepot: respect __GFP_NOLOCKDEP allocation flag 2024-05-02 16:29:29 +02:00
stackinit_kunit.c lib: stackinit: hide never-taken branch from compiler 2024-12-14 19:54:37 +01:00
stmp_device.c
string_helpers.c lib: string_helpers: silence snprintf() output truncation warning 2024-12-14 19:54:06 +01:00
string.c
strncpy_from_user.c
strnlen_user.c
syscall.c
test_bitmap.c lib/bitmap: workaround const_eval test build failure 2023-08-11 12:08:10 +02:00
test_bitops.c
test_bits.c
test_blackhole_dev.c net: blackhole_dev: fix build warning for ethh set but not used 2024-03-26 18:20:33 -04:00
test_bpf.c
test_debug_virtual.c
test_dynamic_debug.c
test_firmware.c test_firmware: return ENOMEM instead of ENOSPC on failed memory allocation 2023-08-03 10:24:19 +02:00
test_fprobe.c fprobe: Pass entry_data to handlers 2023-10-25 12:03:12 +02:00
test_fpu.c
test_free_pages.c
test_hash.c
test_hexdump.c
test_hmm_uapi.h
test_hmm.c lib/test_hmm.c: handle src_pfns and dst_pfns allocation failure 2024-06-12 11:03:29 +02:00
test_ida.c ida: Fix crash in ida_free when the bitmap is empty 2024-01-20 11:50:09 +01:00
test_kmod.c
test_kprobes.c
test_linear_ranges.c
test_list_sort.c
test_lockup.c
test_maple_tree.c maple_tree: add GFP_KERNEL to allocations in mas_expected_entries() 2023-11-02 09:35:24 +01:00
test_memcat_p.c
test_meminit.c lib/test_meminit: fix off-by-one error in test_pages() 2023-10-15 18:32:41 +02:00
test_min_heap.c
test_module.c
test_objagg.c
test_parman.c
test_printf.c
test_ref_tracker.c
test_rhashtable.c
test_scanf.c lib: test_scanf: Add explicit type cast to result initialization in test_number_prefix() 2023-09-19 12:28:05 +02:00
test_siphash.c
test_sort.c
test_static_key_base.c
test_static_keys.c
test_string.c
test_strscpy.c
test_sysctl.c
test_ubsan.c
test_user_copy.c
test_uuid.c
test_vmalloc.c
test_xarray.c mm/filemap: optimize filemap folio adding 2024-10-17 15:21:26 +02:00
test-kstrtox.c
test-string_helpers.c
textsearch.c
timerqueue.c
trace_readwrite.c
ts_bm.c lib/ts_bm: reset initial match offset for every block of text 2023-07-19 16:21:13 +02:00
ts_fsm.c
ts_kmp.c
ubsan.c
ubsan.h
ucmpdi2.c
ucs2_string.c
usercopy.c uaccess: Add speculation barrier to copy_from_user() 2023-02-25 11:25:41 +01:00
uuid.c
vsprintf.c lib/vsprintf: Fix %pfwf when current node refcount == 0 2024-01-01 12:39:07 +00:00
win_minmax.c
xarray.c lib/xarray: introduce a new helper xas_get_order 2024-10-17 15:21:26 +02:00
xxhash.c