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: <20230403144357.2434352d@kernel.org>
Date:   Mon, 3 Apr 2023 14:43:57 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     <edward.cree@....com>
Cc:     <linux-net-drivers@....com>, <davem@...emloft.net>,
        <pabeni@...hat.com>, <edumazet@...gle.com>,
        Edward Cree <ecree.xilinx@...il.com>, <netdev@...r.kernel.org>,
        <habetsm.xilinx@...il.com>, <sudheer.mogilappagari@...el.com>
Subject: Re: [RFC PATCH net-next 1/6] net: ethtool: attach an IDR of custom
 RSS contexts to a netdevice

On Mon, 3 Apr 2023 17:32:58 +0100 edward.cree@....com wrote:
> From: Edward Cree <ecree.xilinx@...il.com>
> 
> Each context stores the RXFH settings (indir, key, and hfunc) as well
>  as optionally some driver private data.
> Delete any still-existing contexts at netdev unregister time.

> +/**
> + * struct ethtool_rxfh_context - a custom RSS context configuration
> + * @indir_size: Number of u32 entries in indirection table
> + * @key_size: Size of hash key, in bytes
> + * @hfunc: RSS hash function identifier.  One of the %ETH_RSS_HASH_*
> + * @priv_size: Size of driver private data, in bytes
> + */
> +struct ethtool_rxfh_context {
> +	u32 indir_size;
> +	u32 key_size;
> +	u8 hfunc;
> +	u16 priv_size;
> +	/* private: indirection table, hash key, and driver private data are
> +	 * stored sequentially in @data area.  Use below helpers to access
> +	 */
> +	u8 data[];

I think that something needs to get aligned here...
Driver priv needs to guarantee ulong alignment in case someone puts 
a pointer in it.

> +};
> +
> +static inline u32 *ethtool_rxfh_context_indir(struct ethtool_rxfh_context *ctx)
> +{
> +	return (u32 *)&ctx->data;
> +}
> +
> +static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx)
> +{
> +	return (u8 *)(ethtool_rxfh_context_indir(ctx) + ctx->indir_size);
> +}
> +
> +static inline void *ethtool_rxfh_context_priv(struct ethtool_rxfh_context *ctx)
> +{
> +	return ethtool_rxfh_context_key(ctx) + ctx->key_size;

ALIGN_PTR() ... ?
Or align data[] and reorder..

> +}
> +
>  /* declare a link mode bitmap */
>  #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name)		\
>  	DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)

> +	u32			rss_ctx_max_id;
> +	struct idr		rss_ctx;

noob question, why not xarray?
Isn't IDR just a legacy wrapper around xarray anyway?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ