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

Merge tag 'for-linus-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs

Pull JFFS2, UBI and UBIFS updates from Richard Weinberger:
"JFFS2:
- Fix for a corner case while mounting
- Fix for an use-after-free issue

UBI:
- Fix for a memory load while attaching
- Don't produce an anchor PEB with fastmap being disabled

UBIFS:
- Fix for orphan inode logic
- Spelling fixes
- New mount option to specify filesystem version"

* tag 'for-linus-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs:
jffs2: fix UAF problem
jffs2: fix jffs2 mounting failure
ubifs: Fix wrong orphan node deletion in ubifs_jnl_update|rename
ubi: fastmap: Free fastmap next anchor peb during detach
ubi: fastmap: Don't produce the initial next anchor PEB when fastmap is disabled
ubifs: misc.h: delete a duplicated word
ubifs: add option to specify version for new file systems

+43 -10
+5
drivers/mtd/ubi/fastmap-wl.c
··· 381 381 ubi->fm_anchor = NULL; 382 382 } 383 383 384 + if (ubi->fm_next_anchor) { 385 + return_unused_peb(ubi, ubi->fm_next_anchor); 386 + ubi->fm_next_anchor = NULL; 387 + } 388 + 384 389 if (ubi->fm) { 385 390 for (i = 0; i < ubi->fm->used_blocks; i++) 386 391 kfree(ubi->fm->e[i]);
+2 -1
drivers/mtd/ubi/wl.c
··· 1086 1086 if (!err) { 1087 1087 spin_lock(&ubi->wl_lock); 1088 1088 1089 - if (!ubi->fm_next_anchor && e->pnum < UBI_FM_MAX_START) { 1089 + if (!ubi->fm_disabled && !ubi->fm_next_anchor && 1090 + e->pnum < UBI_FM_MAX_START) { 1090 1091 /* Abort anchor production, if needed it will be 1091 1092 * enabled again in the wear leveling started below. 1092 1093 */
+5 -1
fs/jffs2/dir.c
··· 590 590 int ret; 591 591 uint32_t now = JFFS2_NOW(); 592 592 593 + mutex_lock(&f->sem); 593 594 for (fd = f->dents ; fd; fd = fd->next) { 594 - if (fd->ino) 595 + if (fd->ino) { 596 + mutex_unlock(&f->sem); 595 597 return -ENOTEMPTY; 598 + } 596 599 } 600 + mutex_unlock(&f->sem); 597 601 598 602 ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, 599 603 dentry->d_name.len, f, now);
+2 -1
fs/jffs2/scan.c
··· 261 261 } 262 262 #endif 263 263 if (c->nr_erasing_blocks) { 264 - if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { 264 + if (!c->used_size && !c->unchecked_size && 265 + ((c->nr_free_blocks+empty_blocks+bad_blocks) != c->nr_blocks || bad_blocks == c->nr_blocks)) { 265 266 pr_notice("Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); 266 267 pr_notice("empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n", 267 268 empty_blocks, bad_blocks, c->nr_blocks);
+6 -4
fs/ubifs/journal.c
··· 539 539 const struct fscrypt_name *nm, const struct inode *inode, 540 540 int deletion, int xent) 541 541 { 542 - int err, dlen, ilen, len, lnum, ino_offs, dent_offs; 542 + int err, dlen, ilen, len, lnum, ino_offs, dent_offs, orphan_added = 0; 543 543 int aligned_dlen, aligned_ilen, sync = IS_DIRSYNC(dir); 544 544 int last_reference = !!(deletion && inode->i_nlink == 0); 545 545 struct ubifs_inode *ui = ubifs_inode(inode); ··· 630 630 goto out_finish; 631 631 } 632 632 ui->del_cmtno = c->cmt_no; 633 + orphan_added = 1; 633 634 } 634 635 635 636 err = write_head(c, BASEHD, dent, len, &lnum, &dent_offs, sync); ··· 703 702 kfree(dent); 704 703 out_ro: 705 704 ubifs_ro_mode(c, err); 706 - if (last_reference) 705 + if (orphan_added) 707 706 ubifs_delete_orphan(c, inode->i_ino); 708 707 finish_reservation(c); 709 708 return err; ··· 1219 1218 void *p; 1220 1219 union ubifs_key key; 1221 1220 struct ubifs_dent_node *dent, *dent2; 1222 - int err, dlen1, dlen2, ilen, lnum, offs, len; 1221 + int err, dlen1, dlen2, ilen, lnum, offs, len, orphan_added = 0; 1223 1222 int aligned_dlen1, aligned_dlen2, plen = UBIFS_INO_NODE_SZ; 1224 1223 int last_reference = !!(new_inode && new_inode->i_nlink == 0); 1225 1224 int move = (old_dir != new_dir); ··· 1335 1334 goto out_finish; 1336 1335 } 1337 1336 new_ui->del_cmtno = c->cmt_no; 1337 + orphan_added = 1; 1338 1338 } 1339 1339 1340 1340 err = write_head(c, BASEHD, dent, len, &lnum, &offs, sync); ··· 1417 1415 release_head(c, BASEHD); 1418 1416 out_ro: 1419 1417 ubifs_ro_mode(c, err); 1420 - if (last_reference) 1418 + if (orphan_added) 1421 1419 ubifs_delete_orphan(c, new_inode->i_ino); 1422 1420 out_finish: 1423 1421 finish_reservation(c);
+1 -1
fs/ubifs/misc.h
··· 121 121 * ubifs_wbuf_sync - synchronize write-buffer. 122 122 * @wbuf: write-buffer to synchronize 123 123 * 124 - * This is the same as as 'ubifs_wbuf_sync_nolock()' but it does not assume 124 + * This is the same as 'ubifs_wbuf_sync_nolock()' but it does not assume 125 125 * that the write-buffer is already locked. 126 126 */ 127 127 static inline int ubifs_wbuf_sync(struct ubifs_wbuf *wbuf)
+3 -2
fs/ubifs/sb.c
··· 174 174 tmp64 = (long long)max_buds * c->leb_size; 175 175 if (big_lpt) 176 176 sup_flags |= UBIFS_FLG_BIGLPT; 177 - sup_flags |= UBIFS_FLG_DOUBLE_HASH; 177 + if (ubifs_default_version > 4) 178 + sup_flags |= UBIFS_FLG_DOUBLE_HASH; 178 179 179 180 if (ubifs_authenticated(c)) { 180 181 sup_flags |= UBIFS_FLG_AUTHENTICATION; ··· 201 200 sup->jhead_cnt = cpu_to_le32(DEFAULT_JHEADS_CNT); 202 201 sup->fanout = cpu_to_le32(DEFAULT_FANOUT); 203 202 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt); 204 - sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION); 203 + sup->fmt_version = cpu_to_le32(ubifs_default_version); 205 204 sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN); 206 205 if (c->mount_opts.override_compr) 207 206 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
+18
fs/ubifs/super.c
··· 26 26 #include <linux/writeback.h> 27 27 #include "ubifs.h" 28 28 29 + static int ubifs_default_version_set(const char *val, const struct kernel_param *kp) 30 + { 31 + int n = 0, ret; 32 + 33 + ret = kstrtoint(val, 10, &n); 34 + if (ret != 0 || n < 4 || n > UBIFS_FORMAT_VERSION) 35 + return -EINVAL; 36 + return param_set_int(val, kp); 37 + } 38 + 39 + static const struct kernel_param_ops ubifs_default_version_ops = { 40 + .set = ubifs_default_version_set, 41 + .get = param_get_int, 42 + }; 43 + 44 + int ubifs_default_version = UBIFS_FORMAT_VERSION; 45 + module_param_cb(default_version, &ubifs_default_version_ops, &ubifs_default_version, 0600); 46 + 29 47 /* 30 48 * Maximum amount of memory we may 'kmalloc()' without worrying that we are 31 49 * allocating too much.
+1
fs/ubifs/ubifs.h
··· 1504 1504 extern const struct inode_operations ubifs_dir_inode_operations; 1505 1505 extern const struct inode_operations ubifs_symlink_inode_operations; 1506 1506 extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; 1507 + extern int ubifs_default_version; 1507 1508 1508 1509 /* auth.c */ 1509 1510 static inline int ubifs_authenticated(const struct ubifs_info *c)