All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "bfields@fieldses.org" <bfields@fieldses.org>,
	"chuck.lever@oracle.com" <chuck.lever@oracle.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] NFSD: Prevent a possible oops in the nfs_dirent() tracepoint
Date: Fri, 25 Jun 2021 16:28:12 +0000	[thread overview]
Message-ID: <b71c76c0fb21ebb35e1f91864bbb411a4c895370.camel@hammerspace.com> (raw)
In-Reply-To: <162463396907.1820.8112792283525036426.stgit@klimt.1015granger.net>

On Fri, 2021-06-25 at 11:12 -0400, Chuck Lever wrote:
> The double copy of the string is a mistake, plus __assign_str()
> uses strlen(), which is wrong to do on a string that isn't
> guaranteed to be NUL-terminated.
> 
> Fixes: 6019ce0742ca ("NFSD: Add a tracepoint to record directory
> entry encoding")
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  fs/nfsd/trace.h |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
> index 27a93ebd1d80..89dccced526a 100644
> --- a/fs/nfsd/trace.h
> +++ b/fs/nfsd/trace.h
> @@ -408,7 +408,6 @@ TRACE_EVENT(nfsd_dirent,
>                 __entry->ino = ino;
>                 __entry->len = namlen;
>                 memcpy(__get_str(name), name, namlen);
> -               __assign_str(name, name);
>         ),
>         TP_printk("fh_hash=0x%08x ino=%llu name=%.*s",
>                 __entry->fh_hash, __entry->ino,
> 
> 

Why not just store it as a NUL terminated string and save a few bytes
by getting rid of the integer-sized storage of the length?

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



  reply	other threads:[~2021-06-25 16:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 15:12 [PATCH] NFSD: Prevent a possible oops in the nfs_dirent() tracepoint Chuck Lever
2021-06-25 16:28 ` Trond Myklebust [this message]
2021-06-25 18:05   ` Chuck Lever III
2021-06-25 18:57     ` Trond Myklebust
2021-06-25 19:38       ` Chuck Lever III

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=b71c76c0fb21ebb35e1f91864bbb411a4c895370.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.