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] [day] [month] [year] [list]
Message-ID: <Y1LFYjyyHRiP8rNe@google.com>
Date:   Fri, 21 Oct 2022 16:14:26 +0000
From:   Sean Christopherson <seanjc@...gle.com>
To:     Vitaly Kuznetsov <vkuznets@...hat.com>
Cc:     kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Michael Kelley <mikelley@...rosoft.com>,
        Siddharth Chandrasekaran <sidcha@...zon.de>,
        Yuan Yao <yuan.yao@...ux.intel.com>,
        Maxim Levitsky <mlevitsk@...hat.com>,
        linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v11 33/46] KVM: selftests: Hyper-V PV IPI selftest

On Fri, Oct 21, 2022, Vitaly Kuznetsov wrote:
> Vitaly Kuznetsov <vkuznets@...hat.com> writes:
> 
> > Sean Christopherson <seanjc@...gle.com> writes:
> >> Do you happen to know if errno is preserved?  I.e. if TEST_ASSERT()'s print of
> >> errno will capture the right errno?  If so, this and the pthread_join() assert
> >> can be:
> >>
> >> 	TEST_ASSERT(!r, pthread_cancel() failed on vcpu_id=%d, vcpu->id);
> >>
> >
> > The example from 'man 3 pthread_cancel' makes me think errno is not
> > set. 'man 3 errno' confirms that:
> >
> > "
> >        Note  that the POSIX threads APIs do not set errno on error.

Ah, that's annoying.

> > Instead, on failure they return an error number as the function result.
> > These error numbers have the same meanings as the error numbers returned
> > in errno by other APIs.
> > "
> >
> > but nothing stops us from doing something like
> >
> > #include <errno.h>
> > ...
> >
> > errno = pthread_cancel(thread);
> > TEST_ASSERT(!errno, pthread_cancel() failed on vcpu_id=%d, vcpu->id);
> >
> > I believe.
> 
> ... only the fact that this won't be thread safe :-( i.e. if we also try
> setting 'errno' from vcpu_thread() (where the pattern for
> pthread_setcanceltype() is exactly the same), we will likely be
> reporting the wrong errno.

errno is thread safe.  From https://man7.org/linux/man-pages/man3/errno.3.html:

       errno is defined by the ISO C standard to be a modifiable lvalue
       of type int, and must not be explicitly declared; errno may be a
       macro.  errno is thread-local; setting it in one thread does not
       affect its value in any other thread.


> I think it's better to keep reporting 'r' for now (and maybe think about
> pthread* wrappers later).

Yeah, definitely a future problem.  pthread wrappers are a good idea, I doubt
there's a single KVM selftest that wants to do anything but assert on failure.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ