From: Ben Hutchings <benh@debian.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] bootconfig: Fix unaligned access when building footer
Date: Wed, 23 Jul 2025 22:20:35 +0200 [thread overview]
Message-ID: <59abcb9262e97b76bfdf18d6de71c15eb2af8a6e.camel@debian.org> (raw)
In-Reply-To: <20250724003747.be2a733e2e7fcf8a9e263cc4@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 942 bytes --]
On Thu, 2025-07-24 at 00:37 +0900, Masami Hiramatsu wrote:
> On Wed, 23 Jul 2025 12:49:25 +0200
> Ben Hutchings <benh@debian.org> wrote:
[...]
> > static int apply_xbc(const char *path, const char *xbc_path)
> > {
> > - char *buf, *data, *p;
> > + struct {
> > + uint32_t size;
> > + uint32_t csum;
> > + char magic[BOOTCONFIG_MAGIC_LEN];
> > + } footer;
>
> Don't we need __attribute__((__packed__)) for the footer?
I don't see any reason for there to be padding in this structure, since
it has an alignment of 4 and the size of each member is a multiple of 4.
I included an assertion that there is no padding:
[...]
> > + memcpy(footer.magic, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN);
> > + static_assert(sizeof(footer) == BOOTCONFIG_FOOTER_SIZE);
> > + memcpy(data + size, &footer, BOOTCONFIG_FOOTER_SIZE);
[...]
Ben.
--
Ben Hutchings - Debian developer, member of kernel, installer and LTS
teams
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-07-23 20:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 10:49 [PATCH] bootconfig: Fix unaligned access when building footer Ben Hutchings
2025-07-23 15:37 ` Masami Hiramatsu
2025-07-23 20:20 ` Ben Hutchings [this message]
2025-07-24 1:10 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=59abcb9262e97b76bfdf18d6de71c15eb2af8a6e.camel@debian.org \
--to=benh@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox