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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87zgdpb8dc.fsf@ovpn-192-65.brq.redhat.com>
Date:   Fri, 21 Oct 2022 15:42:55 +0200
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     Sean Christopherson <seanjc@...gle.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

Vitaly Kuznetsov <vkuznets@...hat.com> writes:

> Sean Christopherson <seanjc@...gle.com> writes:
>
>> On Tue, Oct 04, 2022, Vitaly Kuznetsov wrote:
>
> ...
>
>>> +
>>> +	r = pthread_cancel(thread);
>>> +	TEST_ASSERT(r == 0,
>>
>> !r is generally preferred over "r == 0"
>>
>>> +		    "pthread_cancel on vcpu_id=%d failed with errno=%d",
>>> +		    vcpu->id, r);
>>
>> 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.
> 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. I think it's better to keep reporting 'r' for
now (and maybe think about pthread* wrappers later).

-- 
Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ