lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 3 Aug 2022 19:26:27 +0200
From:   Andrew Jones <andrew.jones@...ux.dev>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Jinrong Liang <ljr.kernel@...il.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Joerg Roedel <joro@...tes.org>,
        Jinrong Liang <cloudliang@...cent.com>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests: kvm: Fix a compile error in
 selftests/kvm/rseq_test.c

On Wed, Aug 03, 2022 at 04:10:53PM +0000, Sean Christopherson wrote:
> On Wed, Aug 03, 2022, Andrew Jones wrote:
> > On Wed, Aug 03, 2022 at 09:58:51PM +0800, Jinrong Liang wrote:
> > > My ldd version is (GNU libc) 2.28, and I get a compilation error in this case.
> > > But I use another ldd (Ubuntu GLIBC 2.31-0ubuntu9.2) 2.31 is compiling fine.
> > > This shows that compilation errors may occur in different GNU libc environments.
> > > Would it be more appropriate to use syscall for better compatibility?
> > 
> > OK, it's a pity, but no big deal to use syscall().
> 
> Ya, https://man7.org/linux/man-pages/man2/gettid.2.html says:
> 
>   The gettid() system call first appeared on Linux in kernel 2.4.11.  Library
>   support was added in glibc 2.30.
> 
> But there are already two other instances of syscall(SYS_gettid) in KVM selftests,
> tools/testing/selftests/kvm/lib/assert.c even adds a _gettid() wrapper.

Ha! And I found four more in selftests...

testing/selftests/powerpc/include/utils.h
testing/selftests/proc/proc.h
testing/selftests/rseq/param_test.c
testing/selftests/sched/cs_prctl_test.c

and even more in tools...

> 
> So rather than having to remember (or discover) to use syscall(SYS_gettid), I wonder
> if it's possible to conditionally define gettid()?  E.g. check for GLIBC version?
> Or do
> 
>   #define gettid() syscall(SYS_gettid)
> 
> so that it's always available and simply overrides the library's gettid() if it's
> provided?

Sounds good to me. Now the question is where to put it? kvm_util.h,
test_util.h, or maybe we should create a new header just for stuff
like this?

It doesn't really "fit" in kvm_util.h, but if we put it there, then we
greatly reduce the chance that we'll have to revisit this issue again.
We could also create a new header just for stuff like this and then
include that from kvm_util.h...

Thanks,
drew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ