diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 5209e47b7fe3..188cf5fd3e8d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/backing-dev.h> | 28 | #include <linux/backing-dev.h> |
29 | #include <linux/pagevec.h> | 29 | #include <linux/pagevec.h> |
30 | #include <linux/blkdev.h> | 30 | #include <linux/blkdev.h> |
31 | #include <linux/backing-dev.h> | ||
31 | #include <linux/security.h> | 32 | #include <linux/security.h> |
32 | #include <linux/syscalls.h> | 33 | #include <linux/syscalls.h> |
33 | #include <linux/cpuset.h> | 34 | #include <linux/cpuset.h> |
@@ -1299,7 +1300,7 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1299 | 1300 | ||
1300 | size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | 1301 | size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; |
1301 | if (vmf->pgoff >= size) | 1302 | if (vmf->pgoff >= size) |
1302 | goto outside_data_content; | 1303 | return VM_FAULT_SIGBUS; |
1303 | 1304 | ||
1304 | /* If we don't want any read-ahead, don't bother */ | 1305 | /* If we don't want any read-ahead, don't bother */ |
1305 | if (VM_RandomReadHint(vma)) | 1306 | if (VM_RandomReadHint(vma)) |
@@ -1376,7 +1377,7 @@ retry_find: | |||
1376 | if (unlikely(vmf->pgoff >= size)) { | 1377 | if (unlikely(vmf->pgoff >= size)) { |
1377 | unlock_page(page); | 1378 | unlock_page(page); |
1378 | page_cache_release(page); | 1379 | page_cache_release(page); |
1379 | goto outside_data_content; | 1380 | return VM_FAULT_SIGBUS; |
1380 | } | 1381 | } |
1381 | 1382 | ||
1382 | /* | 1383 | /* |
@@ -1387,15 +1388,6 @@ retry_find: | |||
1387 | vmf->page = page; | 1388 | vmf->page = page; |
1388 | return ret | VM_FAULT_LOCKED; | 1389 | return ret | VM_FAULT_LOCKED; |
1389 | 1390 | ||
1390 | outside_data_content: | ||
1391 | /* | ||
1392 | * An external ptracer can access pages that normally aren't | ||
1393 | * accessible.. | ||
1394 | */ | ||
1395 | if (vma->vm_mm == current->mm) | ||
1396 | return VM_FAULT_SIGBUS; | ||
1397 | |||
1398 | /* Fall through to the non-read-ahead case */ | ||
1399 | no_cached_page: | 1391 | no_cached_page: |
1400 | /* | 1392 | /* |
1401 | * We're only likely to ever get here if MADV_RANDOM is in | 1393 | * We're only likely to ever get here if MADV_RANDOM is in |
@@ -2510,21 +2502,17 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, | |||
2510 | } | 2502 | } |
2511 | 2503 | ||
2512 | retval = mapping->a_ops->direct_IO(rw, iocb, iov, offset, nr_segs); | 2504 | retval = mapping->a_ops->direct_IO(rw, iocb, iov, offset, nr_segs); |
2513 | if (retval) | ||
2514 | goto out; | ||
2515 | 2505 | ||
2516 | /* | 2506 | /* |
2517 | * Finally, try again to invalidate clean pages which might have been | 2507 | * Finally, try again to invalidate clean pages which might have been |
2518 | * faulted in by get_user_pages() if the source of the write was an | 2508 | * cached by non-direct readahead, or faulted in by get_user_pages() |
2519 | * mmap()ed region of the file we're writing. That's a pretty crazy | 2509 | * if the source of the write was an mmap'ed region of the file |
2520 | * thing to do, so we don't support it 100%. If this invalidation | 2510 | * we're writing. Either one is a pretty crazy thing to do, |
2521 | * fails and we have -EIOCBQUEUED we ignore the failure. | 2511 | * so we don't support it 100%. If this invalidation |
2512 | * fails, tough, the write still worked... | ||
2522 | */ | 2513 | */ |
2523 | if (rw == WRITE && mapping->nrpages) { | 2514 | if (rw == WRITE && mapping->nrpages) { |
2524 | int err = invalidate_inode_pages2_range(mapping, | 2515 | invalidate_inode_pages2_range(mapping, offset >> PAGE_CACHE_SHIFT, end); |
2525 | offset >> PAGE_CACHE_SHIFT, end); | ||
2526 | if (err && retval >= 0) | ||
2527 | retval = err; | ||
2528 | } | 2516 | } |
2529 | out: | 2517 | out: |
2530 | return retval; | 2518 | return retval; |