From: Masami Hiramatsu <mhiramat@kernel.org>
To: Andreas Ziegler <andreas.ziegler@fau.de>
Cc: stable@vger.kernel.org, mingo@redhat.com, rostedt@goodmis.org
Subject: Re: [PATCH stable-4.19] tracing/uprobes: Fix output for multiple string arguments
Date: Thu, 14 Feb 2019 22:39:23 +0900 [thread overview]
Message-ID: <20190214223923.3b068eafda0114870580e48d@kernel.org> (raw)
In-Reply-To: <567dfdfb-98ac-a463-0bfc-757d68b282d0@fau.de>
Hi Andreas,
On Thu, 14 Feb 2019 14:00:03 +0100
Andreas Ziegler <andreas.ziegler@fau.de> wrote:
> Hi,
>
> >
> > diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> > index e696667da29a..04c1769a8c7c 100644
> > --- a/kernel/trace/trace_uprobe.c
> > +++ b/kernel/trace/trace_uprobe.c
> > @@ -142,6 +142,13 @@ static void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
> > ret = strncpy_from_user(dst, src, maxlen);
> > if (ret == maxlen)
> > dst[--ret] = '\0';
> > + else if (ret >= 0)
>
> with this fix the maxlen case still decrements ret by one which does not
> include the terminating \0 (and leaves maxlen = 1 in
> store_trace_args()). Usually this only happens with the last element but
> I still feel that it's inconsistent...
Yes, I found that too. And I thought it was another fix.
>
> Would'nt it be easier to simply add a '+ 1' to to the make_rloc_data()
> statement, like this:
Hmm, in that case, I would like to make "--ret" to "ret - 1" as the
latest kernel does. Keeping the final code similar will help us
if we need another fix to backport.
Any thought?
Thank you,
>
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index e696667da29a..ca0051a84ce8 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -147,7 +147,7 @@ static void FETCH_FUNC_NAME(memory, string)(struct
> pt_regs *regs,
> ((u8 *)get_rloc_data(dest))[0] = '\0';
> *(u32 *)dest = make_data_rloc(0, get_rloc_offs(rloc));
> } else {
> - *(u32 *)dest = make_data_rloc(ret, get_rloc_offs(rloc));
> + *(u32 *)dest = make_data_rloc(ret + 1, get_rloc_offs(rloc));
> }
> }
>
> > + /*
> > + * Include the terminating null byte. In this case it
> > + * was copied by strncpy_from_user but not accounted
> > + * for in ret.
> > + */
> > + ret++;
> >
> > if (ret < 0) { /* Failed to fetch string */
> > ((u8 *)get_rloc_data(dest))[0] = '\0';
> >
>
> Regards,
>
> Andreas
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2019-02-14 13:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-13 13:47 FAILED: patch "[PATCH] tracing/uprobes: Fix output for multiple string arguments" failed to apply to 4.19-stable tree gregkh
2019-02-14 12:52 ` [PATCH stable-4.19] tracing/uprobes: Fix output for multiple string arguments Masami Hiramatsu
2019-02-14 13:00 ` Andreas Ziegler
2019-02-14 13:39 ` Masami Hiramatsu [this message]
2019-02-14 14:24 ` [PATCH stable-4.19 v2] " Masami Hiramatsu
2019-02-14 14:30 ` Masami Hiramatsu
2019-02-14 15:53 ` Andreas Ziegler
2019-02-14 22:27 ` Masami Hiramatsu
2019-02-18 11:34 ` Greg KH
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=20190214223923.3b068eafda0114870580e48d@kernel.org \
--to=mhiramat@kernel.org \
--cc=andreas.ziegler@fau.de \
--cc=mingo@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).