History

Merge branches 'work.namei', 'work.dcache' and 'work.iov_iter' into for-linus

Al Viro committed 9 years ago

Commit c4364f84 parents 1d0fd57 8f64fb1 ad5cb12 0b62fca34 files · +221 −316Browse files

Unified · Split

34 files
  1. drivers/bluetooth/hci_vhci.c +1 −1
  2. drivers/net/macvtap.c +1 −3
  3. drivers/net/tun.c +2 −5
  4. drivers/staging/lustre/lustre/llite/dcache.c +7 −26
  5. drivers/staging/lustre/lustre/llite/llite_internal.h +3 −14
  6. drivers/staging/lustre/lustre/llite/llite_nfs.c +6 −16
  7. drivers/staging/lustre/lustre/llite/namei.c +1 −12
  8. drivers/staging/lustre/lustre/llite/statahead.c +1 −3
  9. drivers/usb/gadget/function/f_fs.c +1 −1
  10. drivers/usb/gadget/legacy/inode.c +1 −1
  11. drivers/vhost/scsi.c +1 −2
  12. drivers/vhost/vhost.c +1 −2
  13. fs/ceph/dir.c +5 −46
  14. fs/ceph/export.c +2 −24
  15. fs/ceph/file.c +0 −4
  16. fs/ceph/inode.c +6 −16
  17. fs/ceph/super.c +1 −1
  18. fs/ceph/super.h +1 −9
  19. fs/namei.c +54 −93
  20. fs/ncpfs/file.c +1 −1
  21. fs/orangefs/devorangefs-req.c +4 −9
  22. include/linux/skbuff.h +3 −3
  23. include/linux/uio.h +3 −0
  24. include/net/sock.h +3 −3
  25. include/net/udplite.h +1 −1
  26. kernel/printk/printk.c +1 −1
  27. lib/iov_iter.c +96 −2
  28. net/atm/common.c +1 −1
  29. net/bluetooth/l2cap_core.c +3 −3
  30. net/ipv4/ip_output.c +2 −2
  31. net/ipv4/ping.c +4 −4
  32. net/packet/af_packet.c +1 −4
  33. net/tipc/msg.c +2 −2
  34. security/keys/keyctl.c +1 −1
drivers/bluetooth/hci_vhci.c+1−1
@@ -181,7 +181,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *data, · 180 unmodified lines
181 if (!skb)181 if (!skb)
182 return -ENOMEM;182 return -ENOMEM;
183 183
184 if (copy_from_iter(skb_put(skb, len), len, from) != len) {184 if (!copy_from_iter_full(skb_put(skb, len), len, from)) {
185 kfree_skb(skb);185 kfree_skb(skb);
186 return -EFAULT;186 return -EFAULT;
187 }187 }
drivers/net/macvtap.c+1−3
@@ -673,7 +673,6 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 672 unmodified lines
673 int depth;673 int depth;
674 bool zerocopy = false;674 bool zerocopy = false;
675 size_t linear;675 size_t linear;
676 ssize_t n;
677 676
678 if (q->flags & IFF_VNET_HDR) {677 if (q->flags & IFF_VNET_HDR) {
679 vnet_hdr_len = q->vnet_hdr_sz;678 vnet_hdr_len = q->vnet_hdr_sz;
@@ -684,8 +683,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, · 4 unmodified lines
684 len -= vnet_hdr_len;683 len -= vnet_hdr_len;
685 684
686 err = -EFAULT;685 err = -EFAULT;
687 n = copy_from_iter(&vnet_hdr, sizeof(vnet_hdr), from);686 if (!copy_from_iter_full(&vnet_hdr, sizeof(vnet_hdr), from))
688 if (n != sizeof(vnet_hdr))
689 goto err;687 goto err;
690 iov_iter_advance(from, vnet_hdr_len - sizeof(vnet_hdr));688 iov_iter_advance(from, vnet_hdr_len - sizeof(vnet_hdr));
691 if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&689 if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
drivers/net/tun.c+2−5
@@ -1171,7 +1171,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 1170 unmodified lines
1171 bool zerocopy = false;1171 bool zerocopy = false;
1172 int err;1172 int err;
1173 u32 rxhash;1173 u32 rxhash;
1174 ssize_t n;
1175 1174
1176 if (!(tun->dev->flags & IFF_UP))1175 if (!(tun->dev->flags & IFF_UP))
1177 return -EIO;1176 return -EIO;
@@ -1181,8 +1180,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 3 unmodified lines
1181 return -EINVAL;1180 return -EINVAL;
1182 len -= sizeof(pi);1181 len -= sizeof(pi);
1183 1182
1184 n = copy_from_iter(&pi, sizeof(pi), from);1183 if (!copy_from_iter_full(&pi, sizeof(pi), from))
1185 if (n != sizeof(pi))
1186 return -EFAULT;1184 return -EFAULT;
1187 }1185 }
1188 1186
@@ -1191,8 +1189,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 2 unmodified lines
1191 return -EINVAL;1189 return -EINVAL;
1192 len -= tun->vnet_hdr_sz;1190 len -= tun->vnet_hdr_sz;
1193 1191
1194 n = copy_from_iter(&gso, sizeof(gso), from);1192 if (!copy_from_iter_full(&gso, sizeof(gso), from))
1195 if (n != sizeof(gso))
1196 return -EFAULT;1193 return -EFAULT;
1197 1194
1198 if ((gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&1195 if ((gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
drivers/staging/lustre/lustre/llite/dcache.c+7−26
@@ -57,9 +57,6 @@ static void ll_release(struct dentry *de) · 56 unmodified lines
57 57
58 LASSERT(de);58 LASSERT(de);
59 lld = ll_d2d(de);59 lld = ll_d2d(de);
60 if (!lld) /* NFS copies the de->d_op methods (bug 4655) */
61 return;
62
63 if (lld->lld_it) {60 if (lld->lld_it) {
64 ll_intent_release(lld->lld_it);61 ll_intent_release(lld->lld_it);
65 kfree(lld->lld_it);62 kfree(lld->lld_it);
@@ -126,30 +123,13 @@ static int ll_ddelete(const struct dentry *de) · 60 unmodified lines
126 return 0;123 return 0;
127}124}
128 125
129int ll_d_init(struct dentry *de)126static int ll_d_init(struct dentry *de)
130{127{
131 CDEBUG(D_DENTRY, "ldd on dentry %pd (%p) parent %p inode %p refc %d\n",128 struct ll_dentry_data *lld = kzalloc(sizeof(*lld), GFP_KERNEL);
132 de, de, de->d_parent, d_inode(de), d_count(de));129 if (unlikely(!lld))
133 130 return -ENOMEM;
134 if (!de->d_fsdata) {131 lld->lld_invalid = 1;
135 struct ll_dentry_data *lld;132 de->d_fsdata = lld;
136
137 lld = kzalloc(sizeof(*lld), GFP_NOFS);
138 if (likely(lld)) {
139 spin_lock(&de->d_lock);
140 if (likely(!de->d_fsdata)) {
141 de->d_fsdata = lld;
142 __d_lustre_invalidate(de);
143 } else {
144 kfree(lld);
145 }
146 spin_unlock(&de->d_lock);
147 } else {
148 return -ENOMEM;
149 }
150 }
151 LASSERT(de->d_op == &ll_d_ops);
152
153 return 0;133 return 0;
154}134}
155 135
@@ -300,6 +280,7 @@ static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) · 144 unmodified lines
300}280}
301 281
302const struct dentry_operations ll_d_ops = {282const struct dentry_operations ll_d_ops = {
283 .d_init = ll_d_init,
303 .d_revalidate = ll_revalidate_nd,284 .d_revalidate = ll_revalidate_nd,
304 .d_release = ll_release,285 .d_release = ll_release,
305 .d_delete = ll_ddelete,286 .d_delete = ll_ddelete,
drivers/staging/lustre/lustre/llite/llite_internal.h+3−14
@@ -801,7 +801,6 @@ int ll_hsm_release(struct inode *inode); · 800 unmodified lines
801 801
802/* llite/dcache.c */802/* llite/dcache.c */
803 803
804int ll_d_init(struct dentry *de);
805extern const struct dentry_operations ll_d_ops;804extern const struct dentry_operations ll_d_ops;
806void ll_intent_drop_lock(struct lookup_intent *);805void ll_intent_drop_lock(struct lookup_intent *);
807void ll_intent_release(struct lookup_intent *);806void ll_intent_release(struct lookup_intent *);
@@ -1189,7 +1188,7 @@ dentry_may_statahead(struct inode *dir, struct dentry *dentry) · 381 unmodified lines
1189 * 'lld_sa_generation == lli->lli_sa_generation'.1188 * 'lld_sa_generation == lli->lli_sa_generation'.
1190 */1189 */
1191 ldd = ll_d2d(dentry);1190 ldd = ll_d2d(dentry);
1192 if (ldd && ldd->lld_sa_generation == lli->lli_sa_generation)1191 if (ldd->lld_sa_generation == lli->lli_sa_generation)
1193 return false;1192 return false;
1194 1193
1195 return true;1194 return true;
@@ -1317,17 +1316,7 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, · 121 unmodified lines
1317 1316
1318static inline int d_lustre_invalid(const struct dentry *dentry)1317static inline int d_lustre_invalid(const struct dentry *dentry)
1319{1318{
1320 struct ll_dentry_data *lld = ll_d2d(dentry);1319 return ll_d2d(dentry)->lld_invalid;
1321
1322 return !lld || lld->lld_invalid;
1323}
1324
1325static inline void __d_lustre_invalidate(struct dentry *dentry)
1326{
1327 struct ll_dentry_data *lld = ll_d2d(dentry);
1328
1329 if (lld)
1330 lld->lld_invalid = 1;
1331}1320}
1332 1321
1333/*1322/*
@@ -1343,7 +1332,7 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested) · 9 unmodified lines
1343 1332
1344 spin_lock_nested(&dentry->d_lock,1333 spin_lock_nested(&dentry->d_lock,
1345 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);1334 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
1346 __d_lustre_invalidate(dentry);1335 ll_d2d(dentry)->lld_invalid = 1;
1347 /*1336 /*
1348 * We should be careful about dentries created by d_obtain_alias().1337 * We should be careful about dentries created by d_obtain_alias().
1349 * These dentries are not put in the dentry tree, instead they are1338 * These dentries are not put in the dentry tree, instead they are
drivers/staging/lustre/lustre/llite/llite_nfs.c+6−16
@@ -169,22 +169,12 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren · 168 unmodified lines
169 /* N.B. d_obtain_alias() drops inode ref on error */169 /* N.B. d_obtain_alias() drops inode ref on error */
170 result = d_obtain_alias(inode);170 result = d_obtain_alias(inode);
171 if (!IS_ERR(result)) {171 if (!IS_ERR(result)) {
172 int rc;172 /*
173 173 * Need to signal to the ll_intent_file_open that
174 rc = ll_d_init(result);174 * we came from NFS and so opencache needs to be
175 if (rc < 0) {175 * enabled for this one
176 dput(result);176 */
177 result = ERR_PTR(rc);177 ll_d2d(result)->lld_nfs_dentry = 1;
178 } else {
179 struct ll_dentry_data *ldd = ll_d2d(result);
180
181 /*
182 * Need to signal to the ll_intent_file_open that
183 * we came from NFS and so opencache needs to be
184 * enabled for this one
185 */
186 ldd->lld_nfs_dentry = 1;
187 }
188 }178 }
189 179
190 return result;180 return result;
drivers/staging/lustre/lustre/llite/namei.c+1−12
@@ -395,17 +395,9 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) · 394 unmodified lines
395 */395 */
396struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)396struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
397{397{
398 struct dentry *new;
399 int rc;
400
401 if (inode) {398 if (inode) {
402 new = ll_find_alias(inode, de);399 struct dentry *new = ll_find_alias(inode, de);
403 if (new) {400 if (new) {
404 rc = ll_d_init(new);
405 if (rc < 0) {
406 dput(new);
407 return ERR_PTR(rc);
408 }
409 d_move(new, de);401 d_move(new, de);
410 iput(inode);402 iput(inode);
411 CDEBUG(D_DENTRY,403 CDEBUG(D_DENTRY,
@@ -414,9 +406,6 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de) · 2 unmodified lines
414 return new;406 return new;
415 }407 }
416 }408 }
417 rc = ll_d_init(de);
418 if (rc < 0)
419 return ERR_PTR(rc);
420 d_add(de, inode);409 d_add(de, inode);
421 CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n",410 CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n",
422 de, d_inode(de), d_count(de), de->d_flags);411 de, d_inode(de), d_count(de), de->d_flags);
drivers/staging/lustre/lustre/llite/statahead.c+1−3
@@ -1513,9 +1513,7 @@ out_unplug: · 1512 unmodified lines
1513 */1513 */
1514 ldd = ll_d2d(*dentryp);1514 ldd = ll_d2d(*dentryp);
1515 lli = ll_i2info(dir);1515 lli = ll_i2info(dir);
1516 /* ldd can be NULL if llite lookup failed. */1516 ldd->lld_sa_generation = lli->lli_sa_generation;
1517 if (ldd)
1518 ldd->lld_sa_generation = lli->lli_sa_generation;
1519 sa_put(sai, entry);1517 sa_put(sai, entry);
1520 return rc;1518 return rc;
1521}1519}
drivers/usb/gadget/function/f_fs.c+1−1
@@ -949,7 +949,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) · 948 unmodified lines
949 goto error_mutex;949 goto error_mutex;
950 }950 }
951 if (!io_data->read &&951 if (!io_data->read &&
952 copy_from_iter(data, data_len, &io_data->data) != data_len) {952 !copy_from_iter_full(data, data_len, &io_data->data)) {
953 ret = -EFAULT;953 ret = -EFAULT;
954 goto error_mutex;954 goto error_mutex;
955 }955 }
drivers/usb/gadget/legacy/inode.c+1−1
@@ -667,7 +667,7 @@ ep_write_iter(struct kiocb *iocb, struct iov_iter *from) · 666 unmodified lines
667 return -ENOMEM;667 return -ENOMEM;
668 }668 }
669 669
670 if (unlikely(copy_from_iter(buf, len, from) != len)) {670 if (unlikely(!copy_from_iter_full(buf, len, from))) {
671 value = -EFAULT;671 value = -EFAULT;
672 goto out;672 goto out;
673 }673 }
drivers/vhost/scsi.c+1−2
@@ -922,8 +922,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) · 921 unmodified lines
922 */922 */
923 iov_iter_init(&out_iter, WRITE, vq->iov, out, out_size);923 iov_iter_init(&out_iter, WRITE, vq->iov, out, out_size);
924 924
925 ret = copy_from_iter(req, req_size, &out_iter);925 if (unlikely(!copy_from_iter_full(req, req_size, &out_iter))) {
926 if (unlikely(ret != req_size)) {
927 vq_err(vq, "Faulted on copy_from_iter\n");926 vq_err(vq, "Faulted on copy_from_iter\n");
928 vhost_scsi_send_bad_target(vs, vq, head, out);927 vhost_scsi_send_bad_target(vs, vq, head, out);
929 continue;928 continue;
drivers/vhost/vhost.c+1−2
@@ -1862,8 +1862,7 @@ static int get_indirect(struct vhost_virtqueue *vq, · 1861 unmodified lines
1862 i, count);1862 i, count);
1863 return -EINVAL;1863 return -EINVAL;
1864 }1864 }
1865 if (unlikely(copy_from_iter(&desc, sizeof(desc), &from) !=1865 if (unlikely(!copy_from_iter_full(&desc, sizeof(desc), &from))) {
1866 sizeof(desc))) {
1867 vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n",1866 vq_err(vq, "Failed indirect descriptor: idx %d, %zx\n",
1868 i, (size_t)vhost64_to_cpu(vq, indirect->addr) + i * sizeof desc);1867 i, (size_t)vhost64_to_cpu(vq, indirect->addr) + i * sizeof desc);
1869 return -EINVAL;1868 return -EINVAL;
fs/ceph/dir.c+5−46
@@ -32,40 +32,19 @@ const struct dentry_operations ceph_dentry_ops; · 31 unmodified lines
32/*32/*
33 * Initialize ceph dentry state.33 * Initialize ceph dentry state.
34 */34 */
35int ceph_init_dentry(struct dentry *dentry)35static int ceph_d_init(struct dentry *dentry)
36{36{
37 struct ceph_dentry_info *di;37 struct ceph_dentry_info *di;
38 38
39 if (dentry->d_fsdata)
40 return 0;
41
42 di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);39 di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
43 if (!di)40 if (!di)
44 return -ENOMEM; /* oh well */41 return -ENOMEM; /* oh well */
45 42
46 spin_lock(&dentry->d_lock);
47 if (dentry->d_fsdata) {
48 /* lost a race */
49 kmem_cache_free(ceph_dentry_cachep, di);
50 goto out_unlock;
51 }
52
53 if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_NOSNAP)
54 d_set_d_op(dentry, &ceph_dentry_ops);
55 else if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR)
56 d_set_d_op(dentry, &ceph_snapdir_dentry_ops);
57 else
58 d_set_d_op(dentry, &ceph_snap_dentry_ops);
59
60 di->dentry = dentry;43 di->dentry = dentry;
61 di->lease_session = NULL;44 di->lease_session = NULL;
62 di->time = jiffies;45 di->time = jiffies;
63 /* avoid reordering d_fsdata setup so that the check above is safe */
64 smp_mb();
65 dentry->d_fsdata = di;46 dentry->d_fsdata = di;
66 ceph_dentry_lru_add(dentry);47 ceph_dentry_lru_add(dentry);
67out_unlock:
68 spin_unlock(&dentry->d_lock);
69 return 0;48 return 0;
70}49}
71 50
@@ -737,10 +716,6 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, · 665 unmodified lines
737 if (dentry->d_name.len > NAME_MAX)716 if (dentry->d_name.len > NAME_MAX)
738 return ERR_PTR(-ENAMETOOLONG);717 return ERR_PTR(-ENAMETOOLONG);
739 718
740 err = ceph_init_dentry(dentry);
741 if (err < 0)
742 return ERR_PTR(err);
743
744 /* can we conclude ENOENT locally? */719 /* can we conclude ENOENT locally? */
745 if (d_really_is_negative(dentry)) {720 if (d_really_is_negative(dentry)) {
746 struct ceph_inode_info *ci = ceph_inode(dir);721 struct ceph_inode_info *ci = ceph_inode(dir);
@@ -1319,16 +1294,6 @@ static void ceph_d_release(struct dentry *dentry) · 572 unmodified lines
1319 kmem_cache_free(ceph_dentry_cachep, di);1294 kmem_cache_free(ceph_dentry_cachep, di);
1320}1295}
1321 1296
1322static int ceph_snapdir_d_revalidate(struct dentry *dentry,
1323 unsigned int flags)
1324{
1325 /*
1326 * Eventually, we'll want to revalidate snapped metadata
1327 * too... probably...
1328 */
1329 return 1;
1330}
1331
1332/*1297/*
1333 * When the VFS prunes a dentry from the cache, we need to clear the1298 * When the VFS prunes a dentry from the cache, we need to clear the
1334 * complete flag on the parent directory.1299 * complete flag on the parent directory.
@@ -1347,6 +1312,9 @@ static void ceph_d_prune(struct dentry *dentry) · 12 unmodified lines
1347 if (d_unhashed(dentry))1312 if (d_unhashed(dentry))
1348 return;1313 return;
1349 1314
1315 if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR)
1316 return;
1317
1350 /*1318 /*
1351 * we hold d_lock, so d_parent is stable, and d_fsdata is never1319 * we hold d_lock, so d_parent is stable, and d_fsdata is never
1352 * cleared until d_release1320 * cleared until d_release
@@ -1517,14 +1485,5 @@ const struct dentry_operations ceph_dentry_ops = { · 164 unmodified lines
1517 .d_revalidate = ceph_d_revalidate,1485 .d_revalidate = ceph_d_revalidate,
1518 .d_release = ceph_d_release,1486 .d_release = ceph_d_release,
1519 .d_prune = ceph_d_prune,1487 .d_prune = ceph_d_prune,
1520};1488 .d_init = ceph_d_init,
1521
1522const struct dentry_operations ceph_snapdir_dentry_ops = {
1523 .d_revalidate = ceph_snapdir_d_revalidate,
1524 .d_release = ceph_d_release,
1525};
1526
1527const struct dentry_operations ceph_snap_dentry_ops = {
1528 .d_release = ceph_d_release,
1529 .d_prune = ceph_d_prune,
1530};1489};
fs/ceph/export.c+2−24
@@ -62,7 +62,6 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino) · 61 unmodified lines
62{62{
63 struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;63 struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
64 struct inode *inode;64 struct inode *inode;
65 struct dentry *dentry;
66 struct ceph_vino vino;65 struct ceph_vino vino;
67 int err;66 int err;
68 67
@@ -94,16 +93,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino) · 25 unmodified lines
94 return ERR_PTR(-ESTALE);93 return ERR_PTR(-ESTALE);
95 }94 }
96 95
97 dentry = d_obtain_alias(inode);96 return d_obtain_alias(inode);
98 if (IS_ERR(dentry))
99 return dentry;
100 err = ceph_init_dentry(dentry);
101 if (err < 0) {
102 dput(dentry);
103 return ERR_PTR(err);
104 }
105 dout("__fh_to_dentry %llx %p dentry %p\n", ino, inode, dentry);
106 return dentry;
107}97}
108 98
109/*99/*
@@ -131,7 +121,6 @@ static struct dentry *__get_parent(struct super_block *sb, · 21 unmodified lines
131 struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;121 struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
132 struct ceph_mds_request *req;122 struct ceph_mds_request *req;
133 struct inode *inode;123 struct inode *inode;
134 struct dentry *dentry;
135 int mask;124 int mask;
136 int err;125 int err;
137 126
@@ -164,18 +153,7 @@ static struct dentry *__get_parent(struct super_block *sb, · 26 unmodified lines
164 if (!inode)153 if (!inode)
165 return ERR_PTR(-ENOENT);154 return ERR_PTR(-ENOENT);
166 155
167 dentry = d_obtain_alias(inode);156 return d_obtain_alias(inode);
168 if (IS_ERR(dentry))
169 return dentry;
170 err = ceph_init_dentry(dentry);
171 if (err < 0) {
172 dput(dentry);
173 return ERR_PTR(err);
174 }
175 dout("__get_parent ino %llx parent %p ino %llx.%llx\n",
176 child ? ceph_ino(d_inode(child)) : ino,
177 dentry, ceph_vinop(inode));
178 return dentry;
179}157}
180 158
181static struct dentry *ceph_get_parent(struct dentry *child)159static struct dentry *ceph_get_parent(struct dentry *child)
fs/ceph/file.c+0−4
@@ -351,10 +351,6 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, · 350 unmodified lines
351 if (dentry->d_name.len > NAME_MAX)351 if (dentry->d_name.len > NAME_MAX)
352 return -ENAMETOOLONG;352 return -ENAMETOOLONG;
353 353
354 err = ceph_init_dentry(dentry);
355 if (err < 0)
356 return err;
357
358 if (flags & O_CREAT) {354 if (flags & O_CREAT) {
359 err = ceph_pre_init_acls(dir, &mode, &acls);355 err = ceph_pre_init_acls(dir, &mode, &acls);
360 if (err < 0)356 if (err < 0)
fs/ceph/inode.c+6−16
@@ -1023,16 +1023,17 @@ static void update_dentry_lease(struct dentry *dentry, · 1022 unmodified lines
1023 long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000;1023 long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000;
1024 struct inode *dir;1024 struct inode *dir;
1025 1025
1026 /* only track leases on regular dentries */
1027 if (dentry->d_op != &ceph_dentry_ops)
1028 return;
1029
1030 spin_lock(&dentry->d_lock);1026 spin_lock(&dentry->d_lock);
1031 dout("update_dentry_lease %p duration %lu ms ttl %lu\n",1027 dout("update_dentry_lease %p duration %lu ms ttl %lu\n",
1032 dentry, duration, ttl);1028 dentry, duration, ttl);
1033 1029
1034 /* make lease_rdcache_gen match directory */1030 /* make lease_rdcache_gen match directory */
1035 dir = d_inode(dentry->d_parent);1031 dir = d_inode(dentry->d_parent);
1032
1033 /* only track leases on regular dentries */
1034 if (ceph_snap(dir) != CEPH_NOSNAP)
1035 goto out_unlock;
1036
1036 di->lease_shared_gen = ceph_inode(dir)->i_shared_gen;1037 di->lease_shared_gen = ceph_inode(dir)->i_shared_gen;
1037 1038
1038 if (duration == 0)1039 if (duration == 0)
@@ -1202,12 +1203,7 @@ retry_lookup: · 163 unmodified lines
1202 err = -ENOMEM;1203 err = -ENOMEM;
1203 goto done;1204 goto done;
1204 }1205 }
1205 err = ceph_init_dentry(dn);1206 err = 0;
1206 if (err < 0) {
1207 dput(dn);
1208 dput(parent);
1209 goto done;
1210 }
1211 } else if (d_really_is_positive(dn) &&1207 } else if (d_really_is_positive(dn) &&
1212 (ceph_ino(d_inode(dn)) != vino.ino ||1208 (ceph_ino(d_inode(dn)) != vino.ino ||
1213 ceph_snap(d_inode(dn)) != vino.snap)) {1209 ceph_snap(d_inode(dn)) != vino.snap)) {
@@ -1561,12 +1557,6 @@ retry_lookup: · 347 unmodified lines
1561 err = -ENOMEM;1557 err = -ENOMEM;
1562 goto out;1558 goto out;
1563 }1559 }
1564 ret = ceph_init_dentry(dn);
1565 if (ret < 0) {
1566 dput(dn);
1567 err = ret;
1568 goto out;
1569 }
1570 } else if (d_really_is_positive(dn) &&1560 } else if (d_really_is_positive(dn) &&
1571 (ceph_ino(d_inode(dn)) != vino.ino ||1561 (ceph_ino(d_inode(dn)) != vino.ino ||
1572 ceph_snap(d_inode(dn)) != vino.snap)) {1562 ceph_snap(d_inode(dn)) != vino.snap)) {
fs/ceph/super.c+1−1
@@ -795,7 +795,6 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc, · 794 unmodified lines
795 root = ERR_PTR(-ENOMEM);795 root = ERR_PTR(-ENOMEM);
796 goto out;796 goto out;
797 }797 }
798 ceph_init_dentry(root);
799 dout("open_root_inode success, root dentry is %p\n", root);798 dout("open_root_inode success, root dentry is %p\n", root);
800 } else {799 } else {
801 root = ERR_PTR(err);800 root = ERR_PTR(err);
@@ -879,6 +878,7 @@ static int ceph_set_super(struct super_block *s, void *data) · 77 unmodified lines
879 fsc->sb = s;878 fsc->sb = s;
880 879
881 s->s_op = &ceph_super_ops;880 s->s_op = &ceph_super_ops;
881 s->s_d_op = &ceph_dentry_ops;
882 s->s_export_op = &ceph_export_ops;882 s->s_export_op = &ceph_export_ops;
883 883
884 s->s_time_gran = 1000; /* 1000 ns == 1 us */884 s->s_time_gran = 1000; /* 1000 ns == 1 us */
fs/ceph/super.h+1−9
@@ -934,8 +934,7 @@ extern const struct file_operations ceph_dir_fops; · 933 unmodified lines
934extern const struct file_operations ceph_snapdir_fops;934extern const struct file_operations ceph_snapdir_fops;
935extern const struct inode_operations ceph_dir_iops;935extern const struct inode_operations ceph_dir_iops;
936extern const struct inode_operations ceph_snapdir_iops;936extern const struct inode_operations ceph_snapdir_iops;
937extern const struct dentry_operations ceph_dentry_ops, ceph_snap_dentry_ops,937extern const struct dentry_operations ceph_dentry_ops;
938 ceph_snapdir_dentry_ops;
939 938
940extern loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order);939extern loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order);
941extern int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry);940extern int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry);
@@ -951,13 +950,6 @@ extern void ceph_invalidate_dentry_lease(struct dentry *dentry); · 9 unmodified lines
951extern unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn);950extern unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn);
952extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl);951extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl);
953 952
954/*
955 * our d_ops vary depending on whether the inode is live,
956 * snapshotted (read-only), or a virtual ".snap" directory.
957 */
958int ceph_init_dentry(struct dentry *dentry);
959
960
961/* ioctl.c */953/* ioctl.c */
962extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg);954extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
963 955
fs/namei.c+54−93
@@ -1725,30 +1725,35 @@ static int pick_link(struct nameidata *nd, struct path *link, · 1724 unmodified lines
1725 return 1;1725 return 1;
1726}1726}
1727 1727
1728enum {WALK_FOLLOW = 1, WALK_MORE = 2};
1729
1728/*1730/*
1729 * Do we need to follow links? We _really_ want to be able1731 * Do we need to follow links? We _really_ want to be able
1730 * to do this check without having to look at inode->i_op,1732 * to do this check without having to look at inode->i_op,
1731 * so we keep a cache of "no, this doesn't need follow_link"1733 * so we keep a cache of "no, this doesn't need follow_link"
1732 * for the common case.1734 * for the common case.
1733 */1735 */
1734static inline int should_follow_link(struct nameidata *nd, struct path *link,1736static inline int step_into(struct nameidata *nd, struct path *path,
1735 int follow,1737 int flags, struct inode *inode, unsigned seq)
1736 struct inode *inode, unsigned seq)
1737{1738{
1738 if (likely(!d_is_symlink(link->dentry)))1739 if (!(flags & WALK_MORE) && nd->depth)
1739 return 0;1740 put_link(nd);
1740 if (!follow)1741 if (likely(!d_is_symlink(path->dentry)) ||
1742 !(flags & WALK_FOLLOW || nd->flags & LOOKUP_FOLLOW)) {
1743 /* not a symlink or should not follow */
1744 path_to_nameidata(path, nd);
1745 nd->inode = inode;
1746 nd->seq = seq;
1741 return 0;1747 return 0;
1748 }
1742 /* make sure that d_is_symlink above matches inode */1749 /* make sure that d_is_symlink above matches inode */
1743 if (nd->flags & LOOKUP_RCU) {1750 if (nd->flags & LOOKUP_RCU) {
1744 if (read_seqcount_retry(&link->dentry->d_seq, seq))1751 if (read_seqcount_retry(&path->dentry->d_seq, seq))
1745 return -ECHILD;1752 return -ECHILD;
1746 }1753 }
1747 return pick_link(nd, link, inode, seq);1754 return pick_link(nd, path, inode, seq);
1748}1755}
1749 1756
1750enum {WALK_GET = 1, WALK_PUT = 2};
1751
1752static int walk_component(struct nameidata *nd, int flags)1757static int walk_component(struct nameidata *nd, int flags)
1753{1758{
1754 struct path path;1759 struct path path;
@@ -1762,7 +1767,7 @@ static int walk_component(struct nameidata *nd, int flags) · 7 unmodified lines
1762 */1767 */
1763 if (unlikely(nd->last_type != LAST_NORM)) {1768 if (unlikely(nd->last_type != LAST_NORM)) {
1764 err = handle_dots(nd, nd->last_type);1769 err = handle_dots(nd, nd->last_type);
1765 if (flags & WALK_PUT)1770 if (!(flags & WALK_MORE) && nd->depth)
1766 put_link(nd);1771 put_link(nd);
1767 return err;1772 return err;
1768 }1773 }
@@ -1789,15 +1794,7 @@ static int walk_component(struct nameidata *nd, int flags) · 20 unmodified lines
1789 inode = d_backing_inode(path.dentry);1794 inode = d_backing_inode(path.dentry);
1790 }1795 }
1791 1796
1792 if (flags & WALK_PUT)1797 return step_into(nd, &path, flags, inode, seq);
1793 put_link(nd);
1794 err = should_follow_link(nd, &path, flags & WALK_GET, inode, seq);
1795 if (unlikely(err))
1796 return err;
1797 path_to_nameidata(&path, nd);
1798 nd->inode = inode;
1799 nd->seq = seq;
1800 return 0;
1801}1798}
1802 1799
1803/*1800/*
@@ -2104,9 +2101,10 @@ OK: · 300 unmodified lines
2104 if (!name)2101 if (!name)
2105 return 0;2102 return 0;
2106 /* last component of nested symlink */2103 /* last component of nested symlink */
2107 err = walk_component(nd, WALK_GET | WALK_PUT);2104 err = walk_component(nd, WALK_FOLLOW);
2108 } else {2105 } else {
2109 err = walk_component(nd, WALK_GET);2106 /* not the last component */
2107 err = walk_component(nd, WALK_FOLLOW | WALK_MORE);
2110 }2108 }
2111 if (err < 0)2109 if (err < 0)
2112 return err;2110 return err;
@@ -2248,12 +2246,7 @@ static inline int lookup_last(struct nameidata *nd) · 135 unmodified lines
2248 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;2246 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
2249 2247
2250 nd->flags &= ~LOOKUP_PARENT;2248 nd->flags &= ~LOOKUP_PARENT;
2251 return walk_component(nd,2249 return walk_component(nd, 0);
2252 nd->flags & LOOKUP_FOLLOW
2253 ? nd->depth
2254 ? WALK_PUT | WALK_GET
2255 : WALK_GET
2256 : 0);
2257}2250}
2258 2251
2259/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */2252/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
@@ -2558,28 +2551,9 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags, · 298 unmodified lines
2558}2551}
2559EXPORT_SYMBOL(user_path_at_empty);2552EXPORT_SYMBOL(user_path_at_empty);
2560 2553
2561/*
2562 * NB: most callers don't do anything directly with the reference to the
2563 * to struct filename, but the nd->last pointer points into the name string
2564 * allocated by getname. So we must hold the reference to it until all
2565 * path-walking is complete.
2566 */
2567static inline struct filename *
2568user_path_parent(int dfd, const char __user *path,
2569 struct path *parent,
2570 struct qstr *last,
2571 int *type,
2572 unsigned int flags)
2573{
2574 /* only LOOKUP_REVAL is allowed in extra flags */
2575 return filename_parentat(dfd, getname(path), flags & LOOKUP_REVAL,
2576 parent, last, type);
2577}
2578
2579/**2554/**
2580 * mountpoint_last - look up last component for umount2555 * mountpoint_last - look up last component for umount
2581 * @nd: pathwalk nameidata - currently pointing at parent directory of "last"2556 * @nd: pathwalk nameidata - currently pointing at parent directory of "last"
2582 * @path: pointer to container for result
2583 *2557 *
2584 * This is a special lookup_last function just for umount. In this case, we2558 * This is a special lookup_last function just for umount. In this case, we
2585 * need to resolve the path without doing any revalidation.2559 * need to resolve the path without doing any revalidation.
@@ -2592,23 +2566,20 @@ user_path_parent(int dfd, const char __user *path, · 6 unmodified lines
2592 *2566 *
2593 * Returns:2567 * Returns:
2594 * -error: if there was an error during lookup. This includes -ENOENT if the2568 * -error: if there was an error during lookup. This includes -ENOENT if the
2595 * lookup found a negative dentry. The nd->path reference will also be2569 * lookup found a negative dentry.
2596 * put in this case.
2597 *2570 *
2598 * 0: if we successfully resolved nd->path and found it to not to be a2571 * 0: if we successfully resolved nd->last and found it to not to be a
2599 * symlink that needs to be followed. "path" will also be populated.2572 * symlink that needs to be followed.
2600 * The nd->path reference will also be put.
2601 *2573 *
2602 * 1: if we successfully resolved nd->last and found it to be a symlink2574 * 1: if we successfully resolved nd->last and found it to be a symlink
2603 * that needs to be followed. "path" will be populated with the path2575 * that needs to be followed.
2604 * to the link, and nd->path will *not* be put.
2605 */2576 */
2606static int2577static int
2607mountpoint_last(struct nameidata *nd, struct path *path)2578mountpoint_last(struct nameidata *nd)
2608{2579{
2609 int error = 0;2580 int error = 0;
2610 struct dentry *dentry;
2611 struct dentry *dir = nd->path.dentry;2581 struct dentry *dir = nd->path.dentry;
2582 struct path path;
2612 2583
2613 /* If we're in rcuwalk, drop out of it to handle last component */2584 /* If we're in rcuwalk, drop out of it to handle last component */
2614 if (nd->flags & LOOKUP_RCU) {2585 if (nd->flags & LOOKUP_RCU) {
@@ -2622,37 +2593,28 @@ mountpoint_last(struct nameidata *nd, struct path *path) · 7 unmodified lines
2622 error = handle_dots(nd, nd->last_type);2593 error = handle_dots(nd, nd->last_type);
2623 if (error)2594 if (error)
2624 return error;2595 return error;
2625 dentry = dget(nd->path.dentry);2596 path.dentry = dget(nd->path.dentry);
2626 } else {2597 } else {
2627 dentry = d_lookup(dir, &nd->last);2598 path.dentry = d_lookup(dir, &nd->last);
2628 if (!dentry) {2599 if (!path.dentry) {
2629 /*2600 /*
2630 * No cached dentry. Mounted dentries are pinned in the2601 * No cached dentry. Mounted dentries are pinned in the
2631 * cache, so that means that this dentry is probably2602 * cache, so that means that this dentry is probably
2632 * a symlink or the path doesn't actually point2603 * a symlink or the path doesn't actually point
2633 * to a mounted dentry.2604 * to a mounted dentry.
2634 */2605 */
2635 dentry = lookup_slow(&nd->last, dir,2606 path.dentry = lookup_slow(&nd->last, dir,
2636 nd->flags | LOOKUP_NO_REVAL);2607 nd->flags | LOOKUP_NO_REVAL);
2637 if (IS_ERR(dentry))2608 if (IS_ERR(path.dentry))
2638 return PTR_ERR(dentry);2609 return PTR_ERR(path.dentry);
2639 }2610 }
2640 }2611 }
2641 if (d_is_negative(dentry)) {2612 if (d_is_negative(path.dentry)) {
2642 dput(dentry);2613 dput(path.dentry);
2643 return -ENOENT;2614 return -ENOENT;
2644 }2615 }
2645 if (nd->depth)2616 path.mnt = nd->path.mnt;
2646 put_link(nd);2617 return step_into(nd, &path, 0, d_backing_inode(path.dentry), 0);
2647 path->dentry = dentry;
2648 path->mnt = nd->path.mnt;
2649 error = should_follow_link(nd, path, nd->flags & LOOKUP_FOLLOW,
2650 d_backing_inode(dentry), 0);
2651 if (unlikely(error))
2652 return error;
2653 mntget(path->mnt);
2654 follow_mount(path);
2655 return 0;
2656}2618}
2657 2619
2658/**2620/**
@@ -2672,13 +2634,19 @@ path_mountpoint(struct nameidata *nd, unsigned flags, struct path *path) · 13 unmodified lines
2672 if (IS_ERR(s))2634 if (IS_ERR(s))
2673 return PTR_ERR(s);2635 return PTR_ERR(s);
2674 while (!(err = link_path_walk(s, nd)) &&2636 while (!(err = link_path_walk(s, nd)) &&
2675 (err = mountpoint_last(nd, path)) > 0) {2637 (err = mountpoint_last(nd)) > 0) {
2676 s = trailing_symlink(nd);2638 s = trailing_symlink(nd);
2677 if (IS_ERR(s)) {2639 if (IS_ERR(s)) {
2678 err = PTR_ERR(s);2640 err = PTR_ERR(s);
2679 break;2641 break;
2680 }2642 }
2681 }2643 }
2644 if (!err) {
2645 *path = nd->path;
2646 nd->path.mnt = NULL;
2647 nd->path.dentry = NULL;
2648 follow_mount(path);
2649 }
2682 terminate_walk(nd);2650 terminate_walk(nd);
2683 return err;2651 return err;
2684}2652}
@@ -3335,18 +3303,11 @@ static int do_last(struct nameidata *nd, · 650 unmodified lines
3335 seq = 0; /* out of RCU mode, so the value doesn't matter */3303 seq = 0; /* out of RCU mode, so the value doesn't matter */
3336 inode = d_backing_inode(path.dentry);3304 inode = d_backing_inode(path.dentry);
3337finish_lookup:3305finish_lookup:
3338 if (nd->depth)3306 error = step_into(nd, &path, 0, inode, seq);
3339 put_link(nd);
3340 error = should_follow_link(nd, &path, nd->flags & LOOKUP_FOLLOW,
3341 inode, seq);
3342 if (unlikely(error))3307 if (unlikely(error))
3343 return error;3308 return error;
3344
3345 path_to_nameidata(&path, nd);
3346 nd->inode = inode;
3347 nd->seq = seq;
3348 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
3349finish_open:3309finish_open:
3310 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
3350 error = complete_walk(nd);3311 error = complete_walk(nd);
3351 if (error)3312 if (error)
3352 return error;3313 return error;
@@ -3861,8 +3822,8 @@ static long do_rmdir(int dfd, const char __user *pathname) · 508 unmodified lines
3861 int type;3822 int type;
3862 unsigned int lookup_flags = 0;3823 unsigned int lookup_flags = 0;
3863retry:3824retry:
3864 name = user_path_parent(dfd, pathname,3825 name = filename_parentat(dfd, getname(pathname), lookup_flags,
3865 &path, &last, &type, lookup_flags);3826 &path, &last, &type);
3866 if (IS_ERR(name))3827 if (IS_ERR(name))
3867 return PTR_ERR(name);3828 return PTR_ERR(name);
3868 3829
@@ -3991,8 +3952,8 @@ static long do_unlinkat(int dfd, const char __user *pathname) · 122 unmodified lines
3991 struct inode *delegated_inode = NULL;3952 struct inode *delegated_inode = NULL;
3992 unsigned int lookup_flags = 0;3953 unsigned int lookup_flags = 0;
3993retry:3954retry:
3994 name = user_path_parent(dfd, pathname,3955 name = filename_parentat(dfd, getname(pathname), lookup_flags,
3995 &path, &last, &type, lookup_flags);3956 &path, &last, &type);
3996 if (IS_ERR(name))3957 if (IS_ERR(name))
3997 return PTR_ERR(name);3958 return PTR_ERR(name);
3998 3959
@@ -4491,15 +4452,15 @@ SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, · 492 unmodified lines
4491 target_flags = 0;4452 target_flags = 0;
4492 4453
4493retry:4454retry:
4494 from = user_path_parent(olddfd, oldname,4455 from = filename_parentat(olddfd, getname(oldname), lookup_flags,
4495 &old_path, &old_last, &old_type, lookup_flags);4456 &old_path, &old_last, &old_type);
4496 if (IS_ERR(from)) {4457 if (IS_ERR(from)) {
4497 error = PTR_ERR(from);4458 error = PTR_ERR(from);
4498 goto exit;4459 goto exit;
4499 }4460 }
4500 4461
4501 to = user_path_parent(newdfd, newname,4462 to = filename_parentat(newdfd, getname(newname), lookup_flags,
4502 &new_path, &new_last, &new_type, lookup_flags);4463 &new_path, &new_last, &new_type);
4503 if (IS_ERR(to)) {4464 if (IS_ERR(to)) {
4504 error = PTR_ERR(to);4465 error = PTR_ERR(to);
4505 goto exit1;4466 goto exit1;
fs/ncpfs/file.c+1−1
@@ -203,7 +203,7 @@ ncp_file_write_iter(struct kiocb *iocb, struct iov_iter *from) · 202 unmodified lines
203 bufsize - (pos % bufsize),203 bufsize - (pos % bufsize),
204 iov_iter_count(from));204 iov_iter_count(from));
205 205
206 if (copy_from_iter(bouncebuffer, to_write, from) != to_write) {206 if (!copy_from_iter_full(bouncebuffer, to_write, from)) {
207 errno = -EFAULT;207 errno = -EFAULT;
208 break;208 break;
209 }209 }
fs/orangefs/devorangefs-req.c+4−9
@@ -355,7 +355,6 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 354 unmodified lines
355 __u64 tag;355 __u64 tag;
356 } head;356 } head;
357 int total = ret = iov_iter_count(iter);357 int total = ret = iov_iter_count(iter);
358 int n;
359 int downcall_size = sizeof(struct orangefs_downcall_s);358 int downcall_size = sizeof(struct orangefs_downcall_s);
360 int head_size = sizeof(head);359 int head_size = sizeof(head);
361 360
@@ -372,8 +371,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 10 unmodified lines
372 return -EFAULT;371 return -EFAULT;
373 }372 }
374 373
375 n = copy_from_iter(&head, head_size, iter);374 if (!copy_from_iter_full(&head, head_size, iter)) {
376 if (n < head_size) {
377 gossip_err("%s: failed to copy head.\n", __func__);375 gossip_err("%s: failed to copy head.\n", __func__);
378 return -EFAULT;376 return -EFAULT;
379 }377 }
@@ -407,8 +405,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 27 unmodified lines
407 return ret;405 return ret;
408 }406 }
409 407
410 n = copy_from_iter(&op->downcall, downcall_size, iter);408 if (!copy_from_iter_full(&op->downcall, downcall_size, iter)) {
411 if (n != downcall_size) {
412 gossip_err("%s: failed to copy downcall.\n", __func__);409 gossip_err("%s: failed to copy downcall.\n", __func__);
413 goto Efault;410 goto Efault;
414 }411 }
@@ -462,10 +459,8 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, · 47 unmodified lines
462 goto Enomem;459 goto Enomem;
463 }460 }
464 memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size);461 memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size);
465 n = copy_from_iter(op->downcall.trailer_buf,462 if (!copy_from_iter_full(op->downcall.trailer_buf,
466 op->downcall.trailer_size,463 op->downcall.trailer_size, iter)) {
467 iter);
468 if (n != op->downcall.trailer_size) {
469 gossip_err("%s: failed to copy trailer.\n", __func__);464 gossip_err("%s: failed to copy trailer.\n", __func__);
470 vfree(op->downcall.trailer_buf);465 vfree(op->downcall.trailer_buf);
471 goto Efault;466 goto Efault;
include/linux/skbuff.h+3−3
@@ -2809,12 +2809,12 @@ static inline int skb_add_data(struct sk_buff *skb, · 2808 unmodified lines
2809 2809
2810 if (skb->ip_summed == CHECKSUM_NONE) {2810 if (skb->ip_summed == CHECKSUM_NONE) {
2811 __wsum csum = 0;2811 __wsum csum = 0;
2812 if (csum_and_copy_from_iter(skb_put(skb, copy), copy,2812 if (csum_and_copy_from_iter_full(skb_put(skb, copy), copy,
2813 &csum, from) == copy) {2813 &csum, from)) {
2814 skb->csum = csum_block_add(skb->csum, csum, off);2814 skb->csum = csum_block_add(skb->csum, csum, off);
2815 return 0;2815 return 0;
2816 }2816 }
2817 } else if (copy_from_iter(skb_put(skb, copy), copy, from) == copy)2817 } else if (copy_from_iter_full(skb_put(skb, copy), copy, from))
2818 return 0;2818 return 0;
2819 2819
2820 __skb_trim(skb, off);2820 __skb_trim(skb, off);
include/linux/uio.h+3−0
@@ -89,7 +89,9 @@ size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes, · 88 unmodified lines
89 struct iov_iter *i);89 struct iov_iter *i);
90size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i);90size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i);
91size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i);91size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i);
92bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i);
92size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i);93size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i);
94bool copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i);
93size_t iov_iter_zero(size_t bytes, struct iov_iter *);95size_t iov_iter_zero(size_t bytes, struct iov_iter *);
94unsigned long iov_iter_alignment(const struct iov_iter *i);96unsigned long iov_iter_alignment(const struct iov_iter *i);
95unsigned long iov_iter_gap_alignment(const struct iov_iter *i);97unsigned long iov_iter_gap_alignment(const struct iov_iter *i);
@@ -155,6 +157,7 @@ static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) · 59 unmodified lines
155}157}
156size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);158size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);
157size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);159size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);
160bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i);
158 161
159int import_iovec(int type, const struct iovec __user * uvector,162int import_iovec(int type, const struct iovec __user * uvector,
160 unsigned nr_segs, unsigned fast_segs,163 unsigned nr_segs, unsigned fast_segs,
include/net/sock.h+3−3
@@ -1783,13 +1783,13 @@ static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb, · 1782 unmodified lines
1783{1783{
1784 if (skb->ip_summed == CHECKSUM_NONE) {1784 if (skb->ip_summed == CHECKSUM_NONE) {
1785 __wsum csum = 0;1785 __wsum csum = 0;
1786 if (csum_and_copy_from_iter(to, copy, &csum, from) != copy)1786 if (!csum_and_copy_from_iter_full(to, copy, &csum, from))
1787 return -EFAULT;1787 return -EFAULT;
1788 skb->csum = csum_block_add(skb->csum, csum, offset);1788 skb->csum = csum_block_add(skb->csum, csum, offset);
1789 } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) {1789 } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) {
1790 if (copy_from_iter_nocache(to, copy, from) != copy)1790 if (!copy_from_iter_full_nocache(to, copy, from))
1791 return -EFAULT;1791 return -EFAULT;
1792 } else if (copy_from_iter(to, copy, from) != copy)1792 } else if (!copy_from_iter_full(to, copy, from))
1793 return -EFAULT;1793 return -EFAULT;
1794 1794
1795 return 0;1795 return 0;
include/net/udplite.h+1−1
@@ -20,7 +20,7 @@ static __inline__ int udplite_getfrag(void *from, char *to, int offset, · 19 unmodified lines
20 int len, int odd, struct sk_buff *skb)20 int len, int odd, struct sk_buff *skb)
21{21{
22 struct msghdr *msg = from;22 struct msghdr *msg = from;
23 return copy_from_iter(to, len, &msg->msg_iter) != len ? -EFAULT : 0;23 return copy_from_iter_full(to, len, &msg->msg_iter) ? 0 : -EFAULT;
24}24}
25 25
26/* Designate sk as UDP-Lite socket */26/* Designate sk as UDP-Lite socket */
kernel/printk/printk.c+1−1
@@ -748,7 +748,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) · 747 unmodified lines
748 return -ENOMEM;748 return -ENOMEM;
749 749
750 buf[len] = '\0';750 buf[len] = '\0';
751 if (copy_from_iter(buf, len, from) != len) {751 if (!copy_from_iter_full(buf, len, from)) {
752 kfree(buf);752 kfree(buf);
753 return -EFAULT;753 return -EFAULT;
754 }754 }
lib/iov_iter.c+96−2
@@ -568,6 +568,31 @@ size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i) · 567 unmodified lines
568}568}
569EXPORT_SYMBOL(copy_from_iter);569EXPORT_SYMBOL(copy_from_iter);
570 570
571bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
572{
573 char *to = addr;
574 if (unlikely(i->type & ITER_PIPE)) {
575 WARN_ON(1);
576 return false;
577 }
578 if (unlikely(i->count < bytes)) \
579 return false;
580
581 iterate_all_kinds(i, bytes, v, ({
582 if (__copy_from_user((to += v.iov_len) - v.iov_len,
583 v.iov_base, v.iov_len))
584 return false;
585 0;}),
586 memcpy_from_page((to += v.bv_len) - v.bv_len, v.bv_page,
587 v.bv_offset, v.bv_len),
588 memcpy((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len)
589 )
590
591 iov_iter_advance(i, bytes);
592 return true;
593}
594EXPORT_SYMBOL(copy_from_iter_full);
595
571size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i)596size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i)
572{597{
573 char *to = addr;598 char *to = addr;
@@ -587,6 +612,30 @@ size_t copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i) · 13 unmodified lines
587}612}
588EXPORT_SYMBOL(copy_from_iter_nocache);613EXPORT_SYMBOL(copy_from_iter_nocache);
589 614
615bool copy_from_iter_full_nocache(void *addr, size_t bytes, struct iov_iter *i)
616{
617 char *to = addr;
618 if (unlikely(i->type & ITER_PIPE)) {
619 WARN_ON(1);
620 return false;
621 }
622 if (unlikely(i->count < bytes)) \
623 return false;
624 iterate_all_kinds(i, bytes, v, ({
625 if (__copy_from_user_nocache((to += v.iov_len) - v.iov_len,
626 v.iov_base, v.iov_len))
627 return false;
628 0;}),
629 memcpy_from_page((to += v.bv_len) - v.bv_len, v.bv_page,
630 v.bv_offset, v.bv_len),
631 memcpy((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len)
632 )
633
634 iov_iter_advance(i, bytes);
635 return true;
636}
637EXPORT_SYMBOL(copy_from_iter_full_nocache);
638
590size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,639size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
591 struct iov_iter *i)640 struct iov_iter *i)
592{641{
@@ -1008,7 +1057,7 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, · 415 unmodified lines
1008 }1057 }
1009 iterate_and_advance(i, bytes, v, ({1058 iterate_and_advance(i, bytes, v, ({
1010 int err = 0;1059 int err = 0;
1011 next = csum_and_copy_from_user(v.iov_base, 1060 next = csum_and_copy_from_user(v.iov_base,
1012 (to += v.iov_len) - v.iov_len,1061 (to += v.iov_len) - v.iov_len,
1013 v.iov_len, 0, &err);1062 v.iov_len, 0, &err);
1014 if (!err) {1063 if (!err) {
@@ -1037,6 +1086,51 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, · 22 unmodified lines
1037}1086}
1038EXPORT_SYMBOL(csum_and_copy_from_iter);1087EXPORT_SYMBOL(csum_and_copy_from_iter);
1039 1088
1089bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
1090 struct iov_iter *i)
1091{
1092 char *to = addr;
1093 __wsum sum, next;
1094 size_t off = 0;
1095 sum = *csum;
1096 if (unlikely(i->type & ITER_PIPE)) {
1097 WARN_ON(1);
1098 return false;
1099 }
1100 if (unlikely(i->count < bytes))
1101 return false;
1102 iterate_all_kinds(i, bytes, v, ({
1103 int err = 0;
1104 next = csum_and_copy_from_user(v.iov_base,
1105 (to += v.iov_len) - v.iov_len,
1106 v.iov_len, 0, &err);
1107 if (err)
1108 return false;
1109 sum = csum_block_add(sum, next, off);
1110 off += v.iov_len;
1111 0;
1112 }), ({
1113 char *p = kmap_atomic(v.bv_page);
1114 next = csum_partial_copy_nocheck(p + v.bv_offset,
1115 (to += v.bv_len) - v.bv_len,
1116 v.bv_len, 0);
1117 kunmap_atomic(p);
1118 sum = csum_block_add(sum, next, off);
1119 off += v.bv_len;
1120 }),({
1121 next = csum_partial_copy_nocheck(v.iov_base,
1122 (to += v.iov_len) - v.iov_len,
1123 v.iov_len, 0);
1124 sum = csum_block_add(sum, next, off);
1125 off += v.iov_len;
1126 })
1127 )
1128 *csum = sum;
1129 iov_iter_advance(i, bytes);
1130 return true;
1131}
1132EXPORT_SYMBOL(csum_and_copy_from_iter_full);
1133
1040size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum,1134size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum,
1041 struct iov_iter *i)1135 struct iov_iter *i)
1042{1136{
@@ -1051,7 +1145,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, · 8 unmodified lines
1051 iterate_and_advance(i, bytes, v, ({1145 iterate_and_advance(i, bytes, v, ({
1052 int err = 0;1146 int err = 0;
1053 next = csum_and_copy_to_user((from += v.iov_len) - v.iov_len,1147 next = csum_and_copy_to_user((from += v.iov_len) - v.iov_len,
1054 v.iov_base, 1148 v.iov_base,
1055 v.iov_len, 0, &err);1149 v.iov_len, 0, &err);
1056 if (!err) {1150 if (!err) {
1057 sum = csum_block_add(sum, next, off);1151 sum = csum_block_add(sum, next, off);
net/atm/common.c+1−1
@@ -630,7 +630,7 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size) · 629 unmodified lines
630 goto out;630 goto out;
631 skb->dev = NULL; /* for paths shared with net_device interfaces */631 skb->dev = NULL; /* for paths shared with net_device interfaces */
632 ATM_SKB(skb)->atm_options = vcc->atm_options;632 ATM_SKB(skb)->atm_options = vcc->atm_options;
633 if (copy_from_iter(skb_put(skb, size), size, &m->msg_iter) != size) {633 if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) {
634 kfree_skb(skb);634 kfree_skb(skb);
635 error = -EFAULT;635 error = -EFAULT;
636 goto out;636 goto out;
net/bluetooth/l2cap_core.c+3−3
@@ -2127,7 +2127,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, · 2126 unmodified lines
2127 struct sk_buff **frag;2127 struct sk_buff **frag;
2128 int sent = 0;2128 int sent = 0;
2129 2129
2130 if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count)2130 if (!copy_from_iter_full(skb_put(skb, count), count, &msg->msg_iter))
2131 return -EFAULT;2131 return -EFAULT;
2132 2132
2133 sent += count;2133 sent += count;
@@ -2147,8 +2147,8 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, · 13 unmodified lines
2147 2147
2148 *frag = tmp;2148 *frag = tmp;
2149 2149
2150 if (copy_from_iter(skb_put(*frag, count), count,2150 if (!copy_from_iter_full(skb_put(*frag, count), count,
2151 &msg->msg_iter) != count)2151 &msg->msg_iter))
2152 return -EFAULT;2152 return -EFAULT;
2153 2153
2154 sent += count;2154 sent += count;
net/ipv4/ip_output.c+2−2
@@ -802,11 +802,11 @@ ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk · 801 unmodified lines
802 struct msghdr *msg = from;802 struct msghdr *msg = from;
803 803
804 if (skb->ip_summed == CHECKSUM_PARTIAL) {804 if (skb->ip_summed == CHECKSUM_PARTIAL) {
805 if (copy_from_iter(to, len, &msg->msg_iter) != len)805 if (!copy_from_iter_full(to, len, &msg->msg_iter))
806 return -EFAULT;806 return -EFAULT;
807 } else {807 } else {
808 __wsum csum = 0;808 __wsum csum = 0;
809 if (csum_and_copy_from_iter(to, len, &csum, &msg->msg_iter) != len)809 if (!csum_and_copy_from_iter_full(to, len, &csum, &msg->msg_iter))
810 return -EFAULT;810 return -EFAULT;
811 skb->csum = csum_block_add(skb->csum, csum, odd);811 skb->csum = csum_block_add(skb->csum, csum, odd);
812 }812 }
net/ipv4/ping.c+4−4
@@ -609,15 +609,15 @@ int ping_getfrag(void *from, char *to, · 608 unmodified lines
609 fraglen -= sizeof(struct icmphdr);609 fraglen -= sizeof(struct icmphdr);
610 if (fraglen < 0)610 if (fraglen < 0)
611 BUG();611 BUG();
612 if (csum_and_copy_from_iter(to + sizeof(struct icmphdr),612 if (!csum_and_copy_from_iter_full(to + sizeof(struct icmphdr),
613 fraglen, &pfh->wcheck,613 fraglen, &pfh->wcheck,
614 &pfh->msg->msg_iter) != fraglen)614 &pfh->msg->msg_iter))
615 return -EFAULT;615 return -EFAULT;
616 } else if (offset < sizeof(struct icmphdr)) {616 } else if (offset < sizeof(struct icmphdr)) {
617 BUG();617 BUG();
618 } else {618 } else {
619 if (csum_and_copy_from_iter(to, fraglen, &pfh->wcheck,619 if (!csum_and_copy_from_iter_full(to, fraglen, &pfh->wcheck,
620 &pfh->msg->msg_iter) != fraglen)620 &pfh->msg->msg_iter))
621 return -EFAULT;621 return -EFAULT;
622 }622 }
623 623
net/packet/af_packet.c+1−4
@@ -2432,14 +2432,11 @@ static int __packet_snd_vnet_parse(struct virtio_net_hdr *vnet_hdr, size_t len) · 2431 unmodified lines
2432static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len,2432static int packet_snd_vnet_parse(struct msghdr *msg, size_t *len,
2433 struct virtio_net_hdr *vnet_hdr)2433 struct virtio_net_hdr *vnet_hdr)
2434{2434{
2435 int n;
2436
2437 if (*len < sizeof(*vnet_hdr))2435 if (*len < sizeof(*vnet_hdr))
2438 return -EINVAL;2436 return -EINVAL;
2439 *len -= sizeof(*vnet_hdr);2437 *len -= sizeof(*vnet_hdr);
2440 2438
2441 n = copy_from_iter(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter);2439 if (!copy_from_iter_full(vnet_hdr, sizeof(*vnet_hdr), &msg->msg_iter))
2442 if (n != sizeof(*vnet_hdr))
2443 return -EFAULT;2440 return -EFAULT;
2444 2441
2445 return __packet_snd_vnet_parse(vnet_hdr, *len);2442 return __packet_snd_vnet_parse(vnet_hdr, *len);
net/tipc/msg.c+2−2
@@ -268,7 +268,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, · 267 unmodified lines
268 __skb_queue_tail(list, skb);268 __skb_queue_tail(list, skb);
269 skb_copy_to_linear_data(skb, mhdr, mhsz);269 skb_copy_to_linear_data(skb, mhdr, mhsz);
270 pktpos = skb->data + mhsz;270 pktpos = skb->data + mhsz;
271 if (copy_from_iter(pktpos, dsz, &m->msg_iter) == dsz)271 if (copy_from_iter_full(pktpos, dsz, &m->msg_iter))
272 return dsz;272 return dsz;
273 rc = -EFAULT;273 rc = -EFAULT;
274 goto error;274 goto error;
@@ -299,7 +299,7 @@ int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, · 24 unmodified lines
299 if (drem < pktrem)299 if (drem < pktrem)
300 pktrem = drem;300 pktrem = drem;
301 301
302 if (copy_from_iter(pktpos, pktrem, &m->msg_iter) != pktrem) {302 if (!copy_from_iter_full(pktpos, pktrem, &m->msg_iter)) {
303 rc = -EFAULT;303 rc = -EFAULT;
304 goto error;304 goto error;
305 }305 }
security/keys/keyctl.c+1−1
@@ -1074,7 +1074,7 @@ long keyctl_instantiate_key_common(key_serial_t id, · 1073 unmodified lines
1074 }1074 }
1075 1075
1076 ret = -EFAULT;1076 ret = -EFAULT;
1077 if (copy_from_iter(payload, plen, from) != plen)1077 if (!copy_from_iter_full(payload, plen, from))
1078 goto error2;1078 goto error2;
1079 }1079 }
1080 1080

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t