Re: [PATCH v2] selftests: fix relative rpath usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/12/24 10:56, Eugene Syromiatnikov wrote:
The relative RPATH ("./") supplied to linker options in CFLAGS is resolved
relative to current working directory and not the executable directory,
which will lead in incorrect resolution when the test executables are run
from elsewhere.  Changing it to $ORIGIN makes it resolve relative
to the directory in which the executables reside, which is supposedly
the desired behaviour.  This patch also moves these CFLAGS to lib.mk,
so the RPATH is provided for all selftest binaries, which is arguably
a useful default.

Can you elaborate on the erros you would see if this isn't fixed? I understand
that check-rpaths tool - howebver I would like to know how it manifests and
how would you reproduce this problem while running selftests?


Discovered by the check-rpaths script[1][2] that checks for insecure
RPATH/RUNPATH[3], such as relative directories, during an attempt
to package BPF selftests for later use in CI:

     ERROR   0004: file '/usr/libexec/kselftests/bpf/urandom_read' contains an insecure runpath '.' in [.]

[1] https://github.com/rpm-software-management/rpm/blob/master/scripts/check-rpaths
[2] https://github.com/rpm-software-management/rpm/blob/master/scripts/check-rpaths-worker
[3] https://cwe.mitre.org/data/definitions/426.html

Signed-off-by: Eugene Syromiatnikov <esyr@xxxxxxxxxx>
---
v2:
   - Consolidated the updated -L/-Wl,-rpath setting into lib.mk
   - Described the testing done in the commit message
v1: https://lore.kernel.org/lkml/20240808145639.GA20510@xxxxxxxxxxxxxxxxx/
     https://lore.kernel.org/lkml/20240808151335.GA5495@xxxxxxxxxxxxxxxxx/
     https://lore.kernel.org/lkml/20240808151621.GA10025@xxxxxxxxxxxxxxxxx/
     https://lore.kernel.org/lkml/20240808151621.GA10025@xxxxxxxxxxxxxxxxx/
---
  tools/testing/selftests/alsa/Makefile  | 1 -
  tools/testing/selftests/bpf/Makefile   | 5 ++---
  tools/testing/selftests/lib.mk         | 3 +++
  tools/testing/selftests/rseq/Makefile  | 2 +-
  tools/testing/selftests/sched/Makefile | 3 +--
  5 files changed, 7 insertions(+), 7 deletions(-)

thanks,
-- Shuah





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux