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] [day] [month] [year] [list]
Message-ID: <877dczm11y.fsf@redhat.com>
Date:   Tue, 23 Nov 2021 14:52:41 +0100
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>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: selftests: Make sure kvm_create_max_vcpus test
 won't hit RLIMIT_NOFILE

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

>>>  
>>> +	/*
>>> +	 * Creating KVM_CAP_MAX_VCPUS vCPUs require KVM_CAP_MAX_VCPUS open
>>> +	 * file decriptors.
>>> +	 */
>>> +	TEST_ASSERT(!getrlimit(RLIMIT_NOFILE, &rl),
>>> +		    "getrlimit() failed (errno: %d)", errno);
>>
>> And strerror() output too?
>>
>
> Sure, will add in v2.
>

Actually, there are two issues with the code above. First, TEST_ASSERT()
already prints both errno and strerror() (setrlimit() counterpart which
is easier to make fail):

KVM_CAP_MAX_VCPU_ID: 4096
KVM_CAP_MAX_VCPUS: 1024
==== Test Assertion Failure ====
  kvm_create_max_vcpus.c:68: !setrlimit(RLIMIT_NOFILE, &rl)
  pid=344504 tid=344504 errno=1 - Operation not permitted
     1	0x0000000000402485: main at kvm_create_max_vcpus.c:68
     2	0x00007fcb2e8b4041: ?? ??:0
     3	0x000000000040254d: _start at ??:?
  setrlimit() failed, errno: 0

Second, note "errno: 0" above. There's no guarantee that getrlimit()
will be executed before evaluating 'errno' in C. I think I'll just drop
redundant errno printout then.

-- 
Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ