Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Nam Cao <namcao@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Gabriele Monaco <gmonaco@redhat.com>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] rv: Ensure containers are registered first
Date: Fri, 18 Jul 2025 12:27:14 +0200	[thread overview]
Message-ID: <2025071835-enjoying-darn-f5d8@gregkh> (raw)
In-Reply-To: <20250718091850.2057864-1-namcao@linutronix.de>

On Fri, Jul 18, 2025 at 11:18:50AM +0200, Nam Cao wrote:
> If rv_register_monitor() is called with a non-NULL parent pointer (i.e. by
> monitors inside a container), it is expected that the parent (a.k.a
> container) is already registered.
> 
> The containers seem to always be registered first. I suspect because of the
> order in Makefile. But nothing guarantees this.

Yes, linking order matters, and it does guarantee this.  We rely on
linking order in the kernel in many places.

> If this registering order is changed, "strange" things happen. For example,
> if the container is registered last, rv_is_container_monitor() incorrectly
> says this is NOT a container. .enable() is then called, which is NULL for
> container, thus we have a NULL pointer deref crash.
> 
> Guarantee that containers are registered first.
> 
> Fixes: cb85c660fcd4 ("rv: Add option for nested monitors and include sched")
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> Cc: stable@vger.kernel.org
> ---
>  include/linux/rv.h                                        | 5 +++++
>  kernel/trace/rv/monitors/pagefault/pagefault.c            | 4 ++--
>  kernel/trace/rv/monitors/rtapp/rtapp.c                    | 4 ++--
>  kernel/trace/rv/monitors/sched/sched.c                    | 4 ++--
>  kernel/trace/rv/monitors/sco/sco.c                        | 4 ++--
>  kernel/trace/rv/monitors/scpd/scpd.c                      | 4 ++--
>  kernel/trace/rv/monitors/sleep/sleep.c                    | 4 ++--
>  kernel/trace/rv/monitors/sncid/sncid.c                    | 4 ++--
>  kernel/trace/rv/monitors/snep/snep.c                      | 4 ++--
>  kernel/trace/rv/monitors/snroc/snroc.c                    | 4 ++--
>  kernel/trace/rv/monitors/tss/tss.c                        | 4 ++--
>  kernel/trace/rv/monitors/wip/wip.c                        | 4 ++--
>  kernel/trace/rv/monitors/wwnr/wwnr.c                      | 4 ++--
>  tools/verification/rvgen/rvgen/templates/container/main.c | 4 ++--
>  tools/verification/rvgen/rvgen/templates/dot2k/main.c     | 4 ++--
>  tools/verification/rvgen/rvgen/templates/ltl2k/main.c     | 4 ++--
>  16 files changed, 35 insertions(+), 30 deletions(-)

As there is no bug now, why is this a cc: stable patch?

thanks,

greg k-h

  parent reply	other threads:[~2025-07-18 10:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-18  9:18 [PATCH] rv: Ensure containers are registered first Nam Cao
2025-07-18  9:35 ` Gabriele Monaco
2025-07-18 10:27 ` Greg KH [this message]
2025-07-18 10:40   ` Nam Cao

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=2025071835-enjoying-darn-f5d8@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=gmonaco@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=namcao@linutronix.de \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox