From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796293036; b=j4u90G9H2DMyrc2y2/NR4QrHrIxYeHqh32DhBOPhVf9acBMHiU4dJ5gNaZJH/scm7i+k x6w/r1iZ5JvDcjQN2H9nHyCnfQCeQSDNCapRlSbQ8ufKmuXfrvodEgWUw9/qtxoyxXs0e Nsz7AyIfTEds7v/pQlH91+xJc9GdKbyeMn7pmDM14WcaKRT1pd85/JzURLgrYPPqk0Gku cOQfu6hVOcYMYIxI5emU/eARZczXmGWvbkN+UGGQALAqvzxZfDVnikCzQcz78Thbm52Je 5YjfcJPb/xM3ogq+QDrOatSD89stM0dAkcc80k1Z3HHubAquywBv5DJuAUnmhHCa7ZA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796293036; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=jq5W1pJifeIGJ1+11qfTkj96NjxWMDxMZfcxWmlPATM=; b=2C8tHC+iMkwsjlj2sGcN0u472ea7nrf0g5vtkugamSr2wp2i9JUwwzZx7/x8olvpNtbE yANIvXls9CRaSlHmj/nZ/L6oZc5gSkNugAbXvpfuwmsMiehk+6b6NtXitwiagnUoXK9dm UfBN7cPysLjnw5oIHy74vAaJy2oakXzCcQr0Vq7wqqHBLgpN/EqmlTEC+Jr83JNdU41ia FZHJD2+NIDfCp+UPSFzuFJ68DnLqidNxM8W4WNN143RQk7ZORMbmN+NcR+U9bc3pStXmH R/b/N9kEVLOtGU0vbpCL+AbwBwbjzoaoD+8DWMRoIoZyoeT+1cgj7jBjM0kMiqyZVOw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CyDJ0m1B; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EB4E606A322; Thu, 3 Dec 2026 10:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CyDJ0m1B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 042271F000C1; Thu, 3 Dec 2026 10:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796293036; bh=jq5W1pJifeIGJ1+11qfTkj96NjxWMDxMZfcxWmlPATM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=CyDJ0m1B/EEAHl737xd0asn0MYfBZl9mFMJoJD4T9+1wzKHJ0faNtVjY5Ut1aYANU OTYcu/pvVK+Jf05TeE27mpSGXxjmDGjnHUDkrfkyo6SNuw1mbvlrI5QTitszL6sklx QIVkQTeYBLaiV+lqUiemm7q5vMagTXDgLhaf8xfbOKPm/k9Vbh2IFGnG1wKuD8yWmj CWdJjiAW81C4ehwZiVM0oEn5tC4cOagiw6XK0bbJW2BTHxPGCZ8u9A2tU8Qps3JIzm /w3Q2IPUbnN9fem+OFUkgCPRyr3ojOb9NXrpuciRXv44XyJdKakxkWccTzkTz8Ix/F faIPsVF+TTnYw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] uprobes: Skip remove_breakpoint() if UPROBE_COPY_INSN is not set Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?TWFzYW1pIEhpcmFtYXRzdSAoR29vZ2xlKQ==?= Cc: linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org In-Reply-To: <179629194562.2709886.5573348043761281153.stgit@mhiramat.c.googlers.com> References: <179629192497.2709886.2379669650835098449.stgit@mhiramat.c.googlers.com> <179629194562.2709886.5573348043761281153.stgit@mhiramat.c.googlers.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 10:17:15 +0000 X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] uprobes: early return in remove_breakpoint() skips MMF_RECALC_UPROBES -- commit 7922d016707ed1ec398765711ff02f36bfd6af90 Author: Masami Hiramatsu (Google) uprobes: Skip remove_breakpoint() if UPROBE_COPY_INSN is not set This commit makes remove_breakpoint() return early if UPROBE_COPY_INSN is not set in uprobe->flags, and adds an smp_rmb() pairing with prepare_uprobe() before set_orig_insn() reads uprobe->arch. > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c > index e850865045b21..7f0515c9dc327 100644 > --- a/kernel/events/uprobes.c > +++ b/kernel/events/uprobes.c [ ... ] > @@ -1194,6 +1197,19 @@ static int remove_breakpoint(struct uprobe *uprobe= , struct vm_area_struct *vma, > { > struct mm_struct *mm =3D vma->vm_mm; > =20 > + /* No breakpoint was ever installed if prepare_uprobe() never succeeded= */ > + if (!test_bit(UPROBE_COPY_INSN, &uprobe->flags)) > + return 0; > + > + /* > + * Pairs with the smp_wmb() in prepare_uprobe(). > + * > + * Guarantees that if we see the UPROBE_COPY_INSN bit set, then > + * we must also see the stores to &uprobe->arch before > + * set_orig_insn() reads them. > + */ > + smp_rmb(); > + > mm_flags_set(MMF_RECALC_UPROBES, mm); > return set_orig_insn(&uprobe->arch, vma, vaddr); > } [Severity: Medium] Can returning early here leave MMF_HAS_UPROBES permanently set on mm? Suppose a process has two uprobes on the same mapped file: U1 is installed (setting MMF_HAS_UPROBES), and U2 has a consumer filter that rejects this process so U2 sits in uprobes_tree with UPROBE_COPY_INSN unset. When U1 is unregistered, remove_breakpoint() sets MMF_RECALC_UPROBES. If the process then hits a non-uprobe trap, find_active_uprobe_rcu() clears MMF_RECALC_UPROBES and calls mmf_recalc_uprobes(), which finds U2 via vma_has_uprobes() and leaves MMF_HAS_UPROBES set. When U2 is later unregistered, remove_breakpoint() now returns 0 without setting MMF_RECALC_UPROBES. Once U2 is gone from uprobes_tree, even uprobe_munmap() will not set it, leaving MMF_HAS_UPROBES stuck so later non-uprobe traps keep taking the find_active_uprobe_rcu() slow path. Calling mm_flags_set(MMF_RECALC_UPROBES, mm) before checking UPROBE_COPY_INSN would avoid this regression while still skipping set_orig_insn(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179629192497.270988= 6.2379669650835098449.stgit@mhiramat.c.googlers.com?part=3D2