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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100607.211829.63035366.davem@davemloft.net>
Date:	Mon, 07 Jun 2010 21:18:29 -0700 (PDT)
From:	David Miller <davem@...emloft.net>
To:	bhutchings@...arflare.com
Cc:	shemminger@...tta.com, arnd@...db.de, netdev@...r.kernel.org,
	linux-net-drivers@...arflare.com
Subject: Re: [PATCHv2 1/2] net: Enable 64-bit net device statistics on
 32-bit architectures

From: Ben Hutchings <bhutchings@...arflare.com>
Date: Fri, 04 Jun 2010 23:04:53 +0100

> +#if BITS_PER_LONG == 64
> +#define NET_DEVICE_STATS_DEFINE(name)	u64 name
> +#elif defined(__LITTLE_ENDIAN)
> +#define NET_DEVICE_STATS_DEFINE(name)	u32 name, pad_ ## name
> +#else
> +#define NET_DEVICE_STATS_DEFINE(name)	u32 pad_ ## name, name
> +#endif
> +
 ...
> +	NET_DEVICE_STATS_DEFINE(rx_packets);
> +	NET_DEVICE_STATS_DEFINE(tx_packets);
> +	NET_DEVICE_STATS_DEFINE(rx_bytes);
 ...
>  	static const char fmt[] = "%30s %12lu\n";
> +	static const char fmt64[] = "%30s %12llu\n";
 ...
> +	seq_printf(seq, fmt64, "total frames received", stats->rx_packets);
> +	seq_printf(seq, fmt64, "total bytes received", stats->rx_bytes);
> +	seq_printf(seq, fmt64, "Broadcast/Multicast Rcvd", stats->multicast);

I guess you only built this on a 64-bit platform that defines u64 as a
long long type.

The rest of the world will receive tons of warnings for these print
statements.

You have basically 3 cases to handle:

1) u64 defined as "unsigned long long"

2) u64 defined as "unsigned long"

3) u32 defined as "unsigned int"

And the whole tree needs to be inspected to make sure there isn't going
to be fallout in areas your patch didn't take care of wrt. printf format
strings and the like.

What was always "unsigned long" is now a variable type, therefore using
a fixed printf format string is impossible unless you always cast these
things when passed in as printf arguments.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ