• Roberto Sassu's avatar
    ima/evm: Fix type mismatch · 6b26285f
    Roberto Sassu authored
    The endianness of a variable written to the measurement list cannot be
    determined at compile time, as it depends on the value of the
    ima_canonical_fmt global variable (set through a kernel option with the
    same name if the machine is big endian).
    
    If ima_canonical_fmt is false, the endianness of a variable is the same as
    the machine; if ima_canonical_fmt is true, the endianness is little endian.
    The warning arises due to this type of instruction:
    
    var = cpu_to_leXX(var)
    
    which tries to assign a value in little endian to a variable with native
    endianness (little or big endian).
    
    Given that the variables set with this instruction are not used in any
    operation but just written to a buffer, it is safe to force the type of the
    value being set to be the same of the type of the variable with:
    
    var = (__force <var type>)cpu_to_leXX(var)
    Reported-by: default avatarkernel test robot <lkp@intel.com>
    Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
    Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
    6b26285f
ima_crypto.c 20.4 KB