linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: Liguang Zhang <zhangliguang@linux.alibaba.com>
Subject: [PATCH 3/3] NFS: Ensure cached readdir info is NUL terminated
Date: Sat,  6 Jul 2019 14:52:52 -0400	[thread overview]
Message-ID: <20190706185252.32488-3-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20190706185252.32488-2-trond.myklebust@hammerspace.com>

Strictly speaking, struct qstr does not require a NUL terminated string,
but in practice all dentries are deliberately stored that way.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 6ccf0e6c9c84..7313084424bb 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -189,7 +189,7 @@ static
 int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int len)
 {
 	string->len = len;
-	string->name = kmemdup(name, len, GFP_KERNEL);
+	string->name = kmemdup_nul(name, len, GFP_KERNEL);;
 	if (string->name == NULL)
 		return -ENOMEM;
 	/*
-- 
2.21.0


  reply	other threads:[~2019-07-06 18:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-06 18:52 [PATCH 1/3] NFS: Fix off-by-one errors in nfs_readdir Trond Myklebust
2019-07-06 18:52 ` [PATCH 2/3] NFS: Reduce stack usage in nfs_readdir() Trond Myklebust
2019-07-06 18:52   ` Trond Myklebust [this message]
2019-07-07 21:01 ` [PATCH 1/3] NFS: Fix off-by-one errors in nfs_readdir Mkrtchyan, Tigran

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=20190706185252.32488-3-trond.myklebust@hammerspace.com \
    --to=trondmy@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=zhangliguang@linux.alibaba.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;
as well as URLs for NNTP newsgroup(s).