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: <Zqu2_OvnXIrCMMu8@google.com>
Date: Thu, 1 Aug 2024 16:25:32 +0000
From: Carlos Llamas <cmllamas@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, kernel-team@...roid.com,
	"J. R. Okajima" <hooanon05g@...il.com>,
	Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
	Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v2] lockdep: upper limit LOCKDEP_CHAINS_BITS

On Wed, Jul 31, 2024 at 04:48:23PM -0700, Andrew Morton wrote:
[...]
> so
> 
> 	BUILD_BUG_ON((1UL << 24) <= ARRAY_SIZE(chain_hlocks));
> 	ie, BUILD_BUG_ON((1UL << 24) <= 5 * (1UL << 21));
> 
> is OK, whereas
> 
> 	BUILD_BUG_ON((1UL << 24) <= 5 * (1UL << 22));
> 
> will bug out.  So LGTM, I'll add it to mm.git.
>

Right. I ran into the BUILD_BUG_ON() while trying to max out
LOCKDEP_CHAINS_BITS. I initially suspected the assert was incorrect as
the static array is being indexed as chain_hlocks[base + depth], which
according to the bitfileds in 'struct lock_chain' should likely be a 30
bit shift instead:

	unsigned int    irq_contex :  2,
			depth      :  6,
			base       : 24;

In practice though, using 1UL << 30 will blow up the bss section. This
is also true for the _any_ of the CONFIG_LOCKDEP_*_BITS. As they are all
shifts to determine the size of static arrays.

I simply dug up this patch from J.R. which avoids the BUILD_BUG_ON(),
but perhaps someone should limit the rest of the configs? In practice,
nobody should be using these 30 bit shifts.


> btw, the help text "Bitsize for MAX_LOCKDEP_CHAINS" is odd.  What's a
> bitsize?  Maybe "bit shift count for..." or such.

Indeed that is odd. I'm also not sure what to make of the "*5" magic
number. I suppose it could be the typical lock depth? I could try to
clarify these points, if no one with more insight wants to do it.

--
Carlos Llamas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ