[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250724101044.d32c46958f6605ae22016851@kernel.org>
Date: Thu, 24 Jul 2025 10:10:44 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Ben Hutchings <benh@...ian.org>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH] bootconfig: Fix unaligned access when building footer
On Wed, 23 Jul 2025 22:20:35 +0200
Ben Hutchings <benh@...ian.org> wrote:
> On Thu, 2025-07-24 at 00:37 +0900, Masami Hiramatsu wrote:
> > On Wed, 23 Jul 2025 12:49:25 +0200
> > Ben Hutchings <benh@...ian.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);
> [...]
OK, if we saw the assertion error, we'll add packed attribute.
Let me pick it as it is.
Thank you!
>
> Ben.
>
> --
> Ben Hutchings - Debian developer, member of kernel, installer and LTS
> teams
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists