public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Peter Zijlstra <peterz@infradead.org>,
	x86@kernel.org
Subject: Re: [PATCH v6] ftrace: Add FTRACE_MCOUNT_MAX_OFFSET to avoid adding weak function
Date: Sat, 28 May 2022 09:30:32 -0400	[thread overview]
Message-ID: <20220528093032.6d2f4147@gandalf.local.home> (raw)
In-Reply-To: <20220527234003.2719e6c6@gandalf.local.home>

On Fri, 27 May 2022 23:40:03 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> @@ -6830,6 +6960,10 @@ void ftrace_module_enable(struct module *mod)
>  		if (ftrace_start_up)
>  			cnt += referenced_filters(rec);
>  
> +		/* Weak functions should still be ignored */
> +		if (!test_for_valid_rec(rec))
> +			continue;

This also needs to clear the other flags.

As this is for module load, it does a two stage setup. That is to make the
correct state of the ftrace locations in the module. As the updates to NOP
is done before the text is set to RO, and if tracing is enabled/disabled
during this time, it will trigger a BUG as it detects executable code
running in RW text. To solve that, the initial setting of the records of
the module is done with the DISABLE flag set, so they are ignored by the
enabling and disabling of ftrace. All the module ftrace locations are set to
NOP.

This function is called after the text is set to ro and we enable the
module functions based on the flags set. But if we are ignoring the record
(as kvm has weak functions), we need to not only skip the setting of the
code, but need to clear the flags to state they are not set. Otherwise it
screws up the accounting of ftrace, and ftrace will WARN and disable itself.

-- Steve




> +
>  		rec->flags &= ~FTRACE_FL_DISABLED;
>  		rec->flags += cnt;
>  


      reply	other threads:[~2022-05-28 13:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-28  3:40 [PATCH v6] ftrace: Add FTRACE_MCOUNT_MAX_OFFSET to avoid adding weak function Steven Rostedt
2022-05-28 13:30 ` Steven Rostedt [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=20220528093032.6d2f4147@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=x86@kernel.org \
    --cc=yhs@fb.com \
    /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