From: Jeff Layton <jlayton@redhat.com>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: linux-nfs@vger.kernel.org, lmcilroy@redhat.com
Subject: Re: [PATCH] nfs: don't pass non-NULL-terminated string to pr_notice()
Date: Fri, 4 Apr 2014 10:01:24 -0400 [thread overview]
Message-ID: <20140404100124.2db49cb8@tlielax.poochiereds.net> (raw)
In-Reply-To: <5EC0B3CC-6647-4A6E-A44C-82A72CBEC490@primarydata.com>
On Fri, 4 Apr 2014 09:51:11 -0400
Trond Myklebust <trond.myklebust@primarydata.com> wrote:
>
> On Apr 4, 2014, at 6:00, Jeff Layton <jlayton@redhat.com> wrote:
>
> > There is no guarantee that the strings in the nfs_cache_array will be
> > NULL-terminated. In the event that we end up hitting a readdir loop, we
> > need to ensure that we pass the warning message a properly-terminated
> > string.
> >
> > Reported-by: Lachlan McIlroy <lmcilroy@redhat.com>
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > ---
> > fs/nfs/dir.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> > index 5c0b6ecc3a88..4689b125f9fe 100644
> > --- a/fs/nfs/dir.c
> > +++ b/fs/nfs/dir.c
> > @@ -304,12 +304,13 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
> > if (ctx->duped > 0
> > && ctx->dup_cookie == *desc->dir_cookie) {
> > if (printk_ratelimit()) {
> > + char *name = kstrndup(array->array[i].string.name, array->array[i].string.len, GFP_KERNEL);
> > +
> > pr_notice("NFS: directory %pD2 contains a readdir loop."
> > "Please contact your server vendor. "
> > "The file: %s has duplicate cookie %llu\n",
> > - desc->file,
> > - array->array[i].string.name,
> > - *desc->dir_cookie);
> > + desc->file, name, *desc->dir_cookie);
> > + kfree(name);
> > }
>
> Umm… Any reason why we couldn’t just use ‘%.*s’ ?
>
No reason at all. I had never run across that...
I'll respin and repost -- thanks!
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2014-04-04 14:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-04 10:00 [PATCH] nfs: don't pass non-NULL-terminated string to pr_notice() Jeff Layton
2014-04-04 13:51 ` Trond Myklebust
2014-04-04 14:01 ` Jeff Layton [this message]
2014-04-05 12:45 ` [PATCH v2] nfs: pass string length to pr_notice message about readdir loops Jeff Layton
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=20140404100124.2db49cb8@tlielax.poochiereds.net \
--to=jlayton@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=lmcilroy@redhat.com \
--cc=trond.myklebust@primarydata.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