ima: define a canonical binary_runtime_measurements list format
The IMA binary_runtime_measurements list is currently in platform native format. To allow restoring a measurement list carried across kexec with a different endianness than the targeted kernel, this patch defines little-endian as the canonical format. For big endian systems wanting to save/restore the measurement list from a system with a different endianness, a new boot command line parameter named "ima_canonical_fmt" is defined. Considerations: use of the "ima_canonical_fmt" boot command line option will break existing userspace applications on big endian systems expecting the binary_runtime_measurements list to be in platform native format. Link: http://lkml.kernel.org/r/1480554346-29071-10-git-send-email-zohar@linux.vnet.ibm.com Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com> Acked-by: Dmitry Kasatkin <dmitry.kasatkin@gmail.com> Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Andreas Steffen <andreas.steffen@strongswan.org> Cc: Josh Sklar <sklar@linux.vnet.ibm.com> Cc: Dave Young <dyoung@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Baoquan He <bhe@redhat.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
c7d0936770
commit
d68a6fe9fc
@@ -21,8 +21,7 @@ static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
|
||||
{
|
||||
struct ima_queue_entry *qe;
|
||||
struct seq_file file;
|
||||
struct ima_kexec_hdr khdr = {
|
||||
.version = 1, .buffer_size = 0, .count = 0};
|
||||
struct ima_kexec_hdr khdr;
|
||||
int ret = 0;
|
||||
|
||||
/* segment size can't change between kexec load and execute */
|
||||
@@ -36,6 +35,8 @@ static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
|
||||
file.read_pos = 0;
|
||||
file.count = sizeof(khdr); /* reserved space */
|
||||
|
||||
memset(&khdr, 0, sizeof(khdr));
|
||||
khdr.version = 1;
|
||||
list_for_each_entry_rcu(qe, &ima_measurements, later) {
|
||||
if (file.count < file.size) {
|
||||
khdr.count++;
|
||||
@@ -54,7 +55,13 @@ static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
|
||||
* (eg. version, buffer size, number of measurements)
|
||||
*/
|
||||
khdr.buffer_size = file.count;
|
||||
if (ima_canonical_fmt) {
|
||||
khdr.version = cpu_to_le16(khdr.version);
|
||||
khdr.count = cpu_to_le64(khdr.count);
|
||||
khdr.buffer_size = cpu_to_le64(khdr.buffer_size);
|
||||
}
|
||||
memcpy(file.buf, &khdr, sizeof(khdr));
|
||||
|
||||
print_hex_dump(KERN_DEBUG, "ima dump: ", DUMP_PREFIX_NONE,
|
||||
16, 1, file.buf,
|
||||
file.count < 100 ? file.count : 100, true);
|
||||
|
Reference in New Issue
Block a user