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: <20240930164154.GG1310185@kernel.org>
Date: Mon, 30 Sep 2024 17:41:54 +0100
From: Simon Horman <horms@...nel.org>
To: Danielle Ratson <danieller@...dia.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, edumazet@...gle.com,
	kuba@...nel.org, pabeni@...hat.com, yuehaibing@...wei.com,
	linux-kernel@...r.kernel.org, petrm@...dia.com
Subject: Re: [PATCH net-next v3 2/2] net: ethtool: Add support for writing
 firmware blocks using EPL payload

On Mon, Sep 30, 2024 at 11:46:37AM +0300, Danielle Ratson wrote:
> In the CMIS specification for pluggable modules, LPL (Low-Priority Payload)
> and EPL (Extended Payload Length) are two types of data payloads used for
> managing various functions and features of the module.
> 
> EPL payloads are used for more complex and extensive management
> functions that require a larger amount of data, so writing firmware
> blocks using EPL is much more efficient.
> 
> Currently, only LPL payload is supported for writing firmware blocks to
> the module.
> 
> Add support for writing firmware block using EPL payload, both to
> support modules that supports only EPL write mechanism, and to optimize
> the flashing process of modules that support LPL and EPL.
> 
> Signed-off-by: Danielle Ratson <danieller@...dia.com>
> Reviewed-by: Petr Machata <petrm@...dia.com>
> Reviewed-by: Simon Horman <horms@...nel.org>

...

> @@ -556,6 +563,49 @@ __ethtool_cmis_cdb_execute_cmd(struct net_device *dev,
>  	return err;
>  }
>  
> +#define CMIS_CDB_EPL_PAGE_START			0xA0
> +#define CMIS_CDB_EPL_PAGE_END			0xAF
> +#define CMIS_CDB_EPL_FW_BLOCK_OFFSET_START	128
> +#define CMIS_CDB_EPL_FW_BLOCK_OFFSET_END	255
> +
> +static int
> +ethtool_cmis_cdb_execute_epl_cmd(struct net_device *dev,
> +				 struct ethtool_cmis_cdb_cmd_args *args,
> +				 struct ethtool_module_eeprom *page_data)
> +{
> +	u16 epl_len = be16_to_cpu(args->req.epl_len);
> +	u32 bytes_written;
> +	u8 page;
> +	int err;
> +
> +	for (page = CMIS_CDB_EPL_PAGE_START;
> +	     page <= CMIS_CDB_EPL_PAGE_END && bytes_written < epl_len; page++) {

bytes_written does not seem to be initialised here for the first iteration
of the loop.

Flagged by W=1 builds with clang-18.

> +		u16 offset = CMIS_CDB_EPL_FW_BLOCK_OFFSET_START;
> +
> +		while (offset <= CMIS_CDB_EPL_FW_BLOCK_OFFSET_END &&
> +		       bytes_written < epl_len) {
> +			u32 bytes_left = epl_len - bytes_written;
> +			u16 space_left, bytes_to_write;
> +
> +			space_left = CMIS_CDB_EPL_FW_BLOCK_OFFSET_END - offset + 1;
> +			bytes_to_write = min_t(u16, bytes_left,
> +					       min_t(u16, space_left,
> +						     args->read_write_len_ext));
> +
> +			err = __ethtool_cmis_cdb_execute_cmd(dev, page_data,
> +							     page, offset,
> +							     bytes_to_write,
> +							     args->req.epl + bytes_written);
> +			if (err < 0)
> +				return err;
> +
> +			offset += bytes_to_write;
> +			bytes_written += bytes_to_write;
> +		}
> +	}
> +	return 0;
> +}
> +
>  static u8 cmis_cdb_calc_checksum(const void *data, size_t size)
>  {
>  	const u8 *bytes = (const u8 *)data;

...

-- 
pw-bot: changes-requested

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ