lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240520150857.GA709412@wp.pl>
Date: Mon, 20 May 2024 17:08:57 +0200
From: Stanislaw Gruszka <stf_xl@...pl>
To: Johannes Berg <johannes@...solutions.net>
Cc: Kees Cook <keescook@...omium.org>,
	"Gustavo A. R. Silva" <gustavoars@...nel.org>,
	Xose Vazquez Perez <xose.vazquez@...il.com>,
	linux-wireless@...r.kernel.org, linux-hardening@...r.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)

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ