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]
Date:   Thu, 2 Aug 2018 06:08:34 -0700
From:   Eric Dumazet <eric.dumazet@...il.com>
To:     Maninder Singh <maninder1.s@...sung.com>, davem@...emloft.net,
        shuahkh@....samsung.com
Cc:     netdev@...r.kernel.org, linux-api@...r.kernel.org,
        linux-kernel@...r.kernel.org, edumazet@...gle.com,
        pankaj.m@...sung.com, a.sahrawat@...sung.com,
        Vaneet Narang <v.narang@...sung.com>
Subject: Re: [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.



On 08/02/2018 03:31 AM, Maninder Singh wrote:
> FILE_SZ is defined as (1UL << 35), it will overflow
> for 32 bit system and logic will break.
> 
> Signed-off-by: Maninder Singh <maninder1.s@...sung.com>
> Signed-off-by: Vaneet Narang <v.narang@...sung.com>
> ---
>  tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
> index e8c5dff..1d6ca12 100644
> --- a/tools/testing/selftests/net/tcp_mmap.c
> +++ b/tools/testing/selftests/net/tcp_mmap.c
> @@ -85,7 +85,7 @@
>  #define MSG_ZEROCOPY    0x4000000
>  #endif
>  
> -#define FILE_SZ (1UL << 35)
> +#define FILE_SZ (1ULL << 35)
>  static int cfg_family = AF_INET6;
>  static socklen_t cfg_alen = sizeof(struct sockaddr_in6);
>  static int cfg_port = 8787;
> @@ -134,7 +134,7 @@ void hash_zone(void *zone, unsigned int length)
>  
>  void *child_thread(void *arg)
>  {
> -	unsigned long total_mmap = 0, total = 0;
> +	unsigned long long total_mmap = 0, total = 0;
>  	struct tcp_zerocopy_receive zc;
>  	unsigned long delta_usec;
>  	int flags = MAP_SHARED;
> @@ -316,7 +316,7 @@ int main(int argc, char *argv[])
>  {
>  	struct sockaddr_storage listenaddr, addr;
>  	unsigned int max_pacing_rate = 0;
> -	unsigned long total = 0;
> +	unsigned long long total = 0;
>  	char *host = NULL;
>  	int fd, c, on = 1;
>  	char *buffer;
> @@ -431,7 +431,7 @@ int main(int argc, char *argv[])
>  		zflg = 0;
>  	}
>  	while (total < FILE_SZ) {
> -		long wr = FILE_SZ - total;
> +		unsigned long long wr = FILE_SZ - total;
>  
>  		if (wr > chunk_size)
>  			wr = chunk_size;
> 

What about using more conventional size_t instead of "unsigned long long" ?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ