aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@primarydata.com>2014-06-18 15:00:19 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-06-23 11:31:38 -0400
commitd4c8e34fe8beeb7877ce7f8d2da6affd7231b2cb (patch)
tree4e493b1102bfedbfec2fc2a9e3258010e3d066a5
parentf7ce5d284253db9760fc1c3a96b66ec2d9abf0ab (diff)
nfsd: properly handle embedded newlines in fault_injection input
Currently rpc_pton() fails to handle the case where you echo an address into the file, as it barfs on the newline. Ensure that we NULL out the first occurrence of any newline. Signed-off-by: Jeff Layton <jlayton@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/fault_inject.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index 2ed05c3cd43d..f1333fc35b33 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -115,11 +115,19 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf,
115 struct net *net = current->nsproxy->net_ns; 115 struct net *net = current->nsproxy->net_ns;
116 struct sockaddr_storage sa; 116 struct sockaddr_storage sa;
117 u64 val; 117 u64 val;
118 char *nl;
118 119
119 if (copy_from_user(write_buf, buf, size)) 120 if (copy_from_user(write_buf, buf, size))
120 return -EFAULT; 121 return -EFAULT;
121 write_buf[size] = '\0'; 122 write_buf[size] = '\0';
122 123
124 /* Deal with any embedded newlines in the string */
125 nl = strchr(write_buf, '\n');
126 if (nl) {
127 size = nl - write_buf;
128 *nl = '\0';
129 }
130
123 size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa)); 131 size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
124 if (size > 0) 132 if (size > 0)
125 nfsd_inject_set_client(file_inode(file)->i_private, &sa, size); 133 nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);