Re: [PATCH] NFSD: Prevent a possible oops in the nfs_dirent() tracepoint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxx






[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux