Commit d4c8e34f authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

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: default avatarJeff Layton <jlayton@primarydata.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent f7ce5d28
...@@ -115,11 +115,19 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf, ...@@ -115,11 +115,19 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf,
struct net *net = current->nsproxy->net_ns; struct net *net = current->nsproxy->net_ns;
struct sockaddr_storage sa; struct sockaddr_storage sa;
u64 val; u64 val;
char *nl;
if (copy_from_user(write_buf, buf, size)) if (copy_from_user(write_buf, buf, size))
return -EFAULT; return -EFAULT;
write_buf[size] = '\0'; write_buf[size] = '\0';
/* Deal with any embedded newlines in the string */
nl = strchr(write_buf, '\n');
if (nl) {
size = nl - write_buf;
*nl = '\0';
}
size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa)); size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
if (size > 0) if (size > 0)
nfsd_inject_set_client(file_inode(file)->i_private, &sa, size); nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment