From: Chuck Lever <chuck.lever@oracle.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Justin Stitt <justinstitt@google.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Jeff Layton <jlayton@kernel.org>, Neil Brown <neilb@suse.de>,
Olga Kornievskaia <kolga@netapp.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, linux-nfs@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] trace: events: cleanup deprecated strncpy uses
Date: Wed, 10 Apr 2024 11:41:18 -0400 [thread overview]
Message-ID: <ZhazHrz4SxBs+BFD@tissot.1015granger.net> (raw)
In-Reply-To: <20240410113614.39b61b0d@gandalf.local.home>
On Wed, Apr 10, 2024 at 11:36:14AM -0400, Steven Rostedt wrote:
> On Mon, 01 Apr 2024 23:48:52 +0000
> Justin Stitt <justinstitt@google.com> wrote:
>
> > diff --git a/include/trace/events/rpcgss.h b/include/trace/events/rpcgss.h
> > index ba2d96a1bc2f..274c297f1b15 100644
> > --- a/include/trace/events/rpcgss.h
> > +++ b/include/trace/events/rpcgss.h
> > @@ -618,7 +618,7 @@ TRACE_EVENT(rpcgss_context,
> > __entry->timeout = timeout;
> > __entry->window_size = window_size;
> > __entry->len = len;
> > - strncpy(__get_str(acceptor), data, len);
> > + memcpy(__get_str(acceptor), data, len);
> > ),
> >
> > TP_printk("win_size=%u expiry=%lu now=%lu timeout=%u acceptor=%.*s",
>
> WTF, that code is just buggy. Looking at the rpcgss_context event we have:
>
> > TRACE_EVENT(rpcgss_context,
> > TP_PROTO(
> > u32 window_size,
> > unsigned long expiry,
> > unsigned long now,
> > unsigned int timeout,
> > unsigned int len,
> > const u8 *data
> > ),
> >
> > TP_ARGS(window_size, expiry, now, timeout, len, data),
> >
> > TP_STRUCT__entry(
> > __field(unsigned long, expiry)
> > __field(unsigned long, now)
> > __field(unsigned int, timeout)
> > __field(u32, window_size)
> > __field(int, len)
> > __string(acceptor, data)
>
> The __string() macro expects "data" to be a string and does *not* check
> length when copying.
>
> If anything, it needs to be:
>
> __string_len(acceptor, data, len)
>
> as the macro code has changed recently, and the current code will crash!
A general question:
Is there a test suite we should run regularly to build some
confidence in the kernel's observability apparatus? We're building
a menagerie of tests around kdevops, and one area where we know
there is a testing gap is the tracepoints in NFSD and SunRPC.
> > ),
> >
> > TP_fast_assign(
> > __entry->expiry = expiry;
> > __entry->now = now;
> > __entry->timeout = timeout;
> > __entry->window_size = window_size;
> > __entry->len = len;
> > strncpy(__get_str(acceptor), data, len);
>
> Then this needs to be:
>
> __assign_str(acceptor, data);
>
> Note, the length is now saved via __string_len() and not needed here.
>
> I'll go send a patch to fix this.
>
> -- Steve
>
>
> > ),
--
Chuck Lever
next prev parent reply other threads:[~2024-04-10 15:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 23:48 [PATCH] trace: events: cleanup deprecated strncpy uses Justin Stitt
2024-04-03 13:30 ` Chuck Lever
2024-04-10 15:36 ` Steven Rostedt
2024-04-10 15:41 ` Chuck Lever [this message]
2024-04-10 15:56 ` Steven Rostedt
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=ZhazHrz4SxBs+BFD@tissot.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=Dai.Ngo@oracle.com \
--cc=andrew@lunn.ch \
--cc=hkallweit1@gmail.com \
--cc=jlayton@kernel.org \
--cc=justinstitt@google.com \
--cc=kolga@netapp.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tom@talpey.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