diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2020-11-20 11:29:13 +0900 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2020-11-30 23:22:11 -0500 |
commit | e86843580d1bb1ce12544bca3115cf11d51603ff (patch) | |
tree | 3b738cfc275115c07dc805b53b6c17ec1d3d055b /tools/bootconfig | |
parent | 24aed09451270b6a2a78adf8a34918d12ffb7dcf (diff) | |
download | linux-stable-e86843580d1bb1ce12544bca3115cf11d51603ff.tar.gz linux-stable-e86843580d1bb1ce12544bca3115cf11d51603ff.tar.bz2 linux-stable-e86843580d1bb1ce12544bca3115cf11d51603ff.zip |
tools/bootconfig: Store size and checksum in footer as le32
Store the size and the checksum fields in the footer as le32
instead of u32. This will allow us to apply bootconfig to the
cross build initrd without caring the endianness.
Link: https://lkml.kernel.org/r/160583935332.547349.5897811300636587426.stgit@devnote2
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'tools/bootconfig')
-rw-r--r-- | tools/bootconfig/main.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c index 4a445b6304bb..7362bef1a368 100644 --- a/tools/bootconfig/main.c +++ b/tools/bootconfig/main.c @@ -10,6 +10,7 @@ #include <unistd.h> #include <string.h> #include <errno.h> +#include <endian.h> #include <linux/kernel.h> #include <linux/bootconfig.h> @@ -183,9 +184,11 @@ static int load_xbc_from_initrd(int fd, char **buf) if (read(fd, &size, sizeof(u32)) < 0) return pr_errno("Failed to read size", -errno); + size = le32toh(size); if (read(fd, &csum, sizeof(u32)) < 0) return pr_errno("Failed to read checksum", -errno); + csum = le32toh(csum); /* Wrong size error */ if (stat.st_size < size + 8 + BOOTCONFIG_MAGIC_LEN) { @@ -407,10 +410,10 @@ static int apply_xbc(const char *path, const char *xbc_path) /* Add a footer */ p = data + size; - *(u32 *)p = size; + *(u32 *)p = htole32(size); p += sizeof(u32); - *(u32 *)p = csum; + *(u32 *)p = htole32(csum); p += sizeof(u32); memcpy(p, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN); |