Merge tag 'AT_EXECVE_CHECK-v6.14-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxPull AT_EXECVE_CHECK selftest fix from Kees Cook: "Fixes the AT_EXECVE_CHECK selftests which d
Merge tag 'AT_EXECVE_CHECK-v6.14-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxPull AT_EXECVE_CHECK selftest fix from Kees Cook: "Fixes the AT_EXECVE_CHECK selftests which didn't run on old versions of glibc"* tag 'AT_EXECVE_CHECK-v6.14-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: selftests: Handle old glibc without execveat(2)
show more ...
selftests: Handle old glibc without execveat(2)Add an execveat(2) wrapper because glibc < 2.34 does not have one. Thisfixes the check-exec tests and samples.Cc: Günther Noack <gnoack@google.com
selftests: Handle old glibc without execveat(2)Add an execveat(2) wrapper because glibc < 2.34 does not have one. Thisfixes the check-exec tests and samples.Cc: Günther Noack <gnoack@google.com>Cc: Jeff Xu <jeffxu@chromium.org>Cc: Kees Cook <kees@kernel.org>Cc: Mimi Zohar <zohar@linux.ibm.com>Cc: Paul Moore <paul@paul-moore.com>Cc: Roberto Sassu <roberto.sassu@huawei.com>Cc: Serge Hallyn <serge@hallyn.com>Cc: Stefan Berger <stefanb@linux.ibm.com>Cc: Stephen Rothwell <sfr@canb.auug.org.au>Reported-by: Nathan Chancellor <nathan@kernel.org>Closes: https://lore.kernel.org/r/20250114205645.GA2825031@ax162Signed-off-by: Mickaël Salaün <mic@digikod.net>Reviewed-by: Günther Noack <gnoack3000@gmail.com>Link: https://lore.kernel.org/r/20250115144753.311152-1-mic@digikod.netSigned-off-by: Kees Cook <kees@kernel.org>
Merge tag 'AT_EXECVE_CHECK-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxPull AT_EXECVE_CHECK from Kees Cook: - Implement AT_EXECVE_CHECK flag to execveat(2) (Mickaël Sala
Merge tag 'AT_EXECVE_CHECK-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxPull AT_EXECVE_CHECK from Kees Cook: - Implement AT_EXECVE_CHECK flag to execveat(2) (Mickaël Salaün) - Implement EXEC_RESTRICT_FILE and EXEC_DENY_INTERACTIVE securebits (Mickaël Salaün) - Add selftests and samples for AT_EXECVE_CHECK (Mickaël Salaün)* tag 'AT_EXECVE_CHECK-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: ima: instantiate the bprm_creds_for_exec() hook samples/check-exec: Add an enlighten "inc" interpreter and 28 tests selftests: ktap_helpers: Fix uninitialized variable samples/check-exec: Add set-exec selftests/landlock: Add tests for execveat + AT_EXECVE_CHECK selftests/exec: Add 32 tests for AT_EXECVE_CHECK and exec securebits security: Add EXEC_RESTRICT_FILE and EXEC_DENY_INTERACTIVE securebits exec: Add a new AT_EXECVE_CHECK flag to execveat(2)
samples/check-exec: Add an enlighten "inc" interpreter and 28 testsAdd a very simple script interpreter called "inc" that can evaluate twodifferent commands (one per line):- "?" to initialize a c
samples/check-exec: Add an enlighten "inc" interpreter and 28 testsAdd a very simple script interpreter called "inc" that can evaluate twodifferent commands (one per line):- "?" to initialize a counter from user's input;- "+" to increment the counter (which is set to 0 by default).It is enlighten to only interpret executable files according toAT_EXECVE_CHECK and the related securebits: # Executing a script with RESTRICT_FILE is only allowed if the script # is executable: ./set-exec -f -- ./inc script-exec.inc # Allowed ./set-exec -f -- ./inc script-noexec.inc # Denied # Executing stdin with DENY_INTERACTIVE is only allowed if stdin is an # executable regular file: ./set-exec -i -- ./inc -i < script-exec.inc # Allowed ./set-exec -i -- ./inc -i < script-noexec.inc # Denied # However, a pipe is not executable and it is then denied: cat script-noexec.inc | ./set-exec -i -- ./inc -i # Denied # Executing raw data (e.g. command argument) with DENY_INTERACTIVE is # always denied. ./set-exec -i -- ./inc -c "+" # Denied ./inc -c "$(<script-ask.inc)" # Allowed # To directly execute a script, we can update $PATH (used by `env`): PATH="${PATH}:." ./script-exec.inc # To execute several commands passed as argument:Add a complete test suite to check the script interpreter against allpossible execution cases: make TARGETS=exec kselftest-install ./tools/testing/selftests/kselftest_install/run_kselftest.shCc: Al Viro <viro@zeniv.linux.org.uk>Cc: Christian Brauner <brauner@kernel.org>Cc: Kees Cook <keescook@chromium.org>Cc: Paul Moore <paul@paul-moore.com>Cc: Serge Hallyn <serge@hallyn.com>Signed-off-by: Mickaël Salaün <mic@digikod.net>Link: https://lore.kernel.org/r/20241212174223.389435-8-mic@digikod.netSigned-off-by: Kees Cook <kees@kernel.org>
selftests/exec: Add 32 tests for AT_EXECVE_CHECK and exec securebitsTest that checks performed by execveat(..., AT_EXECVE_CHECK) areconsistent with noexec mount points and file execute permissions
selftests/exec: Add 32 tests for AT_EXECVE_CHECK and exec securebitsTest that checks performed by execveat(..., AT_EXECVE_CHECK) areconsistent with noexec mount points and file execute permissions.Test that SECBIT_EXEC_RESTRICT_FILE and SECBIT_EXEC_DENY_INTERACTIVE areinherited by child processes and that they can be pinned with theappropriate SECBIT_EXEC_RESTRICT_FILE_LOCKED andSECBIT_EXEC_DENY_INTERACTIVE_LOCKED bits.Cc: Al Viro <viro@zeniv.linux.org.uk>Cc: Christian Brauner <brauner@kernel.org>Cc: Kees Cook <keescook@chromium.org>Cc: Paul Moore <paul@paul-moore.com>Cc: Serge Hallyn <serge@hallyn.com>Signed-off-by: Mickaël Salaün <mic@digikod.net>Link: https://lore.kernel.org/r/20241212174223.389435-4-mic@digikod.netSigned-off-by: Kees Cook <kees@kernel.org>
selftests/exec: add a test for execveat()'s commIn the previous patch we've updated AT_EMPTY_PATH execs to use the dentryfilename. Test for this and just to be sure keeps working with symlinks,wh
selftests/exec: add a test for execveat()'s commIn the previous patch we've updated AT_EMPTY_PATH execs to use the dentryfilename. Test for this and just to be sure keeps working with symlinks,which was a concern in [1], I've added a test for that as well.The test itself is a bit ugly, because the existing check_execveat_fail()helpers use a hardcoded envp and argv, and we want to "pass" things via theenvironment to test various argument values, but it seemed cleaner thanpassing one in everywhere in all the existing tests.Output looks like: ok 51 Check success of execveat(6, 'home/tycho/packages/...yyyyyyyyyyyyyyyyyyyy', 0)... # Check execveat(AT_EMPTY_PATH)'s comm is execveat ok 52 Check success of execveat(9, '', 4096)... # Check execveat(AT_EMPTY_PATH)'s comm is execveat ok 53 Check success of execveat(11, '', 4096)... # Check execveat(AT_EMPTY_PATH)'s comm is execveat [ 25.579272] process 'execveat' launched '/dev/fd/9' with NULL argv: empty string added ok 54 Check success of execveat(9, '', 4096)...Link: https://lore.kernel.org/all/20240925.152228-private.conflict.frozen.trios-TdUGhuI5Sb4v@cyphar.com/ [1]Signed-off-by: Tycho Andersen <tandersen@netflix.com>Link: https://lore.kernel.org/r/20241030203732.248767-2-tycho@tycho.pizzaSigned-off-by: Kees Cook <kees@kernel.org>
selftests: exec: update gitignore for load_addressThe name of the "load_address" objects has been modified, but thecorresponding entry in the gitignore file must be updated.Update the load_addre
selftests: exec: update gitignore for load_addressThe name of the "load_address" objects has been modified, but thecorresponding entry in the gitignore file must be updated.Update the load_address entry in the gitignore file to account forthe new names, adding an exception to keep on tracking load_address.c.Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
selftests/exec: Fix grammar in an error message.Replace "not ... nor" in the error message with "neither ... nor".Signed-off-by: Chang Yu <marcus.yu.56@gmail.com>Signed-off-by: Shuah Khan <skhan
selftests/exec: Fix grammar in an error message.Replace "not ... nor" in the error message with "neither ... nor".Signed-off-by: Chang Yu <marcus.yu.56@gmail.com>Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Merge tag 'mm-stable-2024-07-21-14-50' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mmPull MM updates from Andrew Morton: - In the series "mm: Avoid possible overflows in dirty throttlin
Merge tag 'mm-stable-2024-07-21-14-50' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mmPull MM updates from Andrew Morton: - In the series "mm: Avoid possible overflows in dirty throttling" Jan Kara addresses a couple of issues in the writeback throttling code. These fixes are also targetted at -stable kernels. - Ryusuke Konishi's series "nilfs2: fix potential issues related to reserved inodes" does that. This should actually be in the mm-nonmm-stable tree, along with the many other nilfs2 patches. My bad. - More folio conversions from Kefeng Wang in the series "mm: convert to folio_alloc_mpol()" - Kemeng Shi has sent some cleanups to the writeback code in the series "Add helper functions to remove repeated code and improve readability of cgroup writeback" - Kairui Song has made the swap code a little smaller and a little faster in the series "mm/swap: clean up and optimize swap cache index". - In the series "mm/memory: cleanly support zeropage in vm_insert_page*(), vm_map_pages*() and vmf_insert_mixed()" David Hildenbrand has reworked the rather sketchy handling of the use of the zeropage in MAP_SHARED mappings. I don't see any runtime effects here - more a cleanup/understandability/maintainablity thing. - Dev Jain has improved selftests/mm/va_high_addr_switch.c's handling of higher addresses, for aarch64. The (poorly named) series is "Restructure va_high_addr_switch". - The core TLB handling code gets some cleanups and possible slight optimizations in Bang Li's series "Add update_mmu_tlb_range() to simplify code". - Jane Chu has improved the handling of our fake-an-unrecoverable-memory-error testing feature MADV_HWPOISON in the series "Enhance soft hwpoison handling and injection". - Jeff Johnson has sent a billion patches everywhere to add MODULE_DESCRIPTION() to everything. Some landed in this pull. - In the series "mm: cleanup MIGRATE_SYNC_NO_COPY mode", Kefeng Wang has simplified migration's use of hardware-offload memory copying. - Yosry Ahmed performs more folio API conversions in his series "mm: zswap: trivial folio conversions". - In the series "large folios swap-in: handle refault cases first", Chuanhua Han inches us forward in the handling of large pages in the swap code. This is a cleanup and optimization, working toward the end objective of full support of large folio swapin/out. - In the series "mm,swap: cleanup VMA based swap readahead window calculation", Huang Ying has contributed some cleanups and a possible fixlet to his VMA based swap readahead code. - In the series "add mTHP support for anonymous shmem" Baolin Wang has taught anonymous shmem mappings to use multisize THP. By default this is a no-op - users must opt in vis sysfs controls. Dramatic improvements in pagefault latency are realized. - David Hildenbrand has some cleanups to our remaining use of page_mapcount() in the series "fs/proc: move page_mapcount() to fs/proc/internal.h". - David also has some highmem accounting cleanups in the series "mm/highmem: don't track highmem pages manually". - Build-time fixes and cleanups from John Hubbard in the series "cleanups, fixes, and progress towards avoiding "make headers"". - Cleanups and consolidation of the core pagemap handling from Barry Song in the series "mm: introduce pmd|pte_needs_soft_dirty_wp helpers and utilize them". - Lance Yang's series "Reclaim lazyfree THP without splitting" has reduced the latency of the reclaim of pmd-mapped THPs under fairly common circumstances. A 10x speedup is seen in a microbenchmark. It does this by punting to aother CPU but I guess that's a win unless all CPUs are pegged. - hugetlb_cgroup cleanups from Xiu Jianfeng in the series "mm/hugetlb_cgroup: rework on cftypes". - Miaohe Lin's series "Some cleanups for memory-failure" does just that thing. - Someone other than SeongJae has developed a DAMON feature in Honggyu Kim's series "DAMON based tiered memory management for CXL memory". This adds DAMON features which may be used to help determine the efficiency of our placement of CXL/PCIe attached DRAM. - DAMON user API centralization and simplificatio work in SeongJae Park's series "mm/damon: introduce DAMON parameters online commit function". - In the series "mm: page_type, zsmalloc and page_mapcount_reset()" David Hildenbrand does some maintenance work on zsmalloc - partially modernizing its use of pageframe fields. - Kefeng Wang provides more folio conversions in the series "mm: remove page_maybe_dma_pinned() and page_mkclean()". - More cleanup from David Hildenbrand, this time in the series "mm/memory_hotplug: use PageOffline() instead of PageReserved() for !ZONE_DEVICE". It "enlightens memory hotplug more about PageOffline() pages" and permits the removal of some virtio-mem hacks. - Barry Song's series "mm: clarify folio_add_new_anon_rmap() and __folio_add_anon_rmap()" is a cleanup to the anon folio handling in preparation for mTHP (multisize THP) swapin. - Kefeng Wang's series "mm: improve clear and copy user folio" implements more folio conversions, this time in the area of large folio userspace copying. - The series "Docs/mm/damon/maintaier-profile: document a mailing tool and community meetup series" tells people how to get better involved with other DAMON developers. From SeongJae Park. - A large series ("kmsan: Enable on s390") from Ilya Leoshkevich does that. - David Hildenbrand sends along more cleanups, this time against the migration code. The series is "mm/migrate: move NUMA hinting fault folio isolation + checks under PTL". - Jan Kara has found quite a lot of strangenesses and minor errors in the readahead code. He addresses this in the series "mm: Fix various readahead quirks". - SeongJae Park's series "selftests/damon: test DAMOS tried regions and {min,max}_nr_regions" adds features and addresses errors in DAMON's self testing code. - Gavin Shan has found a userspace-triggerable WARN in the pagecache code. The series "mm/filemap: Limit page cache size to that supported by xarray" addresses this. The series is marked cc:stable. - Chengming Zhou's series "mm/ksm: cmp_and_merge_page() optimizations and cleanup" cleans up and slightly optimizes KSM. - Roman Gushchin has separated the memcg-v1 and memcg-v2 code - lots of code motion. The series (which also makes the memcg-v1 code Kconfigurable) are "mm: memcg: separate legacy cgroup v1 code and put under config option" and "mm: memcg: put cgroup v1-specific memcg data under CONFIG_MEMCG_V1" - Dan Schatzberg's series "Add swappiness argument to memory.reclaim" adds an additional feature to this cgroup-v2 control file. - The series "Userspace controls soft-offline pages" from Jiaqi Yan permits userspace to stop the kernel's automatic treatment of excessive correctable memory errors. In order to permit userspace to monitor and handle this situation. - Kefeng Wang's series "mm: migrate: support poison recover from migrate folio" teaches the kernel to appropriately handle migration from poisoned source folios rather than simply panicing. - SeongJae Park's series "Docs/damon: minor fixups and improvements" does those things. - In the series "mm/zsmalloc: change back to per-size_class lock" Chengming Zhou improves zsmalloc's scalability and memory utilization. - Vivek Kasireddy's series "mm/gup: Introduce memfd_pin_folios() for pinning memfd folios" makes the GUP code use FOLL_PIN rather than bare refcount increments. So these paes can first be moved aside if they reside in the movable zone or a CMA block. - Andrii Nakryiko has added a binary ioctl()-based API to /proc/pid/maps for much faster reading of vma information. The series is "query VMAs from /proc/<pid>/maps". - In the series "mm: introduce per-order mTHP split counters" Lance Yang improves the kernel's presentation of developer information related to multisize THP splitting. - Michael Ellerman has developed the series "Reimplement huge pages without hugepd on powerpc (8xx, e500, book3s/64)". This permits userspace to use all available huge page sizes. - In the series "revert unconditional slab and page allocator fault injection calls" Vlastimil Babka removes a performance-affecting and not very useful feature from slab fault injection.* tag 'mm-stable-2024-07-21-14-50' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (411 commits) mm/mglru: fix ineffective protection calculation mm/zswap: fix a white space issue mm/hugetlb: fix kernel NULL pointer dereference when migrating hugetlb folio mm/hugetlb: fix possible recursive locking detected warning mm/gup: clear the LRU flag of a page before adding to LRU batch mm/numa_balancing: teach mpol_to_str about the balancing mode mm: memcg1: convert charge move flags to unsigned long long alloc_tag: fix page_ext_get/page_ext_put sequence during page splitting lib: reuse page_ext_data() to obtain codetag_ref lib: add missing newline character in the warning message mm/mglru: fix overshooting shrinker memory mm/mglru: fix div-by-zero in vmpressure_calc_level() mm/kmemleak: replace strncpy() with strscpy() mm, page_alloc: put should_fail_alloc_page() back behing CONFIG_FAIL_PAGE_ALLOC mm, slab: put should_failslab() back behind CONFIG_SHOULD_FAILSLAB mm: ignore data-race in __swap_writepage hugetlbfs: ensure generic_hugetlb_get_unmapped_area() returns higher address than mmap_min_addr mm: shmem: rename mTHP shmem counters mm: swap_state: use folio_alloc_mpol() in __read_swap_cache_async() mm/migrate: putback split folios when numa hint migration fails ...
selftests: centralize -D_GNU_SOURCE= to CFLAGS in lib.mkCentralize the _GNU_SOURCE definition to CFLAGS in lib.mk. Removeredundant defines from Makefiles that import lib.mk. Convert any usage of
selftests: centralize -D_GNU_SOURCE= to CFLAGS in lib.mkCentralize the _GNU_SOURCE definition to CFLAGS in lib.mk. Removeredundant defines from Makefiles that import lib.mk. Convert any usage of"#define _GNU_SOURCE 1" to "#define _GNU_SOURCE".This uses the form "-D_GNU_SOURCE=", which is equivalent to"#define _GNU_SOURCE".Otherwise using "-D_GNU_SOURCE" is equivalent to "-D_GNU_SOURCE=1" and"#define _GNU_SOURCE 1", which is less commonly seen in source code andwould require many changes in selftests to avoid redefinition warnings.Link: https://lkml.kernel.org/r/20240625223454.1586259-2-edliaw@google.comSigned-off-by: Edward Liaw <edliaw@google.com>Suggested-by: John Hubbard <jhubbard@nvidia.com>Acked-by: Shuah Khan <skhan@linuxfoundation.org>Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Cc: Albert Ou <aou@eecs.berkeley.edu>Cc: André Almeida <andrealmeid@igalia.com>Cc: Darren Hart <dvhart@infradead.org>Cc: Dave Hansen <dave.hansen@linux.intel.com>Cc: Davidlohr Bueso <dave@stgolabs.net>Cc: David S. Miller <davem@davemloft.net>Cc: Eric Dumazet <edumazet@google.com>Cc: Eric W. Biederman <ebiederm@xmission.com>Cc: Fenghua Yu <fenghua.yu@intel.com>Cc: Ingo Molnar <mingo@redhat.com>Cc: Jakub Kicinski <kuba@kernel.org>Cc: Jarkko Sakkinen <jarkko@kernel.org>Cc: Jason Gunthorpe <jgg@ziepe.ca>Cc: Kees Cook <kees@kernel.org>Cc: Kevin Tian <kevin.tian@intel.com>Cc: Palmer Dabbelt <palmer@dabbelt.com>Cc: Paolo Abeni <pabeni@redhat.com>Cc: Paolo Bonzini <pbonzini@redhat.com>Cc: Paul Walmsley <paul.walmsley@sifive.com>Cc: Peter Zijlstra <peterz@infradead.org>Cc: Reinette Chatre <reinette.chatre@intel.com>Cc: Sean Christopherson <seanjc@google.com>Cc: Thomas Gleixner <tglx@linutronix.de>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
binfmt_elf: Honor PT_LOAD alignment for static PIEThe p_align values in PT_LOAD were ignored for static PIE executables(i.e. ET_DYN without PT_INTERP). This is because there is no way torequest a
binfmt_elf: Honor PT_LOAD alignment for static PIEThe p_align values in PT_LOAD were ignored for static PIE executables(i.e. ET_DYN without PT_INTERP). This is because there is no way torequest a non-fixed mmap region with a specific alignment. ET_DYN withPT_INTERP uses a separate base address (ELF_ET_DYN_BASE) and binfmt_elfperforms the ASLR itself, which means it can also apply alignment. Forthe mmap region, the address selection happens deep within the vm_mmap()implementation (when the requested address is 0).The earlier attempt to implement this: commit 9630f0d60fec ("fs/binfmt_elf: use PT_LOAD p_align values for static PIE") commit 925346c129da ("fs/binfmt_elf: fix PT_LOAD p_align values for loaders")did not take into account the different base address origins, and wereeventually reverted: aeb7923733d1 ("revert "fs/binfmt_elf: use PT_LOAD p_align values for static PIE"")In order to get the correct alignment from an mmap base, binfmt_elf mustperform a 0-address load first, then tear down the mapping and performalignment on the resulting address. Since this is slightly more overhead,only do this when it is needed (i.e. the alignment is not the defaultELF alignment). This does, however, have the benefit of being able touse MAP_FIXED_NOREPLACE, to avoid potential collisions.With this fixed, enable the static PIE self tests again.Reported-by: H.J. Lu <hjl.tools@gmail.com>Closes: https://bugzilla.kernel.org/show_bug.cgi?id=215275Link: https://lore.kernel.org/r/20240508173149.677910-3-keescook@chromium.orgSigned-off-by: Kees Cook <kees@kernel.org>
selftests/exec: Build both static and non-static load_address testsAfter commit 4d1cd3b2c5c1 ("tools/testing/selftests/exec: fix linkerror"), the load address alignment tests tried to build static
selftests/exec: Build both static and non-static load_address testsAfter commit 4d1cd3b2c5c1 ("tools/testing/selftests/exec: fix linkerror"), the load address alignment tests tried to build statically.This was silently ignored in some cases. However, after attempting tofurther fix the build by switching to "-static-pie", the test startedfailing. This appears to be due to non-PT_INTERP ET_DYN execs ("staticPIE") not doing alignment correctly, which remains unfixed[1]. See commitaeb7923733d1 ("revert "fs/binfmt_elf: use PT_LOAD p_align values forstatic PIE"") for more details.Provide rules to build both static and non-static PIE binaries, improvedebug reporting, and perform several test steps instead of a singleall-or-nothing test. However, do not actually enable static-pie tests;alignment specification is only supported for ET_DYN with PT_INTERP("regular PIE").Link: https://bugzilla.kernel.org/show_bug.cgi?id=215275 [1]Link: https://lore.kernel.org/r/20240508173149.677910-1-keescook@chromium.orgSigned-off-by: Kees Cook <kees@kernel.org>
selftests: exec: Use new ksft_exit_fail_perror() helperUse ksft_exit_fail_perror() to print the value of errno and its stringform. This is the first user of the ksft_exit_fail_perror() and proves
selftests: exec: Use new ksft_exit_fail_perror() helperUse ksft_exit_fail_perror() to print the value of errno and its stringform. This is the first user of the ksft_exit_fail_perror() and provesthe usefulness of this API.Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
selftests/exec: Convert remaining /bin/sh to /bin/bashAs was intended with commit 17107429947b ("selftests/exec: Perform scriptchecks with /bin/bash"), convert the other instance of /bin/sh to/bi
selftests/exec: Convert remaining /bin/sh to /bin/bashAs was intended with commit 17107429947b ("selftests/exec: Perform scriptchecks with /bin/bash"), convert the other instance of /bin/sh to/bin/bash. It appears that at least Debian Bookworm's /bin/sh (dash)does not conform to POSIX's "return 127 when script not found"requirement.Fixes: 17107429947b ("selftests/exec: Perform script checks with /bin/bash")Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Closes: https://lore.kernel.org/lkml/02c8bf8e-1934-44ab-a886-e065b37366a7@collabora.com/Signed-off-by: Kees Cook <keescook@chromium.org>
selftests/exec: execveat: Improve debug reportingChildren processes were reporting their status, duplicating theparent's. Remove that, and add some additional details about the testexecution.Re
selftests/exec: execveat: Improve debug reportingChildren processes were reporting their status, duplicating theparent's. Remove that, and add some additional details about the testexecution.Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Link: https://lore.kernel.org/r/20240313185606.work.073-kees@kernel.orgSigned-off-by: Kees Cook <keescook@chromium.org>
selftests/exec: recursion-depth: conform test to TAP format outputConform the layout, informational and status messages to TAP. Nofunctional change is intended other than the layout of output mess
selftests/exec: recursion-depth: conform test to TAP format outputConform the layout, informational and status messages to TAP. Nofunctional change is intended other than the layout of output messages.While at it, do minor cleanups like move the declarations of the variableson top of the function.Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Link: https://lore.kernel.org/r/20240304155928.1818928-3-usama.anjum@collabora.comSigned-off-by: Kees Cook <keescook@chromium.org>
selftests/exec: load_address: conform test to TAP format outputConform the layout, informational and status messages to TAP. Nofunctional change is intended other than the layout of output message
selftests/exec: load_address: conform test to TAP format outputConform the layout, informational and status messages to TAP. Nofunctional change is intended other than the layout of output messages.Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Link: https://lore.kernel.org/r/20240304155928.1818928-2-usama.anjum@collabora.comSigned-off-by: Kees Cook <keescook@chromium.org>
selftests/exec: binfmt_script: Add the overall result line according to TAPThe following line is missing from the test's execution. Add it to makeit fully TAP conformant: # Totals: pass:27 fail:
selftests/exec: binfmt_script: Add the overall result line according to TAPThe following line is missing from the test's execution. Add it to makeit fully TAP conformant: # Totals: pass:27 fail:0 xfail:0 xpass:0 skip:0 error:0Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Reviewed-by: Kees Cook <keescook@chromium.org>Link: https://lore.kernel.org/r/20240304155928.1818928-1-usama.anjum@collabora.comSigned-off-by: Kees Cook <keescook@chromium.org>
selftests/exec: Perform script checks with /bin/bashIt seems some shells linked to /bin/sh don't have consistent behaviorwith error codes on execution failures. Explicitly use /bin/bash so that"n
selftests/exec: Perform script checks with /bin/bashIt seems some shells linked to /bin/sh don't have consistent behaviorwith error codes on execution failures. Explicitly use /bin/bash so that"not found" errors are correctly generated. Repeating the comment fromthe test:/* * Execute as a long pathname relative to "/". If this is a script, * the interpreter will launch but fail to open the script because its * name ("/dev/fd/5/xxx....") is bigger than PATH_MAX. * * The failure code is usually 127 (POSIX: "If a command is not found, * the exit status shall be 127."), but some systems give 126 (POSIX: * "If the command name is found, but it is not an executable utility, * the exit status shall be 126."), so allow either. */Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Closes: https://lore.kernel.org/lkml/02c8bf8e-1934-44ab-a886-e065b37366a7@collabora.com/Signed-off-by: Kees Cook <keescook@chromium.org>---Cc: Eric Biederman <ebiederm@xmission.com>Cc: Shuah Khan <shuah@kernel.org>Cc: Mark Brown <broonie@kernel.org>Cc: linux-mm@kvack.orgCc: linux-kselftest@vger.kernel.org
selftests/exec: Convert execveat test to generate KTAP outputCurrently the execveat test does not produce KTAP output but rather acustom format. This means that we only get a pass/fail for the sui
selftests/exec: Convert execveat test to generate KTAP outputCurrently the execveat test does not produce KTAP output but rather acustom format. This means that we only get a pass/fail for the suite, notfor each individual test that the suite does. Convert to using the standardkselftest output functions which result in KTAP output being generated.The main trick with this is that, being an exec() related test, theprogram executes itself and returns specific exit codes to verifysuccess meaning that we need to only use the top level kselftestheader/summary functions when invoked directly rather than when run aspart of a test.Signed-off-by: Mark Brown <broonie@kernel.org>Reviewed-by: Kees Cook <keescook@chromium.org>Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Merge tag 'linux-kselftest-next-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftestPull Kselftest updates from Shuah Khan: "Several build and cleanup fixes: - remo
Merge tag 'linux-kselftest-next-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftestPull Kselftest updates from Shuah Khan: "Several build and cleanup fixes: - removing obsolete config options - removing dependency on internal kernel macros - adding config options - several build fixes related to headers and install paths"* tag 'linux-kselftest-next-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (22 commits) selftests: Fix build when $(O) points to a relative path selftests: netfilter: fix a build error on openSUSE selftests: kvm: add generated file to the .gitignore selftests/exec: add generated files to .gitignore selftests: add kselftest_install to .gitignore selftests/rtc: continuously read RTC in a loop for 30s selftests/lkdtm: Add UBSAN config selftests/lkdtm: Remove dead config option selftests/exec: Rename file binfmt_script to binfmt_script.py selftests: Use -isystem instead of -I to include headers selftests: vm: remove dependecy from internal kernel macros selftests: vm: Add the uapi headers include variable selftests: mptcp: Add the uapi headers include variable selftests: net: Add the uapi headers include variable selftests: landlock: Add the uapi headers include variable selftests: kvm: Add the uapi headers include variable selftests: futex: Add the uapi headers include variable selftests: Correct the headers install path selftests: Add and export a kernel uapi headers path selftests: set the BUILD variable to absolute path ...
Merge tag 'execve-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxPull execve updates from Kees Cook: "Execve and binfmt updates. Eric and I have stepped up to be the acti
Merge tag 'execve-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxPull execve updates from Kees Cook: "Execve and binfmt updates. Eric and I have stepped up to be the active maintainers of this area, so here's our first collection. The bulk of the work was in coredump handling fixes; additional details are noted below: - Handle unusual AT_PHDR offsets (Akira Kawata) - Fix initial mapping size when PT_LOADs are not ordered (Alexey Dobriyan) - Move more code under CONFIG_COREDUMP (Alexey Dobriyan) - Fix missing mmap_lock in file_files_note (Eric W. Biederman) - Remove a.out support for alpha and m68k (Eric W. Biederman) - Include first pages of non-exec ELF libraries in coredump (Jann Horn) - Don't write past end of notes for regset gap in coredump (Rick Edgecombe) - Comment clean-ups (Tom Rix) - Force single empty string when argv is empty (Kees Cook) - Add NULL argv selftest (Kees Cook) - Properly redefine PT_GNU_* in terms of PT_LOOS (Kees Cook) - MAINTAINERS: Update execve entry with tree (Kees Cook) - Introduce initial KUnit testing for binfmt_elf (Kees Cook)"* tag 'execve-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: binfmt_elf: Don't write past end of notes for regset gap a.out: Stop building a.out/osf1 support on alpha and m68k coredump: Don't compile flat_core_dump when coredumps are disabled coredump: Use the vma snapshot in fill_files_note coredump/elf: Pass coredump_params into fill_note_info coredump: Remove the WARN_ON in dump_vma_snapshot coredump: Snapshot the vmas in do_coredump coredump: Move definition of struct coredump_params into coredump.h binfmt_elf: Introduce KUnit test ELF: Properly redefine PT_GNU_* in terms of PT_LOOS MAINTAINERS: Update execve entry with more details exec: cleanup comments fs/binfmt_elf: Refactor load_elf_binary function fs/binfmt_elf: Fix AT_PHDR for unusual ELF files binfmt: move more stuff undef CONFIG_COREDUMP selftests/exec: Test for empty string on NULL argv exec: Force single empty string when argv is empty coredump: Also dump first pages of non-executable ELF libraries ELF: fix overflow in total mapping size calculation
selftests/exec: add generated files to .gitignoreAdd generated files non-regular and null-argv to .gitignore file.Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Reviewed-by: Kees
selftests/exec: add generated files to .gitignoreAdd generated files non-regular and null-argv to .gitignore file.Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Reviewed-by: Kees Cook <keescook@chromium.org>Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
selftests/exec: Test for empty string on NULL argvTest for the NULL argv argument producing a single empty string on exec.Cc: Eric Biederman <ebiederm@xmission.com>Cc: Shuah Khan <shuah@kernel.o
selftests/exec: Test for empty string on NULL argvTest for the NULL argv argument producing a single empty string on exec.Cc: Eric Biederman <ebiederm@xmission.com>Cc: Shuah Khan <shuah@kernel.org>Cc: Yang Yingliang <yangyingliang@huawei.com>Cc: Andrew Morton <akpm@linux-foundation.org>Cc: linux-kselftest@vger.kernel.orgSigned-off-by: Kees Cook <keescook@chromium.org>Link: https://lore.kernel.org/lkml/20220201011637.2457646-1-keescook@chromium.org
selftests/exec: Rename file binfmt_script to binfmt_script.pyRename file for readability purpose. Update its usage and references.Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>R
selftests/exec: Rename file binfmt_script to binfmt_script.pyRename file for readability purpose. Update its usage and references.Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>Reviewed-by: Kees Cook <keescook@chromium.org>Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
123