linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: linke li <lilinke99@qq.com>
Cc: lilinke99@qq.com, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] uprobes: use READ_ONCE() to read mm->uprobes_state.xol_area in concurrent environment
Date: Sat, 24 Feb 2024 18:25:19 +0800	[thread overview]
Message-ID: <tencent_088804E150842691191FD0021AEE8649EB0A@qq.com> (raw)

In function get_xol_area(), mm->uprobes_state.xol_area is read using 
READ_ONCE() in line 1534

1534   area = READ_ONCE(mm->uprobes_state.xol_area); /* ^^^ */

while read directly in line 1530

1530   	if (!mm->uprobes_state.xol_area)
1531	    __create_xol_area(0);

In the same environment, reads in two places should have the same
protection.

Signed-off-by: linke li <lilinke99@qq.com>
---
 kernel/events/uprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 929e98c62965..e110941fbc6b 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1527,7 +1527,7 @@ static struct xol_area *get_xol_area(void)
 	struct mm_struct *mm = current->mm;
 	struct xol_area *area;
 
-	if (!mm->uprobes_state.xol_area)
+	if (!READ_ONCE(mm->uprobes_state.xol_area))
 		__create_xol_area(0);
 
 	/* Pairs with xol_add_vma() smp_store_release() */
-- 
2.39.3 (Apple Git-145)


                 reply	other threads:[~2024-02-24 10:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=tencent_088804E150842691191FD0021AEE8649EB0A@qq.com \
    --to=lilinke99@qq.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).