|
Lines 182-187
Link Here
|
| 182 |
} |
182 |
} |
| 183 |
#endif |
183 |
#endif |
| 184 |
|
184 |
|
|
|
185 |
|
| 186 |
int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count) |
| 187 |
{ |
| 188 |
struct inode *inode = file->f_dentry->d_inode; |
| 189 |
|
| 190 |
if (inode->i_flock && MANDATORY_LOCK(inode)) |
| 191 |
return locks_mandatory_area(read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE, inode, file, *ppos, count); |
| 192 |
return 0; |
| 193 |
} |
| 194 |
|
| 185 |
ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) |
195 |
ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) |
| 186 |
{ |
196 |
{ |
| 187 |
struct kiocb kiocb; |
197 |
struct kiocb kiocb; |
|
Lines 200-206
Link Here
|
| 200 |
|
210 |
|
| 201 |
ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) |
211 |
ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) |
| 202 |
{ |
212 |
{ |
| 203 |
struct inode *inode = file->f_dentry->d_inode; |
|
|
| 204 |
ssize_t ret; |
213 |
ssize_t ret; |
| 205 |
|
214 |
|
| 206 |
if (!(file->f_mode & FMODE_READ)) |
215 |
if (!(file->f_mode & FMODE_READ)) |
|
Lines 208-214
Link Here
|
| 208 |
if (!file->f_op || (!file->f_op->read && !file->f_op->aio_read)) |
217 |
if (!file->f_op || (!file->f_op->read && !file->f_op->aio_read)) |
| 209 |
return -EINVAL; |
218 |
return -EINVAL; |
| 210 |
|
219 |
|
| 211 |
ret = locks_verify_area(FLOCK_VERIFY_READ, inode, file, *pos, count); |
220 |
ret = rw_verify_area(READ, file, pos, count); |
| 212 |
if (!ret) { |
221 |
if (!ret) { |
| 213 |
ret = security_file_permission (file, MAY_READ); |
222 |
ret = security_file_permission (file, MAY_READ); |
| 214 |
if (!ret) { |
223 |
if (!ret) { |
|
Lines 247-253
Link Here
|
| 247 |
|
256 |
|
| 248 |
ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) |
257 |
ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) |
| 249 |
{ |
258 |
{ |
| 250 |
struct inode *inode = file->f_dentry->d_inode; |
|
|
| 251 |
ssize_t ret; |
259 |
ssize_t ret; |
| 252 |
|
260 |
|
| 253 |
if (!(file->f_mode & FMODE_WRITE)) |
261 |
if (!(file->f_mode & FMODE_WRITE)) |
|
Lines 255-261
Link Here
|
| 255 |
if (!file->f_op || (!file->f_op->write && !file->f_op->aio_write)) |
263 |
if (!file->f_op || (!file->f_op->write && !file->f_op->aio_write)) |
| 256 |
return -EINVAL; |
264 |
return -EINVAL; |
| 257 |
|
265 |
|
| 258 |
ret = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file, *pos, count); |
266 |
ret = rw_verify_area(WRITE, file, pos, count); |
| 259 |
if (!ret) { |
267 |
if (!ret) { |
| 260 |
ret = security_file_permission (file, MAY_WRITE); |
268 |
ret = security_file_permission (file, MAY_WRITE); |
| 261 |
if (!ret) { |
269 |
if (!ret) { |
|
Lines 399-405
Link Here
|
| 399 |
int seg; |
407 |
int seg; |
| 400 |
io_fn_t fn; |
408 |
io_fn_t fn; |
| 401 |
iov_fn_t fnv; |
409 |
iov_fn_t fnv; |
| 402 |
struct inode *inode; |
|
|
| 403 |
|
410 |
|
| 404 |
/* |
411 |
/* |
| 405 |
* SuS says "The readv() function *may* fail if the iovcnt argument |
412 |
* SuS says "The readv() function *may* fail if the iovcnt argument |
|
Lines 452-462
Link Here
|
| 452 |
goto out; |
459 |
goto out; |
| 453 |
} |
460 |
} |
| 454 |
|
461 |
|
| 455 |
inode = file->f_dentry->d_inode; |
462 |
ret = rw_verify_area(type, file, pos, tot_len); |
| 456 |
/* VERIFY_WRITE actually means a read, as we write to user space */ |
|
|
| 457 |
ret = locks_verify_area((type == READ |
| 458 |
? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE), |
| 459 |
inode, file, *pos, tot_len); |
| 460 |
if (ret) |
463 |
if (ret) |
| 461 |
goto out; |
464 |
goto out; |
| 462 |
|
465 |
|
|
Lines 603-609
Link Here
|
| 603 |
else |
606 |
else |
| 604 |
if (!(in_file->f_mode & FMODE_PREAD)) |
607 |
if (!(in_file->f_mode & FMODE_PREAD)) |
| 605 |
goto fput_in; |
608 |
goto fput_in; |
| 606 |
retval = locks_verify_area(FLOCK_VERIFY_READ, in_inode, in_file, *ppos, count); |
609 |
retval = rw_verify_area(READ, in_file, ppos, count); |
| 607 |
if (retval) |
610 |
if (retval) |
| 608 |
goto fput_in; |
611 |
goto fput_in; |
| 609 |
|
612 |
|
|
Lines 624-630
Link Here
|
| 624 |
if (!out_file->f_op || !out_file->f_op->sendpage) |
627 |
if (!out_file->f_op || !out_file->f_op->sendpage) |
| 625 |
goto fput_out; |
628 |
goto fput_out; |
| 626 |
out_inode = out_file->f_dentry->d_inode; |
629 |
out_inode = out_file->f_dentry->d_inode; |
| 627 |
retval = locks_verify_area(FLOCK_VERIFY_WRITE, out_inode, out_file, out_file->f_pos, count); |
630 |
retval = rw_verify_area(WRITE, out_file, &out_file->f_pos, count); |
| 628 |
if (retval) |
631 |
if (retval) |
| 629 |
goto fput_out; |
632 |
goto fput_out; |
| 630 |
|
633 |
|