aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/aio.c2
-rw-r--r--fs/binfmt_flat.c6
-rw-r--r--fs/lockd/svclock.c4
-rw-r--r--fs/nfs/client.c29
-rw-r--r--fs/nfs/dir.c2
-rw-r--r--fs/nfs/getroot.c3
-rw-r--r--fs/ocfs2/localalloc.c4
-rw-r--r--fs/splice.c46
-rw-r--r--fs/xfs/xfs_buf_item.h5
-rw-r--r--fs/xfs/xfs_log_recover.c51
-rw-r--r--fs/xfs/xfs_trans_buf.c1
11 files changed, 73 insertions, 80 deletions
diff --git a/fs/aio.c b/fs/aio.c
index dbe699e9828c..ea2e19820381 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1562,6 +1562,7 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1562 fput(file); 1562 fput(file);
1563 return -EAGAIN; 1563 return -EAGAIN;
1564 } 1564 }
1565 req->ki_filp = file;
1565 if (iocb->aio_flags & IOCB_FLAG_RESFD) { 1566 if (iocb->aio_flags & IOCB_FLAG_RESFD) {
1566 /* 1567 /*
1567 * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an 1568 * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an
@@ -1576,7 +1577,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1576 } 1577 }
1577 } 1578 }
1578 1579
1579 req->ki_filp = file;
1580 ret = put_user(req->ki_key, &user_iocb->aio_key); 1580 ret = put_user(req->ki_key, &user_iocb->aio_key);
1581 if (unlikely(ret)) { 1581 if (unlikely(ret)) {
1582 dprintk("EFAULT: aio_key\n"); 1582 dprintk("EFAULT: aio_key\n");
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 861141b4f6d6..fcb3405bb14e 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -742,6 +742,7 @@ static int load_flat_file(struct linux_binprm * bprm,
742 * __start to address 4 so that is okay). 742 * __start to address 4 so that is okay).
743 */ 743 */
744 if (rev > OLD_FLAT_VERSION) { 744 if (rev > OLD_FLAT_VERSION) {
745 unsigned long persistent = 0;
745 for (i=0; i < relocs; i++) { 746 for (i=0; i < relocs; i++) {
746 unsigned long addr, relval; 747 unsigned long addr, relval;
747 748
@@ -749,6 +750,8 @@ static int load_flat_file(struct linux_binprm * bprm,
749 relocated (of course, the address has to be 750 relocated (of course, the address has to be
750 relocated first). */ 751 relocated first). */
751 relval = ntohl(reloc[i]); 752 relval = ntohl(reloc[i]);
753 if (flat_set_persistent (relval, &persistent))
754 continue;
752 addr = flat_get_relocate_addr(relval); 755 addr = flat_get_relocate_addr(relval);
753 rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1); 756 rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1);
754 if (rp == (unsigned long *)RELOC_FAILED) { 757 if (rp == (unsigned long *)RELOC_FAILED) {
@@ -757,7 +760,8 @@ static int load_flat_file(struct linux_binprm * bprm,
757 } 760 }
758 761
759 /* Get the pointer's value. */ 762 /* Get the pointer's value. */
760 addr = flat_get_addr_from_rp(rp, relval, flags); 763 addr = flat_get_addr_from_rp(rp, relval, flags,
764 &persistent);
761 if (addr != 0) { 765 if (addr != 0) {
762 /* 766 /*
763 * Do the relocation. PIC relocs in the data section are 767 * Do the relocation. PIC relocs in the data section are
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index d098c7af0d22..d120ec39bcb0 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -485,8 +485,10 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
485 return nlm_granted; 485 return nlm_granted;
486 /* Create host handle for callback */ 486 /* Create host handle for callback */
487 host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len); 487 host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
488 if (host == NULL) 488 if (host == NULL) {
489 kfree(conf);
489 return nlm_lck_denied_nolocks; 490 return nlm_lck_denied_nolocks;
491 }
490 block = nlmsvc_create_block(rqstp, host, file, lock, cookie); 492 block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
491 if (block == NULL) { 493 if (block == NULL) {
492 kfree(conf); 494 kfree(conf);
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index a49f9feff776..a204484072f3 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -588,16 +588,6 @@ static int nfs_init_server(struct nfs_server *server, const struct nfs_mount_dat
588 server->namelen = data->namlen; 588 server->namelen = data->namlen;
589 /* Create a client RPC handle for the NFSv3 ACL management interface */ 589 /* Create a client RPC handle for the NFSv3 ACL management interface */
590 nfs_init_server_aclclient(server); 590 nfs_init_server_aclclient(server);
591 if (clp->cl_nfsversion == 3) {
592 if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
593 server->namelen = NFS3_MAXNAMLEN;
594 if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
595 server->caps |= NFS_CAP_READDIRPLUS;
596 } else {
597 if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN)
598 server->namelen = NFS2_MAXNAMLEN;
599 }
600
601 dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp); 591 dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp);
602 return 0; 592 return 0;
603 593
@@ -794,6 +784,16 @@ struct nfs_server *nfs_create_server(const struct nfs_mount_data *data,
794 error = nfs_probe_fsinfo(server, mntfh, &fattr); 784 error = nfs_probe_fsinfo(server, mntfh, &fattr);
795 if (error < 0) 785 if (error < 0)
796 goto error; 786 goto error;
787 if (server->nfs_client->rpc_ops->version == 3) {
788 if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
789 server->namelen = NFS3_MAXNAMLEN;
790 if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
791 server->caps |= NFS_CAP_READDIRPLUS;
792 } else {
793 if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN)
794 server->namelen = NFS2_MAXNAMLEN;
795 }
796
797 if (!(fattr.valid & NFS_ATTR_FATTR)) { 797 if (!(fattr.valid & NFS_ATTR_FATTR)) {
798 error = server->nfs_client->rpc_ops->getattr(server, mntfh, &fattr); 798 error = server->nfs_client->rpc_ops->getattr(server, mntfh, &fattr);
799 if (error < 0) { 799 if (error < 0) {
@@ -984,6 +984,9 @@ struct nfs_server *nfs4_create_server(const struct nfs4_mount_data *data,
984 if (error < 0) 984 if (error < 0)
985 goto error; 985 goto error;
986 986
987 if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
988 server->namelen = NFS4_MAXNAMLEN;
989
987 BUG_ON(!server->nfs_client); 990 BUG_ON(!server->nfs_client);
988 BUG_ON(!server->nfs_client->rpc_ops); 991 BUG_ON(!server->nfs_client->rpc_ops);
989 BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); 992 BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
@@ -1056,6 +1059,9 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
1056 if (error < 0) 1059 if (error < 0)
1057 goto error; 1060 goto error;
1058 1061
1062 if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
1063 server->namelen = NFS4_MAXNAMLEN;
1064
1059 dprintk("Referral FSID: %llx:%llx\n", 1065 dprintk("Referral FSID: %llx:%llx\n",
1060 (unsigned long long) server->fsid.major, 1066 (unsigned long long) server->fsid.major,
1061 (unsigned long long) server->fsid.minor); 1067 (unsigned long long) server->fsid.minor);
@@ -1115,6 +1121,9 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
1115 if (error < 0) 1121 if (error < 0)
1116 goto out_free_server; 1122 goto out_free_server;
1117 1123
1124 if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
1125 server->namelen = NFS4_MAXNAMLEN;
1126
1118 dprintk("Cloned FSID: %llx:%llx\n", 1127 dprintk("Cloned FSID: %llx:%llx\n",
1119 (unsigned long long) server->fsid.major, 1128 (unsigned long long) server->fsid.major,
1120 (unsigned long long) server->fsid.minor); 1129 (unsigned long long) server->fsid.minor);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ea97408e423e..e4a04d16b8b0 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1162,6 +1162,8 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
1162 } 1162 }
1163 if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR)) 1163 if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR))
1164 return NULL; 1164 return NULL;
1165 if (name.len > NFS_SERVER(dir)->namelen)
1166 return NULL;
1165 /* Note: caller is already holding the dir->i_mutex! */ 1167 /* Note: caller is already holding the dir->i_mutex! */
1166 dentry = d_alloc(parent, &name); 1168 dentry = d_alloc(parent, &name);
1167 if (dentry == NULL) 1169 if (dentry == NULL)
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index d1cbf0a0fbb2..522e5ad4d8ad 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -175,6 +175,9 @@ next_component:
175 path++; 175 path++;
176 name.len = path - (const char *) name.name; 176 name.len = path - (const char *) name.name;
177 177
178 if (name.len > NFS4_MAXNAMLEN)
179 return -ENAMETOOLONG;
180
178eat_dot_dir: 181eat_dot_dir:
179 while (*path == '/') 182 while (*path == '/')
180 path++; 183 path++;
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index de984d272576..d272847d5a07 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -514,8 +514,10 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
514 ac->ac_bh = osb->local_alloc_bh; 514 ac->ac_bh = osb->local_alloc_bh;
515 status = 0; 515 status = 0;
516bail: 516bail:
517 if (status < 0 && local_alloc_inode) 517 if (status < 0 && local_alloc_inode) {
518 mutex_unlock(&local_alloc_inode->i_mutex);
518 iput(local_alloc_inode); 519 iput(local_alloc_inode);
520 }
519 521
520 mlog_exit(status); 522 mlog_exit(status);
521 return status; 523 return status;
diff --git a/fs/splice.c b/fs/splice.c
index c010a72ca2d2..e95a36228863 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1224,6 +1224,33 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1224} 1224}
1225 1225
1226/* 1226/*
1227 * Do a copy-from-user while holding the mmap_semaphore for reading, in a
1228 * manner safe from deadlocking with simultaneous mmap() (grabbing mmap_sem
1229 * for writing) and page faulting on the user memory pointed to by src.
1230 * This assumes that we will very rarely hit the partial != 0 path, or this
1231 * will not be a win.
1232 */
1233static int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n)
1234{
1235 int partial;
1236
1237 pagefault_disable();
1238 partial = __copy_from_user_inatomic(dst, src, n);
1239 pagefault_enable();
1240
1241 /*
1242 * Didn't copy everything, drop the mmap_sem and do a faulting copy
1243 */
1244 if (unlikely(partial)) {
1245 up_read(&current->mm->mmap_sem);
1246 partial = copy_from_user(dst, src, n);
1247 down_read(&current->mm->mmap_sem);
1248 }
1249
1250 return partial;
1251}
1252
1253/*
1227 * Map an iov into an array of pages and offset/length tupples. With the 1254 * Map an iov into an array of pages and offset/length tupples. With the
1228 * partial_page structure, we can map several non-contiguous ranges into 1255 * partial_page structure, we can map several non-contiguous ranges into
1229 * our ones pages[] map instead of splitting that operation into pieces. 1256 * our ones pages[] map instead of splitting that operation into pieces.
@@ -1236,31 +1263,26 @@ static int get_iovec_page_array(const struct iovec __user *iov,
1236{ 1263{
1237 int buffers = 0, error = 0; 1264 int buffers = 0, error = 0;
1238 1265
1239 /*
1240 * It's ok to take the mmap_sem for reading, even
1241 * across a "get_user()".
1242 */
1243 down_read(&current->mm->mmap_sem); 1266 down_read(&current->mm->mmap_sem);
1244 1267
1245 while (nr_vecs) { 1268 while (nr_vecs) {
1246 unsigned long off, npages; 1269 unsigned long off, npages;
1270 struct iovec entry;
1247 void __user *base; 1271 void __user *base;
1248 size_t len; 1272 size_t len;
1249 int i; 1273 int i;
1250 1274
1251 /* 1275 error = -EFAULT;
1252 * Get user address base and length for this iovec. 1276 if (copy_from_user_mmap_sem(&entry, iov, sizeof(entry)))
1253 */
1254 error = get_user(base, &iov->iov_base);
1255 if (unlikely(error))
1256 break;
1257 error = get_user(len, &iov->iov_len);
1258 if (unlikely(error))
1259 break; 1277 break;
1260 1278
1279 base = entry.iov_base;
1280 len = entry.iov_len;
1281
1261 /* 1282 /*
1262 * Sanity check this iovec. 0 read succeeds. 1283 * Sanity check this iovec. 0 read succeeds.
1263 */ 1284 */
1285 error = 0;
1264 if (unlikely(!len)) 1286 if (unlikely(!len))
1265 break; 1287 break;
1266 error = -EFAULT; 1288 error = -EFAULT;
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index fa25b7dcc6c3..d7e136143066 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -52,11 +52,6 @@ typedef struct xfs_buf_log_format_t {
52#define XFS_BLI_UDQUOT_BUF 0x4 52#define XFS_BLI_UDQUOT_BUF 0x4
53#define XFS_BLI_PDQUOT_BUF 0x8 53#define XFS_BLI_PDQUOT_BUF 0x8
54#define XFS_BLI_GDQUOT_BUF 0x10 54#define XFS_BLI_GDQUOT_BUF 0x10
55/*
56 * This flag indicates that the buffer contains newly allocated
57 * inodes.
58 */
59#define XFS_BLI_INODE_NEW_BUF 0x20
60 55
61#define XFS_BLI_CHUNK 128 56#define XFS_BLI_CHUNK 128
62#define XFS_BLI_SHIFT 7 57#define XFS_BLI_SHIFT 7
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 7174991f4bef..8ae6e8e5f3db 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -1874,7 +1874,6 @@ xlog_recover_do_inode_buffer(
1874/*ARGSUSED*/ 1874/*ARGSUSED*/
1875STATIC void 1875STATIC void
1876xlog_recover_do_reg_buffer( 1876xlog_recover_do_reg_buffer(
1877 xfs_mount_t *mp,
1878 xlog_recover_item_t *item, 1877 xlog_recover_item_t *item,
1879 xfs_buf_t *bp, 1878 xfs_buf_t *bp,
1880 xfs_buf_log_format_t *buf_f) 1879 xfs_buf_log_format_t *buf_f)
@@ -1885,50 +1884,6 @@ xlog_recover_do_reg_buffer(
1885 unsigned int *data_map = NULL; 1884 unsigned int *data_map = NULL;
1886 unsigned int map_size = 0; 1885 unsigned int map_size = 0;
1887 int error; 1886 int error;
1888 int stale_buf = 1;
1889
1890 /*
1891 * Scan through the on-disk inode buffer and attempt to
1892 * determine if it has been written to since it was logged.
1893 *
1894 * - If any of the magic numbers are incorrect then the buffer is stale
1895 * - If any of the modes are non-zero then the buffer is not stale
1896 * - If all of the modes are zero and at least one of the generation
1897 * counts is non-zero then the buffer is stale
1898 *
1899 * If the end result is a stale buffer then the log buffer is replayed
1900 * otherwise it is skipped.
1901 *
1902 * This heuristic is not perfect. It can be improved by scanning the
1903 * entire inode chunk for evidence that any of the inode clusters have
1904 * been updated. To fix this problem completely we will need a major
1905 * architectural change to the logging system.
1906 */
1907 if (buf_f->blf_flags & XFS_BLI_INODE_NEW_BUF) {
1908 xfs_dinode_t *dip;
1909 int inodes_per_buf;
1910 int mode_count = 0;
1911 int gen_count = 0;
1912
1913 stale_buf = 0;
1914 inodes_per_buf = XFS_BUF_COUNT(bp) >> mp->m_sb.sb_inodelog;
1915 for (i = 0; i < inodes_per_buf; i++) {
1916 dip = (xfs_dinode_t *)xfs_buf_offset(bp,
1917 i * mp->m_sb.sb_inodesize);
1918 if (be16_to_cpu(dip->di_core.di_magic) !=
1919 XFS_DINODE_MAGIC) {
1920 stale_buf = 1;
1921 break;
1922 }
1923 if (dip->di_core.di_mode)
1924 mode_count++;
1925 if (dip->di_core.di_gen)
1926 gen_count++;
1927 }
1928
1929 if (!mode_count && gen_count)
1930 stale_buf = 1;
1931 }
1932 1887
1933 switch (buf_f->blf_type) { 1888 switch (buf_f->blf_type) {
1934 case XFS_LI_BUF: 1889 case XFS_LI_BUF:
@@ -1962,7 +1917,7 @@ xlog_recover_do_reg_buffer(
1962 -1, 0, XFS_QMOPT_DOWARN, 1917 -1, 0, XFS_QMOPT_DOWARN,
1963 "dquot_buf_recover"); 1918 "dquot_buf_recover");
1964 } 1919 }
1965 if (!error && stale_buf) 1920 if (!error)
1966 memcpy(xfs_buf_offset(bp, 1921 memcpy(xfs_buf_offset(bp,
1967 (uint)bit << XFS_BLI_SHIFT), /* dest */ 1922 (uint)bit << XFS_BLI_SHIFT), /* dest */
1968 item->ri_buf[i].i_addr, /* source */ 1923 item->ri_buf[i].i_addr, /* source */
@@ -2134,7 +2089,7 @@ xlog_recover_do_dquot_buffer(
2134 if (log->l_quotaoffs_flag & type) 2089 if (log->l_quotaoffs_flag & type)
2135 return; 2090 return;
2136 2091
2137 xlog_recover_do_reg_buffer(mp, item, bp, buf_f); 2092 xlog_recover_do_reg_buffer(item, bp, buf_f);
2138} 2093}
2139 2094
2140/* 2095/*
@@ -2235,7 +2190,7 @@ xlog_recover_do_buffer_trans(
2235 (XFS_BLI_UDQUOT_BUF|XFS_BLI_PDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) { 2190 (XFS_BLI_UDQUOT_BUF|XFS_BLI_PDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) {
2236 xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f); 2191 xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f);
2237 } else { 2192 } else {
2238 xlog_recover_do_reg_buffer(mp, item, bp, buf_f); 2193 xlog_recover_do_reg_buffer(item, bp, buf_f);
2239 } 2194 }
2240 if (error) 2195 if (error)
2241 return XFS_ERROR(error); 2196 return XFS_ERROR(error);
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 95fff6872a2f..60b6b898022b 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -966,7 +966,6 @@ xfs_trans_inode_alloc_buf(
966 ASSERT(atomic_read(&bip->bli_refcount) > 0); 966 ASSERT(atomic_read(&bip->bli_refcount) > 0);
967 967
968 bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF; 968 bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF;
969 bip->bli_format.blf_flags |= XFS_BLI_INODE_NEW_BUF;
970} 969}
971 970
972 971