From: Steven Rostedt <rostedt@goodmis.org>
To: Justin Stitt <justinstitt@google.com>
Cc: 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>,
Chuck Lever <chuck.lever@oracle.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:36:14 -0400 [thread overview]
Message-ID: <20240410113614.39b61b0d@gandalf.local.home> (raw)
In-Reply-To: <20240401-strncpy-include-trace-events-mdio-h-v1-1-9cb5a4cda116@google.com>
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!
> ),
>
> 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
> ),
next prev parent reply other threads:[~2024-04-10 15:33 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 [this message]
2024-04-10 15:41 ` Chuck Lever
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=20240410113614.39b61b0d@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=Dai.Ngo@oracle.com \
--cc=andrew@lunn.ch \
--cc=chuck.lever@oracle.com \
--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=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