public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: [PATCH 2/7] liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain::depth
Date: Tue, 14 Jun 2016 21:47:53 +0100	[thread overview]
Message-ID: <20160614204752.GU7555@decadent.org.uk> (raw)
In-Reply-To: <20160614204437.GS7555@decadent.org.uk>

[-- Attachment #1: Type: text/plain, Size: 1480 bytes --]

liblockdep has been broken since commit 75dd602a5198 ("lockdep: Fix
lock_chain::base size"), as that adds a check that MAX_LOCK_DEPTH is
within the range of lock_chain::depth and in liblockdep it is much
too large.

That should have resulted in a compiler error, but didn't because:

- the check uses ARRAY_SIZE(), which isn't yet defined in liblockdep
  so is assumed to be an (undeclared) function
- putting a function call inside a BUILD_BUG_ON() expression quietly
  turns it into some nonsense involving a variable-length array

It did produce a compiler warning, but I didn't notice because
liblockdep already produces too many warnings if -Wall is enabled
(which I'll fix shortly).

Even before that commit, which reduced lock_chain::depth from 8 bits
to 6, MAX_LOCK_DEPTH was too large.

Cc: <stable@vger.kernel.org> # for versions before 4.6, use a value of 255
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 tools/lib/lockdep/uinclude/linux/lockdep.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/lockdep/uinclude/linux/lockdep.h b/tools/lib/lockdep/uinclude/linux/lockdep.h
index c808c7d02d21..d30214221920 100644
--- a/tools/lib/lockdep/uinclude/linux/lockdep.h
+++ b/tools/lib/lockdep/uinclude/linux/lockdep.h
@@ -8,7 +8,7 @@
 #include <linux/utsname.h>
 #include <linux/compiler.h>
 
-#define MAX_LOCK_DEPTH 2000UL
+#define MAX_LOCK_DEPTH 63UL
 
 #define asmlinkage
 #define __visible


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  parent reply	other threads:[~2016-06-14 20:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 20:44 [PATCH 0/7] Fixes for liblockdep Ben Hutchings
2016-06-14 20:47 ` [PATCH 1/7] liblockdep: Fix undefined symbol prandom_u32 Ben Hutchings
2016-06-14 21:31   ` Sasha Levin
2016-06-14 20:47 ` Ben Hutchings [this message]
2016-06-14 21:13   ` [PATCH 2/7] liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain::depth Peter Zijlstra
2016-06-14 20:48 ` [PATCH 3/7] liblockdep: Define the ARRAY_SIZE() macro Ben Hutchings
2016-06-14 20:48 ` [PATCH 4/7] liblockdep: Enable -Wall by default Ben Hutchings
2016-06-14 20:48 ` [PATCH 5/7] liblockdep: Fix 'unused value' warnings Ben Hutchings
2016-06-14 20:49 ` [PATCH 6/7] liblockdep: Fix 'set but not used' warnings Ben Hutchings
2016-06-14 20:49 ` [PATCH 7/7] liblockdep: Fix 'defined but not used' warning for init_utsname() Ben Hutchings
2016-06-14 21:31 ` [PATCH 0/7] Fixes for liblockdep Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160614204752.GU7555@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sasha.levin@oracle.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox