All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Baptiste Lepers" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Baptiste Lepers <baptiste.lepers@gmail.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: perf/urgent] events: Reuse value read using READ_ONCE instead of re-reading it
Date: Thu, 16 Sep 2021 11:59:20 -0000	[thread overview]
Message-ID: <163179356028.25758.1740508579736783885.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210906015310.12802-1-baptiste.lepers@gmail.com>

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     b89a05b21f46150ac10a962aa50109250b56b03b
Gitweb:        https://git.kernel.org/tip/b89a05b21f46150ac10a962aa50109250b56b03b
Author:        Baptiste Lepers <baptiste.lepers@gmail.com>
AuthorDate:    Mon, 06 Sep 2021 11:53:10 +10:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 15 Sep 2021 17:49:06 +02:00

events: Reuse value read using READ_ONCE instead of re-reading it

In perf_event_addr_filters_apply, the task associated with
the event (event->ctx->task) is read using READ_ONCE at the beginning
of the function, checked, and then re-read from event->ctx->task,
voiding all guarantees of the checks. Reuse the value that was read by
READ_ONCE to ensure the consistency of the task struct throughout the
function.

Fixes: 375637bc52495 ("perf/core: Introduce address range filtering")
Signed-off-by: Baptiste Lepers <baptiste.lepers@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210906015310.12802-1-baptiste.lepers@gmail.com
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 744e872..0c000cb 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10193,7 +10193,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
 		return;
 
 	if (ifh->nr_file_filters) {
-		mm = get_task_mm(event->ctx->task);
+		mm = get_task_mm(task);
 		if (!mm)
 			goto restart;
 

      parent reply	other threads:[~2021-09-16 11:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06  1:53 [PATCH] events: Reuse value read using READ_ONCE instead of re-reading it Baptiste Lepers
2021-09-10 16:21 ` Peter Zijlstra
2021-09-16 11:59 ` tip-bot2 for Baptiste Lepers [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=163179356028.25758.1740508579736783885.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=baptiste.lepers@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@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 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.