Hi Arnout,

On Fri, Dec 5, 2025 at 9:53 AM Arnout Engelen <[email protected]> wrote:
>
> Previously, the 'second' test would test the `RESOLVE_IN_ROOT` feature
> when the current libc supports it, even when the currently running
> kernel did not yet support it.
>
> Signed-off-by: Arnout Engelen <[email protected]>
> ---
>  tests/run-sysroot.sh | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/tests/run-sysroot.sh b/tests/run-sysroot.sh
> index fe302446..d2041e8a 100755
> --- a/tests/run-sysroot.sh
> +++ b/tests/run-sysroot.sh
> @@ -46,10 +46,14 @@ TID 431185:
>  #8  0x0000aaaae56127f0 _start
>  EOF
>
> -HAVE_OPENAT2=$(grep '^#define HAVE_OPENAT2_RESOLVE_IN_ROOT' \
> -                    ${abs_builddir}/../config.h | awk '{print $3}')
> +libc_has_openat2_resolve_in_root() {
> +  grep '^#define HAVE_OPENAT2_RESOLVE_IN_ROOT' ${abs_builddir}/../config.h | 
> awk '{print $3}'
> +}
> +kernel_has_openat2_resolve_in_root() {
> +  printf "%s\n%s" "5.6.0" "$(uname -r)" | sort -V -C
> +}
>
> -if [[ "$HAVE_OPENAT2" = 1 ]]; then
> +if libc_has_openat2_resolve_in_root && kernel_has_openat2_resolve_in_root; 
> then
>      # Change the layout of files in sysroot to test symlink escape scenario
>      rm -f "${tmpdir}/sysroot/bin"
>      mkdir "${tmpdir}/sysroot/bin"
> @@ -57,7 +61,8 @@ if [[ "$HAVE_OPENAT2" = 1 ]]; then
>      ln -s /bin/bash "${tmpdir}/sysroot/usr/bin/bash"
>
>      # Check that stack with --sysroot generates correct backtrace even if 
> target
> -    # binary is actually absolute symlink pointing outside of sysroot 
> directory
> +    # binary is actually absolute symlink to be interpreted relative to the 
> sysroot
> +    # directory
>      testrun "${abs_top_builddir}"/src/stack --core "${tmpdir}/core.bash" \
>             --sysroot "${tmpdir}/sysroot" >"${tmpdir}/stack.out"
>
> --
> 2.51.2
>

I think this fix works but it would be better to just define
HAVE_OPENAT2_RESOLVE_IN_ROOT when both libc and kernel support are
present. This approach has the advantage of not including the eu-stack
--sysroot option when glibc supports RESOLVE_IN_ROOT but the kernel
doesn't.

I posted a small patch that tweaks configure.ac so that libc and
kernel RESOVLE_IN_ROOT support is verified at build time. Does this
work for you: https://sourceware.org/pipermail/elfutils-devel/2025q4/008838.html

Aaron

Reply via email to