public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs: don't pass non-NULL-terminated string to pr_notice()
@ 2014-04-04 10:00 Jeff Layton
  2014-04-04 13:51 ` Trond Myklebust
  2014-04-05 12:45 ` [PATCH v2] nfs: pass string length to pr_notice message about readdir loops Jeff Layton
  0 siblings, 2 replies; 4+ messages in thread
From: Jeff Layton @ 2014-04-04 10:00 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, lmcilroy

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);
 					}
 					status = -ELOOP;
 					goto out;
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-05 12:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2014-04-05 12:45 ` [PATCH v2] nfs: pass string length to pr_notice message about readdir loops Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox