From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Kees Cook <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Xose Vazquez Perez <xose.vazquez@gmail.com>,
linux-wireless@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [WARNING] memcpy: detected field-spanning write (size 1005) of single field "&out_cmd->cmd.payload" at drivers/net/wireless/intel/iwlegacy/common.c:3173 (size 320)
Date: Mon, 20 May 2024 17:08:57 +0200 [thread overview]
Message-ID: <20240520150857.GA709412@wp.pl> (raw)
In-Reply-To: <95f3e147de837b4833e6cf6eb67108f96640af4e.camel@sipsolutions.net>
On Mon, May 20, 2024 at 01:45:37PM +0200, Johannes Berg wrote:
>
> > +++ b/drivers/net/wireless/intel/iwlegacy/commands.h
> > @@ -201,9 +201,6 @@ struct il_cmd_header {
> > * 15 unsolicited RX or uCode-originated notification
> > */
> > __le16 sequence;
> > -
> > - /* command or response/notification data follows immediately */
> > - u8 data[];
> > } __packed;
>
> [...]
>
>
> > - memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len);
> > + memcpy(&out_cmd->cmd.raw, cmd->data, cmd->len);
>
> [...]
>
> > +++ b/drivers/net/wireless/intel/iwlegacy/common.h
> > @@ -555,6 +555,7 @@ struct il_device_cmd {
> > u32 val32;
> > struct il_tx_cmd tx;
> > u8 payload[DEF_CMD_PAYLOAD_SIZE];
> > + DECLARE_FLEX_ARRAY(u8, raw);
> >
>
> I don't think this is right, now the raw comes after
> DEF_CMD_PAYLOAD_SIZE? You want it to be a union with payload, I'd think.
Not sure if I understand. I think we have union with payload with
the patch. The structure looks like this:
struct il_device_cmd {
struct il_cmd_header hdr; /* uCode API */
union {
u32 flags;
u8 val8;
u16 val16;
u32 val32;
struct il_tx_cmd tx;
u8 payload[DEF_CMD_PAYLOAD_SIZE];
DECLARE_FLEX_ARRAY(u8, raw);
} __packed cmd;
} __packed;
BTW, the first four cmd union fields i.e. flags, val8 ...
can be removed as well, seems nothing touch those fields in the code.
Regards
Stanislaw
next prev parent reply other threads:[~2024-05-20 15:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 17:48 [WARNING] memcpy: detected field-spanning write (size 1005) of single field "&out_cmd->cmd.payload" at drivers/net/wireless/intel/iwlegacy/common.c:3173 (size 320) Xose Vazquez Perez
2024-05-18 9:29 ` Stanislaw Gruszka
2024-05-18 17:48 ` Kees Cook
2024-05-20 7:32 ` Stanislaw Gruszka
2024-05-20 11:45 ` Johannes Berg
2024-05-20 15:08 ` Stanislaw Gruszka [this message]
2024-05-20 15:10 ` Johannes Berg
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=20240520150857.GA709412@wp.pl \
--to=stf_xl@wp.pl \
--cc=gustavoars@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=xose.vazquez@gmail.com \
/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