From: Ingo Molnar <mingo@kernel.org>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] lockdep: avoid signed overflow
Date: Thu, 16 Mar 2017 07:42:09 +0100 [thread overview]
Message-ID: <20170316064208.GB7130@gmail.com> (raw)
In-Reply-To: <1489595492-11745-1-git-send-email-mark.rutland@arm.com>
* Mark Rutland <mark.rutland@arm.com> wrote:
> The counters in struct lockdep_stats are all (signed) ints. For some
> counters (e.g. hardirqs_on_events, hardirqs_off_events), it's easy to
> trigger an overflow in a short period of time, rendering the information
> exposed under /proc/lockdep_stats erroneous, and causing UBSAN to
> scream.
> diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h
> index c2b8849..9fd970e 100644
> --- a/kernel/locking/lockdep_internals.h
> +++ b/kernel/locking/lockdep_internals.h
> @@ -132,23 +132,23 @@ extern void get_usage_chars(struct lock_class *class,
> * and we want to avoid too much cache bouncing.
> */
> struct lockdep_stats {
> - int chain_lookup_hits;
> - int chain_lookup_misses;
> - int hardirqs_on_events;
> - int hardirqs_off_events;
> - int redundant_hardirqs_on;
> - int redundant_hardirqs_off;
> - int softirqs_on_events;
> - int softirqs_off_events;
> - int redundant_softirqs_on;
> - int redundant_softirqs_off;
> - int nr_unused_locks;
> - int nr_cyclic_checks;
> - int nr_cyclic_check_recursions;
> - int nr_find_usage_forwards_checks;
> - int nr_find_usage_forwards_recursions;
> - int nr_find_usage_backwards_checks;
> - int nr_find_usage_backwards_recursions;
> + unsigned long chain_lookup_hits;
> + unsigned long chain_lookup_misses;
> + unsigned long hardirqs_on_events;
> + unsigned long hardirqs_off_events;
> + unsigned long redundant_hardirqs_on;
> + unsigned long redundant_hardirqs_off;
> + unsigned long softirqs_on_events;
> + unsigned long softirqs_off_events;
> + unsigned long redundant_softirqs_on;
> + unsigned long redundant_softirqs_off;
> + unsigned long nr_unused_locks;
> + unsigned long nr_cyclic_checks;
> + unsigned long nr_cyclic_check_recursions;
> + unsigned long nr_find_usage_forwards_checks;
> + unsigned long nr_find_usage_forwards_recursions;
> + unsigned long nr_find_usage_backwards_checks;
> + unsigned long nr_find_usage_backwards_recursions;
Presumably it's just as easy to overflow on 32-bit CPUs, so this should probably
be u64 or such.
Thanks,
Ingo
prev parent reply other threads:[~2017-03-16 6:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 16:31 [PATCH] lockdep: avoid signed overflow Mark Rutland
2017-03-16 6:42 ` Ingo Molnar [this message]
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=20170316064208.GB7130@gmail.com \
--to=mingo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.