aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c108
1 files changed, 3 insertions, 105 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 79c4b2b0b14e..a4a5260b0279 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -29,7 +29,6 @@
29#include <linux/pagevec.h> 29#include <linux/pagevec.h>
30#include <linux/blkdev.h> 30#include <linux/blkdev.h>
31#include <linux/security.h> 31#include <linux/security.h>
32#include <linux/syscalls.h>
33#include <linux/cpuset.h> 32#include <linux/cpuset.h>
34#include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ 33#include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */
35#include <linux/memcontrol.h> 34#include <linux/memcontrol.h>
@@ -1478,44 +1477,6 @@ out:
1478} 1477}
1479EXPORT_SYMBOL(generic_file_aio_read); 1478EXPORT_SYMBOL(generic_file_aio_read);
1480 1479
1481static ssize_t
1482do_readahead(struct address_space *mapping, struct file *filp,
1483 pgoff_t index, unsigned long nr)
1484{
1485 if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage)
1486 return -EINVAL;
1487
1488 force_page_cache_readahead(mapping, filp, index, nr);
1489 return 0;
1490}
1491
1492SYSCALL_DEFINE(readahead)(int fd, loff_t offset, size_t count)
1493{
1494 ssize_t ret;
1495 struct file *file;
1496
1497 ret = -EBADF;
1498 file = fget(fd);
1499 if (file) {
1500 if (file->f_mode & FMODE_READ) {
1501 struct address_space *mapping = file->f_mapping;
1502 pgoff_t start = offset >> PAGE_CACHE_SHIFT;
1503 pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
1504 unsigned long len = end - start + 1;
1505 ret = do_readahead(mapping, file, start, len);
1506 }
1507 fput(file);
1508 }
1509 return ret;
1510}
1511#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
1512asmlinkage long SyS_readahead(long fd, loff_t offset, long count)
1513{
1514 return SYSC_readahead((int) fd, offset, (size_t) count);
1515}
1516SYSCALL_ALIAS(sys_readahead, SyS_readahead);
1517#endif
1518
1519#ifdef CONFIG_MMU 1480#ifdef CONFIG_MMU
1520/** 1481/**
1521 * page_cache_read - adds requested page to the page cache if not already there 1482 * page_cache_read - adds requested page to the page cache if not already there
@@ -1938,71 +1899,6 @@ struct page *read_cache_page(struct address_space *mapping,
1938} 1899}
1939EXPORT_SYMBOL(read_cache_page); 1900EXPORT_SYMBOL(read_cache_page);
1940 1901
1941/*
1942 * The logic we want is
1943 *
1944 * if suid or (sgid and xgrp)
1945 * remove privs
1946 */
1947int should_remove_suid(struct dentry *dentry)
1948{
1949 umode_t mode = dentry->d_inode->i_mode;
1950 int kill = 0;
1951
1952 /* suid always must be killed */
1953 if (unlikely(mode & S_ISUID))
1954 kill = ATTR_KILL_SUID;
1955
1956 /*
1957 * sgid without any exec bits is just a mandatory locking mark; leave
1958 * it alone. If some exec bits are set, it's a real sgid; kill it.
1959 */
1960 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
1961 kill |= ATTR_KILL_SGID;
1962
1963 if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode)))
1964 return kill;
1965
1966 return 0;
1967}
1968EXPORT_SYMBOL(should_remove_suid);
1969
1970static int __remove_suid(struct dentry *dentry, int kill)
1971{
1972 struct iattr newattrs;
1973
1974 newattrs.ia_valid = ATTR_FORCE | kill;
1975 return notify_change(dentry, &newattrs);
1976}
1977
1978int file_remove_suid(struct file *file)
1979{
1980 struct dentry *dentry = file->f_path.dentry;
1981 struct inode *inode = dentry->d_inode;
1982 int killsuid;
1983 int killpriv;
1984 int error = 0;
1985
1986 /* Fast path for nothing security related */
1987 if (IS_NOSEC(inode))
1988 return 0;
1989
1990 killsuid = should_remove_suid(dentry);
1991 killpriv = security_inode_need_killpriv(dentry);
1992
1993 if (killpriv < 0)
1994 return killpriv;
1995 if (killpriv)
1996 error = security_inode_killpriv(dentry);
1997 if (!error && killsuid)
1998 error = __remove_suid(dentry, killsuid);
1999 if (!error && (inode->i_sb->s_flags & MS_NOSEC))
2000 inode->i_flags |= S_NOSEC;
2001
2002 return error;
2003}
2004EXPORT_SYMBOL(file_remove_suid);
2005
2006static size_t __iovec_copy_from_user_inatomic(char *vaddr, 1902static size_t __iovec_copy_from_user_inatomic(char *vaddr,
2007 const struct iovec *iov, size_t base, size_t bytes) 1903 const struct iovec *iov, size_t base, size_t bytes)
2008{ 1904{
@@ -2528,7 +2424,9 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
2528 if (err) 2424 if (err)
2529 goto out; 2425 goto out;
2530 2426
2531 file_update_time(file); 2427 err = file_update_time(file);
2428 if (err)
2429 goto out;
2532 2430
2533 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 2431 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
2534 if (unlikely(file->f_flags & O_DIRECT)) { 2432 if (unlikely(file->f_flags & O_DIRECT)) {