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: <20200819141716.GE2403519@lunn.ch>
Date:   Wed, 19 Aug 2020 16:17:16 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     sameehj@...zon.com
Cc:     davem@...emloft.net, netdev@...r.kernel.org, dwmw@...zon.com,
        zorik@...zon.com, matua@...zon.com, saeedb@...zon.com,
        msw@...zon.com, aliguori@...zon.com, nafea@...zon.com,
        gtzalik@...zon.com, netanel@...zon.com, alisaidi@...zon.com,
        benh@...zon.com, akiyano@...zon.com, ndagan@...zon.com
Subject: Re: [PATCH V2 net-next 1/4] net: ena: ethtool: use unsigned long for
 pointer arithmetics

On Wed, Aug 19, 2020 at 01:43:46PM +0000, sameehj@...zon.com wrote:
> From: Sameeh Jubran <sameehj@...zon.com>
> 
> unsigned long is the type for doing maths on pointers.

Maths on pointers is perfectly valid. The real issue here is you have
all your types mixed up.

> -			ptr = (u64 *)((uintptr_t)&ring->tx_stats +
> -				(uintptr_t)ena_stats->stat_offset);
> +			ptr = (u64 *)((unsigned long)&ring->tx_stats +
> +				ena_stats->stat_offset);

struct ena_ring {
...
        union {
		struct ena_stats_tx tx_stats;
		struct ena_stats_rx rx_stats;
	};

struct ena_stats_tx {
	u64 cnt;
	u64 bytes;
	u64 queue_stop;
	u64 prepare_ctx_err;
	u64 queue_wakeup;
	...
}

&ring->tx_stats will give you a struct *ena_stats_tx. Arithmetic on
that, adding 1 for example, takes you forward a full ena_stats_tx
structure. Not what you want.

&ring->tx_stats.cnt however, will give you a u64 *. Adding 1 to that
will give you bytes, etc.

     Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ