All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Jason Baron <jbaron@redhat.com>
Cc: rostedt@goodmis.org, a.p.zijlstra@chello.nl,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] jump label: close race in jump_label_inc() vs. jump_label_dec()
Date: Thu, 5 Jan 2012 09:20:05 +0200	[thread overview]
Message-ID: <20120105072005.GP2072@redhat.com> (raw)
In-Reply-To: <201201041532.q04FWbBl022103@int-mx10.intmail.prod.int.phx2.redhat.com>

On Wed, Jan 04, 2012 at 10:32:37AM -0500, Jason Baron wrote:
> The previous fix to ensure that jump_label_inc() does not return until the jump
> is completely patched, opened up a race in the inc/dec path. The scenario is:
> 
> key->enabled = 0;
> 
> 	CPU 0					CPU 1
>         ----- 					-----
> 
> jump_label_inc():			jump_label_dec():
> 
> 1) if (atomic_read(&key->enabled) == 0)
> 	jump_label_update(key, JUMP_LABEL_ENABLE);
> 
> 					 2) if (!atomic_dec_and_mutex_lock(&key->enabled, &jump_label_mutex))
> 					 	return;
> 
> 3) atomic_inc(&key->enabled);
> 
> So now, key->enabled = 0, but the jump has been enabled, which is an invalid
> state.
> 
Isn't it an indication of a higher level bug if jump_label_dec() is
called on a disabled jump label? In other words isn't key->enabled == -1
invalid sate by itself? I do not see how the call sequence above can
happen with perf events for instance. jump_label_dec() is called on
event destruction and if key->enabled = 0 then there is no events to
destroy.

--
			Gleb.

  reply	other threads:[~2012-01-05  7:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-04 15:32 [PATCH] jump label: close race in jump_label_inc() vs. jump_label_dec() Jason Baron
2012-01-05  7:20 ` Gleb Natapov [this message]
2012-01-05 14:39 ` Steven Rostedt
2012-01-05 15:30   ` Jason Baron
2012-01-05 15:34     ` Steven Rostedt
2012-01-05 15:38       ` Jason Baron

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=20120105072005.GP2072@redhat.com \
    --to=gleb@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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.