aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorHarsh Prateek Bora <harsh@linux.vnet.ibm.com>2010-08-03 07:55:40 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2010-10-28 10:08:44 -0400
commit3834b12a18d51d6c535ea52e16355d75806ffe38 (patch)
treed3ccd5ac5e0610ca7b1e5a937eeaf827db548786 /fs/9p
parent57ee047b4d6bb4bcc74be0329441d1b242e57e61 (diff)
fs/9p: setrlimit fix for 9p write
Current 9p client file write code does not check for RLIMIT_FSIZE resource. This bug was found by running LTP test case for setrlimit. This bug is fixed by calling generic_write_checks before sending the write request to the server. Without this patch: the write function is allowed to write above the RLIMIT_FSIZE set by user. With this patch: the write function checks for RLIMIT_SIZE and writes upto the size limit. Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/vfs_file.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index e97c92bd6f16..89c44e92022c 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -219,7 +219,9 @@ static ssize_t
219v9fs_file_write(struct file *filp, const char __user * data, 219v9fs_file_write(struct file *filp, const char __user * data,
220 size_t count, loff_t * offset) 220 size_t count, loff_t * offset)
221{ 221{
222 int n, rsize, total = 0; 222 ssize_t retval;
223 size_t total = 0;
224 int n, rsize;
223 struct p9_fid *fid; 225 struct p9_fid *fid;
224 struct p9_client *clnt; 226 struct p9_client *clnt;
225 struct inode *inode = filp->f_path.dentry->d_inode; 227 struct inode *inode = filp->f_path.dentry->d_inode;
@@ -234,6 +236,17 @@ v9fs_file_write(struct file *filp, const char __user * data,
234 236
235 rsize = fid->iounit ? fid->iounit : clnt->msize - P9_IOHDRSZ; 237 rsize = fid->iounit ? fid->iounit : clnt->msize - P9_IOHDRSZ;
236 238
239 retval = generic_write_checks(filp, &origin, &count, 0);
240 if (retval)
241 goto out;
242
243 retval = -EINVAL;
244 if ((ssize_t) count < 0)
245 goto out;
246 retval = 0;
247 if (!count)
248 goto out;
249
237 do { 250 do {
238 if (count < rsize) 251 if (count < rsize)
239 rsize = count; 252 rsize = count;
@@ -258,9 +271,11 @@ v9fs_file_write(struct file *filp, const char __user * data,
258 } 271 }
259 272
260 if (n < 0) 273 if (n < 0)
261 return n; 274 retval = n;
262 275 else
263 return total; 276 retval = total;
277out:
278 return retval;
264} 279}
265 280
266static int v9fs_file_fsync(struct file *filp, int datasync) 281static int v9fs_file_fsync(struct file *filp, int datasync)