ima/evm: Fix type mismatch
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: kernel test robot <lkp@intel.com> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
committed by
Mimi Zohar
parent
24c9ae23bd
commit
6b26285f44
@@ -360,7 +360,7 @@ int evm_read_protected_xattrs(struct dentry *dentry, u8 *buffer,
|
||||
size = sizeof(u32);
|
||||
if (buffer) {
|
||||
if (canonical_fmt)
|
||||
rc = cpu_to_le32(rc);
|
||||
rc = (__force int)cpu_to_le32(rc);
|
||||
|
||||
*(u32 *)(buffer + total_size) = rc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user