aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/ima/ima_template.c
diff options
context:
space:
mode:
authorRoberto Sassu <roberto.sassu@huawei.com>2021-06-08 14:31:21 +0200
committerMimi Zohar <zohar@linux.ibm.com>2021-06-08 16:29:10 -0400
commit24c9ae23bdfa0642228e747849dd052fd4295c6c (patch)
tree3e57619f2de9068ac8aeba2ebddad546a20c5e50 /security/integrity/ima/ima_template.c
parentdoc: Fix warning in Documentation/security/IMA-templates.rst (diff)
downloadlinux-dev-24c9ae23bdfa0642228e747849dd052fd4295c6c.tar.xz
linux-dev-24c9ae23bdfa0642228e747849dd052fd4295c6c.zip
ima: Set correct casting types
The code expects that the values being parsed from a buffer when the ima_canonical_fmt global variable is true are in little endian. Thus, this patch sets the casting types accordingly. 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/ima/ima_template.c')
-rw-r--r--security/integrity/ima/ima_template.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index a85963853a91..694560396be0 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -423,9 +423,9 @@ int ima_restore_measurement_list(loff_t size, void *buf)
return 0;
if (ima_canonical_fmt) {
- khdr->version = le16_to_cpu(khdr->version);
- khdr->count = le64_to_cpu(khdr->count);
- khdr->buffer_size = le64_to_cpu(khdr->buffer_size);
+ khdr->version = le16_to_cpu((__force __le16)khdr->version);
+ khdr->count = le64_to_cpu((__force __le64)khdr->count);
+ khdr->buffer_size = le64_to_cpu((__force __le64)khdr->buffer_size);
}
if (khdr->version != 1) {
@@ -515,7 +515,7 @@ int ima_restore_measurement_list(loff_t size, void *buf)
}
entry->pcr = !ima_canonical_fmt ? *(u32 *)(hdr[HDR_PCR].data) :
- le32_to_cpu(*(u32 *)(hdr[HDR_PCR].data));
+ le32_to_cpu(*(__le32 *)(hdr[HDR_PCR].data));
ret = ima_restore_measurement_entry(entry);
if (ret < 0)
break;