Linux Trace Kernel
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Ben Hutchings <benh@debian.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] bootconfig: Fix unaligned access when building footer
Date: Thu, 24 Jul 2025 10:10:44 +0900	[thread overview]
Message-ID: <20250724101044.d32c46958f6605ae22016851@kernel.org> (raw)
In-Reply-To: <59abcb9262e97b76bfdf18d6de71c15eb2af8a6e.camel@debian.org>

On Wed, 23 Jul 2025 22:20:35 +0200
Ben Hutchings <benh@debian.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@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);
> [...]

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@kernel.org>

      reply	other threads:[~2025-07-24  1:10 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
2025-07-24  1:10     ` Masami Hiramatsu [this message]

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=20250724101044.d32c46958f6605ae22016851@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=benh@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.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