aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/evm
diff options
context:
space:
mode:
authorRoberto Sassu <roberto.sassu@huawei.com>2021-06-08 14:31:22 +0200
committerMimi Zohar <zohar@linux.ibm.com>2021-06-08 16:29:10 -0400
commit6b26285f44c9306747c609cb304f787f1933594c (patch)
tree50ca9c69d4317105c9d384292c32fa56b9f9fd62 /security/integrity/evm
parentima: Set correct casting types (diff)
downloadlinux-dev-6b26285f44c9306747c609cb304f787f1933594c.tar.xz
linux-dev-6b26285f44c9306747c609cb304f787f1933594c.zip
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>
Diffstat (limited to 'security/integrity/evm')
-rw-r--r--security/integrity/evm/evm_main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 2c226e634ae9..977208aecd06 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -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;
}