All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Dmitry Vyukov <dvyukov@google.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	andrii@kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	kpsingh@kernel.org, netdev <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: corrupted pvqspinlock in htab_map_update_elem
Date: Mon, 1 Feb 2021 12:53:53 -0500	[thread overview]
Message-ID: <5936f4a4-f150-e56e-f07d-1efee06eba16@redhat.com> (raw)
In-Reply-To: <YBfkuyIfB1+VRxXP@hirez.programming.kicks-ass.net>

On 2/1/21 6:23 AM, Peter Zijlstra wrote:
> On Mon, Feb 01, 2021 at 10:50:58AM +0100, Peter Zijlstra wrote:
>
>>>   queued_spin_unlock arch/x86/include/asm/qspinlock.h:56 [inline]
>>>   lockdep_unlock+0x10e/0x290 kernel/locking/lockdep.c:124
>>>   debug_locks_off_graph_unlock kernel/locking/lockdep.c:165 [inline]
>>>   print_usage_bug kernel/locking/lockdep.c:3710 [inline]
>> Ha, I think you hit a bug in lockdep.
> Something like so I suppose.
>
> ---
> Subject: locking/lockdep: Avoid unmatched unlock
> From: Peter Zijlstra <peterz@infradead.org>
> Date: Mon Feb 1 11:55:38 CET 2021
>
> Commit f6f48e180404 ("lockdep: Teach lockdep about "USED" <- "IN-NMI"
> inversions") overlooked that print_usage_bug() releases the graph_lock
> and called it without the graph lock held.
>
> Fixes: f6f48e180404 ("lockdep: Teach lockdep about "USED" <- "IN-NMI" inversions")
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>   kernel/locking/lockdep.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3773,7 +3773,7 @@ static void
>   print_usage_bug(struct task_struct *curr, struct held_lock *this,
>   		enum lock_usage_bit prev_bit, enum lock_usage_bit new_bit)
>   {
> -	if (!debug_locks_off_graph_unlock() || debug_locks_silent)
> +	if (!debug_locks_off() || debug_locks_silent)
>   		return;
>   
>   	pr_warn("\n");
> @@ -3814,6 +3814,7 @@ valid_state(struct task_struct *curr, st
>   	    enum lock_usage_bit new_bit, enum lock_usage_bit bad_bit)
>   {
>   	if (unlikely(hlock_class(this)->usage_mask & (1 << bad_bit))) {
> +		graph_unlock()
>   		print_usage_bug(curr, this, bad_bit, new_bit);
>   		return 0;
>   	}

I have also suspected doing unlock without a corresponding lock. This 
patch looks good to me.

Acked-by: Waiman Long <longman@redhat.com>

Cheers,
Longman


  reply	other threads:[~2021-02-01 17:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-31  8:42 corrupted pvqspinlock in htab_map_update_elem Dmitry Vyukov
2021-02-01  9:50 ` Peter Zijlstra
2021-02-01 10:06   ` Dmitry Vyukov
2021-02-01 11:23   ` Peter Zijlstra
2021-02-01 17:53     ` Waiman Long [this message]
2021-02-01 18:09       ` Dmitry Vyukov
2021-02-01 18:14         ` Waiman Long
2021-02-08 12:06     ` [tip: locking/core] locking/lockdep: Avoid unmatched unlock tip-bot2 for Peter Zijlstra

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=5936f4a4-f150-e56e-f07d-1efee06eba16@redhat.com \
    --to=longman@redhat.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dvyukov@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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.