Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle when arch_prctl fails. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jul 2, 2021

  1. Correctly handle when arch_prctl fails.

    The current code is written as follows:
    
    ```
    bool faulting_disabled;
    if ((faulting_disabled = arch_prctl(ARCH_GET_CPUID, 0)) < 0)
        secure_err(1, "CPUID faulting feature inaccessible");
    ```
    
    `arch_prctl` will return -1 on failure, however bool cannot represent
    the value -1. This produces the following warning in clang when
    `-Wtautological-constant-compare` is enabled)
    
    ```
    third_party/libvirtcpuid/src/cpuid.c:368:61: error: result of comparison of constant 0 with expression of type 'bool' is always false [-Werror,-Wtautological-constant-compare]
        if ((faulting_disabled = arch_prctl(ARCH_GET_CPUID, 0)) < 0)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
    ```
    
    The fix is to change `faulting_disabled` to an int so it can store the
    return value of `arch_prctl`.
    eatnumber1 committed Jul 2, 2021
    Configuration menu
    Copy the full SHA
    a0caf0e View commit details
    Browse the repository at this point in the history