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: <c702670609914da89e934879b5c89de7@AcuMS.aculab.com>
Date: Mon, 15 Jul 2024 08:22:19 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Leon Romanovsky' <leon@...nel.org>
CC: Anand Khoje <anand.a.khoje@...cle.com>, "linux-rdma@...r.kernel.org"
	<linux-rdma@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>, "saeedm@...lanox.com" <saeedm@...lanox.com>,
	"tariqt@...dia.com" <tariqt@...dia.com>, "edumazet@...gle.com"
	<edumazet@...gle.com>, "kuba@...nel.org" <kuba@...nel.org>,
	"pabeni@...hat.com" <pabeni@...hat.com>, "davem@...emloft.net"
	<davem@...emloft.net>
Subject: RE: [PATCH v4] net/mlx5: Reclaim max 50K pages at once

From: Leon Romanovsky
> Sent: 01 July 2024 12:50
> To: David Laight <David.Laight@...LAB.COM>
...
> > > BTW, this can be written as:
> > > 	req->npages = max_t(s32, npages, MAX_RECLAIM_NPAGES);
> >
> > That shouldn't need all the (s32) casts.
> 
> #define doesn't have a type, so it is better to be explicit here.

The constant has a type, the cast just hides any checking that might be done.
Would you really write:
	if ((s32)npages > (s32)-50000)
		...
Because that is what you are generating.

Here it probably doesn't matter, but it is really bad practise.
If, for example, 'npages' is 64 bit than the cast can change the value.

There are places where the type of the result has been used and caused
bugs because a value got masked to 16 bits.

In reality there should be a big trawl through the code to try to
remove all the 'pointless' min_t() and max_t().
Adding new ones just makes it worse.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ