From: Steven Rostedt <rostedt@goodmis.org>
To: Sachin Sant <sachinp@linux.ibm.com>
Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: Kernel WARNING at lib/vsprintf.c:2721 while running ftrace kernel selftests
Date: Tue, 27 Feb 2024 12:08:42 -0500 [thread overview]
Message-ID: <20240227120842.0d5ffb46@gandalf.local.home> (raw)
In-Reply-To: <20240227115614.3572872e@gandalf.local.home>
On Tue, 27 Feb 2024 11:56:14 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 27 Feb 2024 22:08:18 +0530
> Sachin Sant <sachinp@linux.ibm.com> wrote:
>
> > > Can you apply this, and see if it triggers and if it does, print the line
> > > that has the max size?
> > >
> >
> > With this I see following trace
> >
> > [ 61.327138] ------------[ cut here ]------------
> > [ 61.327159] MAX OUT OF RANGE 63492
>
> Well I guess there you have it ;-)
>
> vsprintf() doesn't like a precision of 63492!
>
> I'll look to see what the best way to deal with this is.
Does this fix it?
-- Steve
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ff0b0a999171..e0840b94f1a2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6882,7 +6882,9 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
/* Used in tracing_mark_raw_write() as well */
#define FAULTED_STR "<faulted>"
#define FAULTED_SIZE (sizeof(FAULTED_STR) - 1) /* '\0' is already accounted for */
-
+#ifndef SHORT_MAX
+#define SHORT_MAX ((1<<15) - 1)
+#endif
if (tracing_disabled)
return -EINVAL;
@@ -6900,6 +6902,16 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
if (cnt < FAULTED_SIZE)
size += FAULTED_SIZE - cnt;
+ /*
+ * trace_print_print() uses vsprintf() to determine the size via
+ * the precision format "%*.s" which can not be greater than
+ * a signed short.
+ */
+ if (size > SHORT_MAX) {
+ cnt -= size - SHORT_MAX;
+ goto again;
+ }
+
if (size > TRACE_SEQ_BUFFER_SIZE) {
cnt -= size - TRACE_SEQ_BUFFER_SIZE;
goto again;
next prev parent reply other threads:[~2024-02-27 17:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-25 16:31 Kernel WARNING at lib/vsprintf.c:2721 while running ftrace kernel selftests Sachin Sant
2024-02-26 17:22 ` Steven Rostedt
2024-02-27 9:36 ` Sachin Sant
2024-02-27 14:18 ` Steven Rostedt
2024-02-27 16:08 ` Sachin Sant
2024-02-27 16:24 ` Steven Rostedt
2024-02-27 16:38 ` Sachin Sant
2024-02-27 16:56 ` Steven Rostedt
2024-02-27 17:08 ` Steven Rostedt [this message]
2024-02-27 17:36 ` Sachin Sant
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=20240227120842.0d5ffb46@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=sachinp@linux.ibm.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