From: Qingfang Deng <dqfext@gmail.com>
To: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
netdev@vger.kernel.org,
Jedrzej Jagielski <jedrzej.jagielski@intel.com>,
Chuanhong Guo <gch981213@gmail.com>
Subject: Re: [PATCH iwl-next v1] ixgbe: fix type punning in ixgbe_update_flash_X550
Date: Thu, 22 Jan 2026 17:39:33 +0800 [thread overview]
Message-ID: <20260122093940.213113-1-dqfext@gmail.com> (raw)
In-Reply-To: <20260122085102.1117651-1-aleksandr.loktionov@intel.com>
On Thu, 22 Jan 2026 09:51:02 +0100, Aleksandr Loktionov wrote:
> Add a u32 buffer array member to union ixgbe_hic_hdr2 and use it
> directly instead of casting the union address to u32 pointer. This
> avoids potential strict aliasing violations and makes the code more
> explicit about the buffer usage.
>
> The ixgbe_host_interface_command function expects a void* buffer, so
> providing a proper u32 array member in the union is the correct
> approach rather than relying on pointer casting. This eliminates the
> type punning issue where we were casting the union pointer to u32*.
>
> By using buffer.buf instead of &buffer, we pass the address of the
> u32 array directly, which is semantically correct and avoids any
> potential undefined behavior from strict aliasing rule violations.
This commit message is unnecessarily verbose, looks like AI-generated.
The kernel is built with -fno-strict-aliasing, so it's okay to not
follow the rule.
What you're fixing is likely an alignment issue. (see below)
>
> Fixes: 49425dfc7451 ("ixgbe: Add support for x550em_a 10G MAC type")
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
> ---
> drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 1 +
> drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
> index 61f2ef6..eb5bf3b 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
> @@ -2798,6 +2798,7 @@ struct ixgbe_hic_hdr2_rsp {
> };
>
> union ixgbe_hic_hdr2 {
> + u32 buf[1];
The alignment of this union was 1 byte. By adding a u32 member, you're
effectively making it align to u32 (4 bytes).
> struct ixgbe_hic_hdr2_req req;
> struct ixgbe_hic_hdr2_rsp rsp;
> };
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> index 76d2fa3..4a0ccbf 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
> @@ -1228,7 +1228,7 @@ static int ixgbe_update_flash_X550(struct ixgbe_hw *hw)
> buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
> buffer.req.checksum = FW_DEFAULT_CHECKSUM;
>
> - status = ixgbe_host_interface_command(hw, &buffer, sizeof(buffer),
> + status = ixgbe_host_interface_command(hw, buffer.buf, sizeof(buffer),
> IXGBE_HI_COMMAND_TIMEOUT, false);
`buffer` is a local variable allocated on stack, and the compiler did
not guarantee its alignment. As ixgbe_host_interface_command() casts
`buffer` to a u32 array, this may cause an unaligned-access exception
on some arch.
For your reference, I addressed a similar issue previously:
https://lore.kernel.org/all/20230601015432.159066-1-dqfext@gmail.com/
Please update your message, and try not to use completely-AIGC phrases.
> return status;
> }
> --
> 2.52.0
>
>
Regards,
Qingfang
next prev parent reply other threads:[~2026-01-22 9:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 8:51 [PATCH iwl-next v1] ixgbe: fix type punning in ixgbe_update_flash_X550 Aleksandr Loktionov
2026-01-22 9:39 ` Qingfang Deng [this message]
2026-01-22 10:12 ` Loktionov, Aleksandr
2026-01-23 6:45 ` Qingfang Deng
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=20260122093940.213113-1-dqfext@gmail.com \
--to=dqfext@gmail.com \
--cc=aleksandr.loktionov@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=gch981213@gmail.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jedrzej.jagielski@intel.com \
--cc=netdev@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