* [PATCH 6.4 209/239] selftests/rseq: Play nice with binaries statically linked against glibc 2.35+
[not found] <20230801091925.659598007@linuxfoundation.org>
@ 2023-08-01 9:21 ` Greg Kroah-Hartman
2023-08-02 2:52 ` [PATCH 6.4 000/239] 6.4.8-rc1 review Naresh Kamboju
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-08-01 9:21 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Aaron Lewis, kvm,
Sean Christopherson, Paolo Bonzini
From: Sean Christopherson <seanjc@google.com>
commit 3bcbc20942db5d738221cca31a928efc09827069 upstream.
To allow running rseq and KVM's rseq selftests as statically linked
binaries, initialize the various "trampoline" pointers to point directly
at the expect glibc symbols, and skip the dlysm() lookups if the rseq
size is non-zero, i.e. the binary is statically linked *and* the libc
registered its own rseq.
Define weak versions of the symbols so as not to break linking against
libc versions that don't support rseq in any capacity.
The KVM selftests in particular are often statically linked so that they
can be run on targets with very limited runtime environments, i.e. test
machines.
Fixes: 233e667e1ae3 ("selftests/rseq: Uplift rseq selftests for compatibility with glibc-2.35")
Cc: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20230721223352.2333911-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
tools/testing/selftests/rseq/rseq.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
--- a/tools/testing/selftests/rseq/rseq.c
+++ b/tools/testing/selftests/rseq/rseq.c
@@ -34,9 +34,17 @@
#include "../kselftest.h"
#include "rseq.h"
-static const ptrdiff_t *libc_rseq_offset_p;
-static const unsigned int *libc_rseq_size_p;
-static const unsigned int *libc_rseq_flags_p;
+/*
+ * Define weak versions to play nice with binaries that are statically linked
+ * against a libc that doesn't support registering its own rseq.
+ */
+__weak ptrdiff_t __rseq_offset;
+__weak unsigned int __rseq_size;
+__weak unsigned int __rseq_flags;
+
+static const ptrdiff_t *libc_rseq_offset_p = &__rseq_offset;
+static const unsigned int *libc_rseq_size_p = &__rseq_size;
+static const unsigned int *libc_rseq_flags_p = &__rseq_flags;
/* Offset from the thread pointer to the rseq area. */
ptrdiff_t rseq_offset;
@@ -155,9 +163,17 @@ unsigned int get_rseq_feature_size(void)
static __attribute__((constructor))
void rseq_init(void)
{
- libc_rseq_offset_p = dlsym(RTLD_NEXT, "__rseq_offset");
- libc_rseq_size_p = dlsym(RTLD_NEXT, "__rseq_size");
- libc_rseq_flags_p = dlsym(RTLD_NEXT, "__rseq_flags");
+ /*
+ * If the libc's registered rseq size isn't already valid, it may be
+ * because the binary is dynamically linked and not necessarily due to
+ * libc not having registered a restartable sequence. Try to find the
+ * symbols if that's the case.
+ */
+ if (!*libc_rseq_size_p) {
+ libc_rseq_offset_p = dlsym(RTLD_NEXT, "__rseq_offset");
+ libc_rseq_size_p = dlsym(RTLD_NEXT, "__rseq_size");
+ libc_rseq_flags_p = dlsym(RTLD_NEXT, "__rseq_flags");
+ }
if (libc_rseq_size_p && libc_rseq_offset_p && libc_rseq_flags_p &&
*libc_rseq_size_p != 0) {
/* rseq registration owned by glibc */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6.4 000/239] 6.4.8-rc1 review
[not found] <20230801091925.659598007@linuxfoundation.org>
2023-08-01 9:21 ` [PATCH 6.4 209/239] selftests/rseq: Play nice with binaries statically linked against glibc 2.35+ Greg Kroah-Hartman
@ 2023-08-02 2:52 ` Naresh Kamboju
2023-08-02 6:53 ` Greg Kroah-Hartman
1 sibling, 1 reply; 3+ messages in thread
From: Naresh Kamboju @ 2023-08-02 2:52 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: stable, patches, linux-kernel, torvalds, akpm, linux, shuah,
patches, lkft-triage, pavel, jonathanh, f.fainelli,
sudipm.mukherjee, srw, rwarsow, conor, Aaron Lewis, kvm list,
Sean Christopherson, Paolo Bonzini,
open list:KERNEL SELFTEST FRAMEWORK
On Tue, 1 Aug 2023 at 15:11, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> This is the start of the stable review cycle for the 6.4.8 release.
> There are 239 patches in this series, all will be posted as a response
> to this one. If anyone has any issues with these being applied, please
> let me know.
>
> Responses should be made by Thu, 03 Aug 2023 09:18:38 +0000.
> Anything received after that time might be too late.
>
> The whole patch series can be found in one patch at:
> https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.4.8-rc1.gz
> or in the git tree and branch at:
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.4.y
> and the diffstat can be found below.
>
> thanks,
>
> greg k-h
Following kselftest build regression found,
selftests/rseq: Play nice with binaries statically linked against
glibc 2.35+
commit 3bcbc20942db5d738221cca31a928efc09827069 upstream.
To allow running rseq and KVM's rseq selftests as statically linked
binaries, initialize the various "trampoline" pointers to point directly
at the expect glibc symbols, and skip the dlysm() lookups if the rseq
size is non-zero, i.e. the binary is statically linked *and* the libc
registered its own rseq.
Define weak versions of the symbols so as not to break linking against
libc versions that don't support rseq in any capacity.
The KVM selftests in particular are often statically linked so that they
can be run on targets with very limited runtime environments, i.e. test
machines.
Fixes: 233e667e1ae3 ("selftests/rseq: Uplift rseq selftests for
compatibility with glibc-2.35")
Cc: Aaron Lewis <aaronlewis@google.com>
Cc: kvm@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20230721223352.2333911-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Build log:
----
x86_64-linux-gnu-gcc -O2 -Wall -g -I./ -isystem
/home/tuxbuild/.cache/tuxmake/builds/1/build/usr/include
-L/home/tuxbuild/.cache/tuxmake/builds/1/build/kselftest/rseq
-Wl,-rpath=./ -shared -fPIC rseq.c -lpthread -ldl -o
/home/tuxbuild/.cache/tuxmake/builds/1/build/kselftest/rseq/librseq.so
rseq.c:41:1: error: unknown type name '__weak'
41 | __weak ptrdiff_t __rseq_offset;
| ^~~~~~
rseq.c:41:18: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '__rseq_offset'
41 | __weak ptrdiff_t __rseq_offset;
| ^~~~~~~~~~~~~
rseq.c:42:7: error: expected ';' before 'unsigned'
42 | __weak unsigned int __rseq_size;
| ^~~~~~~~~
| ;
rseq.c:43:7: error: expected ';' before 'unsigned'
43 | __weak unsigned int __rseq_flags;
| ^~~~~~~~~
| ;
rseq.c:45:47: error: '__rseq_offset' undeclared here (not in a
function); did you mean 'rseq_offset'?
45 | static const ptrdiff_t *libc_rseq_offset_p = &__rseq_offset;
| ^~~~~~~~~~~~~
| rseq_offset
make[3]: Leaving directory 'tools/testing/selftests/rseq'
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Links:
- https://storage.tuxsuite.com/public/linaro/lkft/builds/2TNSVjRCfcIaJWQNkPwDQ9jn2ls/build.log
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.4.y/build/v6.4.7-240-g2c273bf138a4/testrun/18770115/suite/kselftest-rseq/test/shardfile-rseq/details/
--
Linaro LKFT
https://lkft.linaro.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6.4 000/239] 6.4.8-rc1 review
2023-08-02 2:52 ` [PATCH 6.4 000/239] 6.4.8-rc1 review Naresh Kamboju
@ 2023-08-02 6:53 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-08-02 6:53 UTC (permalink / raw)
To: Naresh Kamboju
Cc: stable, patches, linux-kernel, torvalds, akpm, linux, shuah,
patches, lkft-triage, pavel, jonathanh, f.fainelli,
sudipm.mukherjee, srw, rwarsow, conor, Aaron Lewis, kvm list,
Sean Christopherson, Paolo Bonzini,
open list:KERNEL SELFTEST FRAMEWORK
On Wed, Aug 02, 2023 at 08:22:59AM +0530, Naresh Kamboju wrote:
> On Tue, 1 Aug 2023 at 15:11, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > This is the start of the stable review cycle for the 6.4.8 release.
> > There are 239 patches in this series, all will be posted as a response
> > to this one. If anyone has any issues with these being applied, please
> > let me know.
> >
> > Responses should be made by Thu, 03 Aug 2023 09:18:38 +0000.
> > Anything received after that time might be too late.
> >
> > The whole patch series can be found in one patch at:
> > https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.4.8-rc1.gz
> > or in the git tree and branch at:
> > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.4.y
> > and the diffstat can be found below.
> >
> > thanks,
> >
> > greg k-h
>
> Following kselftest build regression found,
>
> selftests/rseq: Play nice with binaries statically linked against
> glibc 2.35+
> commit 3bcbc20942db5d738221cca31a928efc09827069 upstream.
>
>
> To allow running rseq and KVM's rseq selftests as statically linked
> binaries, initialize the various "trampoline" pointers to point directly
> at the expect glibc symbols, and skip the dlysm() lookups if the rseq
> size is non-zero, i.e. the binary is statically linked *and* the libc
> registered its own rseq.
>
> Define weak versions of the symbols so as not to break linking against
> libc versions that don't support rseq in any capacity.
>
> The KVM selftests in particular are often statically linked so that they
> can be run on targets with very limited runtime environments, i.e. test
> machines.
>
> Fixes: 233e667e1ae3 ("selftests/rseq: Uplift rseq selftests for
> compatibility with glibc-2.35")
> Cc: Aaron Lewis <aaronlewis@google.com>
> Cc: kvm@vger.kernel.org
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> Message-Id: <20230721223352.2333911-1-seanjc@google.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
>
> Build log:
> ----
> x86_64-linux-gnu-gcc -O2 -Wall -g -I./ -isystem
> /home/tuxbuild/.cache/tuxmake/builds/1/build/usr/include
> -L/home/tuxbuild/.cache/tuxmake/builds/1/build/kselftest/rseq
> -Wl,-rpath=./ -shared -fPIC rseq.c -lpthread -ldl -o
> /home/tuxbuild/.cache/tuxmake/builds/1/build/kselftest/rseq/librseq.so
> rseq.c:41:1: error: unknown type name '__weak'
> 41 | __weak ptrdiff_t __rseq_offset;
> | ^~~~~~
> rseq.c:41:18: error: expected '=', ',', ';', 'asm' or '__attribute__'
> before '__rseq_offset'
> 41 | __weak ptrdiff_t __rseq_offset;
> | ^~~~~~~~~~~~~
> rseq.c:42:7: error: expected ';' before 'unsigned'
> 42 | __weak unsigned int __rseq_size;
> | ^~~~~~~~~
> | ;
> rseq.c:43:7: error: expected ';' before 'unsigned'
> 43 | __weak unsigned int __rseq_flags;
> | ^~~~~~~~~
> | ;
> rseq.c:45:47: error: '__rseq_offset' undeclared here (not in a
> function); did you mean 'rseq_offset'?
> 45 | static const ptrdiff_t *libc_rseq_offset_p = &__rseq_offset;
> | ^~~~~~~~~~~~~
> | rseq_offset
> make[3]: Leaving directory 'tools/testing/selftests/rseq'
>
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
>
> Links:
> - https://storage.tuxsuite.com/public/linaro/lkft/builds/2TNSVjRCfcIaJWQNkPwDQ9jn2ls/build.log
> - https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.4.y/build/v6.4.7-240-g2c273bf138a4/testrun/18770115/suite/kselftest-rseq/test/shardfile-rseq/details/
Odd this didn't also show up in 6.1. I'll go drop the offending commit
for now.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-02 6:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230801091925.659598007@linuxfoundation.org>
2023-08-01 9:21 ` [PATCH 6.4 209/239] selftests/rseq: Play nice with binaries statically linked against glibc 2.35+ Greg Kroah-Hartman
2023-08-02 2:52 ` [PATCH 6.4 000/239] 6.4.8-rc1 review Naresh Kamboju
2023-08-02 6:53 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox