Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull VFS fixes from Al Viro:
"A bunch of assorted fixes, most of them followups to overlayfs merge"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
ovl: initialize ->is_cursor
Return short read or 0 at end of a raw device, not EIO
isofs: don't bother with ->d_op for normal case
isofs_cmp(): we'll never see a dentry for . or ..
overlayfs: fix lockdep misannotation
ovl: fix check for cursor
overlayfs: barriers for opening upper-layer directory
rcu: Provide counterpart to rcu_dereference() for non-RCU situations
staging: android: logger: Fix log corruption regression

+50 -58
+1 -1
drivers/char/raw.c
··· 285 285 286 286 static const struct file_operations raw_fops = { 287 287 .read = new_sync_read, 288 - .read_iter = generic_file_read_iter, 288 + .read_iter = blkdev_read_iter, 289 289 .write = new_sync_write, 290 290 .write_iter = blkdev_write_iter, 291 291 .fsync = blkdev_fsync,
+8 -5
drivers/staging/android/logger.c
··· 420 420 struct logger_log *log = file_get_log(iocb->ki_filp); 421 421 struct logger_entry header; 422 422 struct timespec now; 423 - size_t len, count; 423 + size_t len, count, w_off; 424 424 425 425 count = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD); 426 426 ··· 452 452 memcpy(log->buffer + log->w_off, &header, len); 453 453 memcpy(log->buffer, (char *)&header + len, sizeof(header) - len); 454 454 455 - len = min(count, log->size - log->w_off); 455 + /* Work with a copy until we are ready to commit the whole entry */ 456 + w_off = logger_offset(log, log->w_off + sizeof(struct logger_entry)); 456 457 457 - if (copy_from_iter(log->buffer + log->w_off, len, from) != len) { 458 + len = min(count, log->size - w_off); 459 + 460 + if (copy_from_iter(log->buffer + w_off, len, from) != len) { 458 461 /* 459 - * Note that by not updating w_off, this abandons the 462 + * Note that by not updating log->w_off, this abandons the 460 463 * portion of the new entry that *was* successfully 461 464 * copied, just above. This is intentional to avoid 462 465 * message corruption from missing fragments. ··· 473 470 return -EFAULT; 474 471 } 475 472 476 - log->w_off = logger_offset(log, log->w_off + count); 473 + log->w_off = logger_offset(log, w_off + count); 477 474 mutex_unlock(&log->mutex); 478 475 479 476 /* wake up any blocked readers */
+2 -1
fs/block_dev.c
··· 1585 1585 } 1586 1586 EXPORT_SYMBOL_GPL(blkdev_write_iter); 1587 1587 1588 - static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) 1588 + ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) 1589 1589 { 1590 1590 struct file *file = iocb->ki_filp; 1591 1591 struct inode *bd_inode = file->f_mapping->host; ··· 1599 1599 iov_iter_truncate(to, size); 1600 1600 return generic_file_read_iter(iocb, to); 1601 1601 } 1602 + EXPORT_SYMBOL_GPL(blkdev_read_iter); 1602 1603 1603 1604 /* 1604 1605 * Try to release a page associated with block device when the system
+2 -22
fs/isofs/inode.c
··· 29 29 #define BEQUIET 30 30 31 31 static int isofs_hashi(const struct dentry *parent, struct qstr *qstr); 32 - static int isofs_hash(const struct dentry *parent, struct qstr *qstr); 33 32 static int isofs_dentry_cmpi(const struct dentry *parent, 34 - const struct dentry *dentry, 35 - unsigned int len, const char *str, const struct qstr *name); 36 - static int isofs_dentry_cmp(const struct dentry *parent, 37 33 const struct dentry *dentry, 38 34 unsigned int len, const char *str, const struct qstr *name); 39 35 ··· 130 134 131 135 132 136 static const struct dentry_operations isofs_dentry_ops[] = { 133 - { 134 - .d_hash = isofs_hash, 135 - .d_compare = isofs_dentry_cmp, 136 - }, 137 137 { 138 138 .d_hash = isofs_hashi, 139 139 .d_compare = isofs_dentry_cmpi, ··· 250 258 } 251 259 252 260 static int 253 - isofs_hash(const struct dentry *dentry, struct qstr *qstr) 254 - { 255 - return isofs_hash_common(qstr, 0); 256 - } 257 - 258 - static int 259 261 isofs_hashi(const struct dentry *dentry, struct qstr *qstr) 260 262 { 261 263 return isofs_hashi_common(qstr, 0); 262 - } 263 - 264 - static int 265 - isofs_dentry_cmp(const struct dentry *parent, const struct dentry *dentry, 266 - unsigned int len, const char *str, const struct qstr *name) 267 - { 268 - return isofs_dentry_cmp_common(len, str, name, 0, 0); 269 264 } 270 265 271 266 static int ··· 909 930 if (opt.check == 'r') 910 931 table++; 911 932 912 - s->s_d_op = &isofs_dentry_ops[table]; 933 + if (table) 934 + s->s_d_op = &isofs_dentry_ops[table - 1]; 913 935 914 936 /* get the root dentry */ 915 937 s->s_root = d_make_root(inode);
+4 -18
fs/isofs/namei.c
··· 18 18 isofs_cmp(struct dentry *dentry, const char *compare, int dlen) 19 19 { 20 20 struct qstr qstr; 21 - 22 - if (!compare) 23 - return 1; 24 - 25 - /* check special "." and ".." files */ 26 - if (dlen == 1) { 27 - /* "." */ 28 - if (compare[0] == 0) { 29 - if (!dentry->d_name.len) 30 - return 0; 31 - compare = "."; 32 - } else if (compare[0] == 1) { 33 - compare = ".."; 34 - dlen = 2; 35 - } 36 - } 37 - 38 21 qstr.name = compare; 39 22 qstr.len = dlen; 23 + if (likely(!dentry->d_op)) 24 + return dentry->d_name.len != dlen || memcmp(dentry->d_name.name, compare, dlen); 40 25 return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr); 41 26 } 42 27 ··· 131 146 (!(de->flags[-sbi->s_high_sierra] & 1))) && 132 147 (sbi->s_showassoc || 133 148 (!(de->flags[-sbi->s_high_sierra] & 4)))) { 134 - match = (isofs_cmp(dentry, dpnt, dlen) == 0); 149 + if (dpnt && (dlen > 1 || dpnt[0] > 1)) 150 + match = (isofs_cmp(dentry, dpnt, dlen) == 0); 135 151 } 136 152 if (match) { 137 153 isofs_normalize_block_and_offset(de,
+1 -1
fs/namei.c
··· 2497 2497 } 2498 2498 2499 2499 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); 2500 - mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); 2500 + mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT2); 2501 2501 return NULL; 2502 2502 } 2503 2503 EXPORT_SYMBOL(lock_rename);
+10 -7
fs/overlayfs/readdir.c
··· 21 21 unsigned int len; 22 22 unsigned int type; 23 23 u64 ino; 24 - bool is_whiteout; 25 24 struct list_head l_node; 26 25 struct rb_node node; 26 + bool is_whiteout; 27 + bool is_cursor; 27 28 char name[]; 28 29 }; 29 30 ··· 93 92 p->type = d_type; 94 93 p->ino = ino; 95 94 p->is_whiteout = false; 95 + p->is_cursor = false; 96 96 } 97 97 98 98 return p; ··· 253 251 254 252 mutex_lock(&dir->d_inode->i_mutex); 255 253 list_for_each_entry(p, rdd->list, l_node) { 256 - if (!p->name) 254 + if (p->is_cursor) 257 255 continue; 258 256 259 257 if (p->type != DT_CHR) ··· 309 307 } 310 308 out: 311 309 return err; 312 - 313 310 } 314 311 315 312 static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos) ··· 317 316 loff_t off = 0; 318 317 319 318 list_for_each_entry(p, &od->cache->entries, l_node) { 320 - if (!p->name) 319 + if (p->is_cursor) 321 320 continue; 322 321 if (off >= pos) 323 322 break; ··· 390 389 391 390 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node); 392 391 /* Skip cursors */ 393 - if (p->name) { 392 + if (!p->is_cursor) { 394 393 if (!p->is_whiteout) { 395 394 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type)) 396 395 break; ··· 455 454 if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) { 456 455 struct inode *inode = file_inode(file); 457 456 458 - realfile = od->upperfile; 457 + realfile =lockless_dereference(od->upperfile); 459 458 if (!realfile) { 460 459 struct path upperpath; 461 460 462 461 ovl_path_upper(dentry, &upperpath); 463 462 realfile = ovl_path_open(&upperpath, O_RDONLY); 463 + smp_mb__before_spinlock(); 464 464 mutex_lock(&inode->i_mutex); 465 465 if (!od->upperfile) { 466 466 if (IS_ERR(realfile)) { ··· 520 518 od->realfile = realfile; 521 519 od->is_real = (type != OVL_PATH_MERGE); 522 520 od->is_upper = (type != OVL_PATH_LOWER); 521 + od->cursor.is_cursor = true; 523 522 file->private_data = od; 524 523 525 524 return 0; ··· 572 569 { 573 570 struct ovl_cache_entry *p; 574 571 575 - mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_PARENT); 572 + mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_CHILD); 576 573 list_for_each_entry(p, list, l_node) { 577 574 struct dentry *dentry; 578 575
+7 -3
include/linux/fs.h
··· 639 639 * 2: child/target 640 640 * 3: xattr 641 641 * 4: second non-directory 642 - * The last is for certain operations (such as rename) which lock two 642 + * 5: second parent (when locking independent directories in rename) 643 + * 644 + * I_MUTEX_NONDIR2 is for certain operations (such as rename) which lock two 643 645 * non-directories at once. 644 646 * 645 647 * The locking order between these classes is 646 - * parent -> child -> normal -> xattr -> second non-directory 648 + * parent[2] -> child -> grandchild -> normal -> xattr -> second non-directory 647 649 */ 648 650 enum inode_i_mutex_lock_class 649 651 { ··· 653 651 I_MUTEX_PARENT, 654 652 I_MUTEX_CHILD, 655 653 I_MUTEX_XATTR, 656 - I_MUTEX_NONDIR2 654 + I_MUTEX_NONDIR2, 655 + I_MUTEX_PARENT2, 657 656 }; 658 657 659 658 void lock_two_nondirectories(struct inode *, struct inode*); ··· 2469 2466 extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); 2470 2467 2471 2468 /* fs/block_dev.c */ 2469 + extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to); 2472 2470 extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); 2473 2471 extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2474 2472 int datasync);
+15
include/linux/rcupdate.h
··· 617 617 #define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v) 618 618 619 619 /** 620 + * lockless_dereference() - safely load a pointer for later dereference 621 + * @p: The pointer to load 622 + * 623 + * Similar to rcu_dereference(), but for situations where the pointed-to 624 + * object's lifetime is managed by something other than RCU. That 625 + * "something other" might be reference counting or simple immortality. 626 + */ 627 + #define lockless_dereference(p) \ 628 + ({ \ 629 + typeof(p) _________p1 = ACCESS_ONCE(p); \ 630 + smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ 631 + (_________p1); \ 632 + }) 633 + 634 + /** 620 635 * rcu_assign_pointer() - assign to RCU-protected pointer 621 636 * @p: pointer to assign to 622 637 * @v: value to assign (publish)