The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Jiri Olsa <olsajiri@gmail.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCHv2 mm-stable] uprobes: Revert ref_ctr_offset in uprobe_unregister error path
Date: Tue, 17 Jun 2025 13:59:50 +0200	[thread overview]
Message-ID: <e77b2fb5-f2ff-4c11-8b3a-6b5ee89738e0@redhat.com> (raw)
In-Reply-To: <aFFYTi4FcKE7rmlI@krava>

On 17.06.25 13:58, Jiri Olsa wrote:
> ping
> 
> On Wed, Jun 11, 2025 at 10:57:08AM +0200, Jiri Olsa wrote:
>> hi, ping ;-)
>>
>> On Wed, Jun 04, 2025 at 10:28:42PM +0200, Jiri Olsa wrote:
>>> On Wed, May 14, 2025 at 12:18:09PM +0200, Jiri Olsa wrote:
>>>> From: Jiri Olsa <olsajiri@gmail.com>
>>>>
>>>> There's error path that could lead to inactive uprobe:
>>>>
>>>>    1) uprobe_register succeeds - updates instruction to int3 and
>>>>       changes ref_ctr from 0 to 1
>>>>    2) uprobe_unregister fails  - int3 stays in place, but ref_ctr
>>>>       is changed to 0 (it's not restored to 1 in the fail path)
>>>>       uprobe is leaked
>>>>    3) another uprobe_register comes and re-uses the leaked uprobe
>>>>       and succeds - but int3 is already in place, so ref_ctr update
>>>>       is skipped and it stays 0 - uprobe CAN NOT be triggered now
>>>>    4) uprobe_unregister fails because ref_ctr value is unexpected
>>>>
>>>> Fixing this by reverting the updated ref_ctr value back to 1 in step 2),
>>>> which is the case when uprobe_unregister fails (int3 stays in place),
>>>> but we have already updated refctr.
>>>>
>>>> The new scenario will go as follows:
>>>>
>>>>    1) uprobe_register succeeds - updates instruction to int3 and
>>>>       changes ref_ctr from 0 to 1
>>>>    2) uprobe_unregister fails  - int3 stays in place and ref_ctr
>>>>       is reverted to 1..  uprobe is leaked
>>>>    3) another uprobe_register comes and re-uses the leaked uprobe
>>>>       and succeds - but int3 is already in place, so ref_ctr update
>>>>       is skipped and it stays 1 - uprobe CAN be triggered now
>>>>    4) uprobe_unregister succeeds
>>>>
>>>> Fixes: 1cc33161a83d ("uprobes: Support SDT markers having reference count (semaphore)")
>>>> Acked-by: David Hildenbrand <david@redhat.com>
>>>> Acked-by: Oleg Nesterov <oleg@redhat.com>
>>>> Suggested-by: Oleg Nesterov <oleg@redhat.com>
>>>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>>>
>>> hi,
>>> I can't find this in any related tree, was this pulled in?

@Andrew, I assume you should pick this.

-- 
Cheers,

David / dhildenb


      reply	other threads:[~2025-06-17 11:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 10:18 [PATCHv2 mm-stable] uprobes: Revert ref_ctr_offset in uprobe_unregister error path Jiri Olsa
2025-06-04 20:28 ` Jiri Olsa
2025-06-11  8:57   ` Jiri Olsa
2025-06-17 11:58     ` Jiri Olsa
2025-06-17 11:59       ` David Hildenbrand [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=e77b2fb5-f2ff-4c11-8b3a-6b5ee89738e0@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=oleg@redhat.com \
    --cc=olsajiri@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox