Skip to content

Commit

Permalink
Merge tag 'for-linus-5.11-rc1' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/rw/ubifs

Pull jffs2, ubi and ubifs updates from Richard Weinberger:
 "JFFS2:
   - Fix for a remount regression
   - Fix for an abnormal GC exit
   - Fix for a possible NULL pointer issue while mounting

  UBI:
   - Add support ECC-ed NOR flash
   - Removal of dead code

  UBIFS:
   - Make node dumping debug code more reliable
   - Various cleanups: less ifdefs, less typos
   - Fix for an info leak"

* tag 'for-linus-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs:
  ubifs: ubifs_dump_node: Dump all branches of the index node
  ubifs: ubifs_dump_sleb: Remove unused function
  ubifs: Pass node length in all node dumping callers
  Revert "ubifs: Fix out-of-bounds memory access caused by abnormal value of node_len"
  ubifs: Limit dumping length by size of memory which is allocated for the node
  ubifs: Remove the redundant return in dbg_check_nondata_nodes_order
  jffs2: Fix NULL pointer dereference in rp_size fs option parsing
  ubifs: Fixed print foramt mismatch in ubifs
  ubi: Do not zero out EC and VID on ECC-ed NOR flashes
  jffs2: remove trailing semicolon in macro definition
  ubifs: Fix error return code in ubifs_init_authentication()
  ubifs: wbuf: Don't leak kernel memory to flash
  ubi: Remove useless code in bytes_str_to_int
  ubifs: Fix the printing type of c->big_lpt
  jffs2: Allow setting rp_size to zero during remounting
  jffs2: Fix ignoring mounting options problem during remounting
  jffs2: Fix GC exit abnormally
  ubifs: Code cleanup by removing ifdef macro surrounding
  jffs2: Fix if/else empty body warnings
  ubifs: Delete duplicated words + other fixes
  • Loading branch information
torvalds committed Dec 18, 2020
2 parents e13300b + b80a974 commit 787fec8
Show file tree
Hide file tree
Showing 26 changed files with 203 additions and 149 deletions.
6 changes: 1 addition & 5 deletions drivers/mtd/ubi/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,8 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
ubi->bad_peb_limit = get_bad_peb_limit(ubi, max_beb_per1024);
}

if (ubi->mtd->type == MTD_NORFLASH) {
ubi_assert(ubi->mtd->writesize == 1);
if (ubi->mtd->type == MTD_NORFLASH)
ubi->nor_flash = 1;
}

ubi->min_io_size = ubi->mtd->writesize;
ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
Expand Down Expand Up @@ -1352,8 +1350,6 @@ static int bytes_str_to_int(const char *str)
fallthrough;
case 'K':
result *= 1024;
if (endp[1] == 'i' && endp[2] == 'B')
endp += 2;
case '\0':
break;
default:
Expand Down
9 changes: 8 additions & 1 deletion drivers/mtd/ubi/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,14 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)
return -EROFS;
}

if (ubi->nor_flash) {
/*
* If the flash is ECC-ed then we have to erase the ECC block before we
* can write to it. But the write is in preparation to an erase in the
* first place. This means we cannot zero out EC and VID before the
* erase and we just have to hope the flash starts erasing from the
* start of the page.
*/
if (ubi->nor_flash && ubi->mtd->writesize == 1) {
err = nor_erase_prepare(ubi, pnum);
if (err)
return err;
Expand Down
23 changes: 12 additions & 11 deletions fs/jffs2/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef _JFFS2_DEBUG_H_
#define _JFFS2_DEBUG_H_

#include <linux/printk.h>
#include <linux/sched.h>

#ifndef CONFIG_JFFS2_FS_DEBUG
Expand Down Expand Up @@ -99,73 +100,73 @@ do { \
#ifdef JFFS2_DBG_READINODE_MESSAGES
#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_readinode(fmt, ...)
#define dbg_readinode(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif
#ifdef JFFS2_DBG_READINODE2_MESSAGES
#define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_readinode2(fmt, ...)
#define dbg_readinode2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* Fragtree build debugging messages */
#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_fragtree(fmt, ...)
#define dbg_fragtree(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif
#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_fragtree2(fmt, ...)
#define dbg_fragtree2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* Directory entry list manilulation debugging messages */
#ifdef JFFS2_DBG_DENTLIST_MESSAGES
#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_dentlist(fmt, ...)
#define dbg_dentlist(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* Print the messages about manipulating node_refs */
#ifdef JFFS2_DBG_NODEREF_MESSAGES
#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_noderef(fmt, ...)
#define dbg_noderef(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* Manipulations with the list of inodes (JFFS2 inocache) */
#ifdef JFFS2_DBG_INOCACHE_MESSAGES
#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_inocache(fmt, ...)
#define dbg_inocache(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* Summary debugging messages */
#ifdef JFFS2_DBG_SUMMARY_MESSAGES
#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_summary(fmt, ...)
#define dbg_summary(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* File system build messages */
#ifdef JFFS2_DBG_FSBUILD_MESSAGES
#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_fsbuild(fmt, ...)
#define dbg_fsbuild(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* Watch the object allocations */
#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_memalloc(fmt, ...)
#define dbg_memalloc(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* Watch the XATTR subsystem */
#ifdef JFFS2_DBG_XATTR_MESSAGES
#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
#else
#define dbg_xattr(fmt, ...)
#define dbg_xattr(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif

/* "Sanity" checks */
Expand Down
1 change: 1 addition & 0 deletions fs/jffs2/jffs2_fs_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct jffs2_mount_opts {
* users. This is implemented simply by means of not allowing the
* latter users to write to the file system if the amount if the
* available space is less then 'rp_size'. */
bool set_rp_size;
unsigned int rp_size;
};

Expand Down
4 changes: 2 additions & 2 deletions fs/jffs2/nodelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,14 @@ static inline struct jffs2_node_frag *frag_last(struct rb_root *root)
#define frag_parent(frag) rb_entry(rb_parent(&(frag)->rb), struct jffs2_node_frag, rb)
#define frag_left(frag) rb_entry((frag)->rb.rb_left, struct jffs2_node_frag, rb)
#define frag_right(frag) rb_entry((frag)->rb.rb_right, struct jffs2_node_frag, rb)
#define frag_erase(frag, list) rb_erase(&frag->rb, list);
#define frag_erase(frag, list) rb_erase(&frag->rb, list)

#define tn_next(tn) rb_entry(rb_next(&(tn)->rb), struct jffs2_tmp_dnode_info, rb)
#define tn_prev(tn) rb_entry(rb_prev(&(tn)->rb), struct jffs2_tmp_dnode_info, rb)
#define tn_parent(tn) rb_entry(rb_parent(&(tn)->rb), struct jffs2_tmp_dnode_info, rb)
#define tn_left(tn) rb_entry((tn)->rb.rb_left, struct jffs2_tmp_dnode_info, rb)
#define tn_right(tn) rb_entry((tn)->rb.rb_right, struct jffs2_tmp_dnode_info, rb)
#define tn_erase(tn, list) rb_erase(&tn->rb, list);
#define tn_erase(tn, list) rb_erase(&tn->rb, list)
#define tn_last(list) rb_entry(rb_last(list), struct jffs2_tmp_dnode_info, rb)
#define tn_first(list) rb_entry(rb_first(list), struct jffs2_tmp_dnode_info, rb)

Expand Down
16 changes: 16 additions & 0 deletions fs/jffs2/readinode.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,22 @@ static inline int read_direntry(struct jffs2_sb_info *c, struct jffs2_raw_node_r
jffs2_free_full_dirent(fd);
return -EIO;
}

#ifdef CONFIG_JFFS2_SUMMARY
/*
* we use CONFIG_JFFS2_SUMMARY because without it, we
* have checked it while mounting
*/
crc = crc32(0, fd->name, rd->nsize);
if (unlikely(crc != je32_to_cpu(rd->name_crc))) {
JFFS2_NOTICE("name CRC failed on dirent node at"
"%#08x: read %#08x,calculated %#08x\n",
ref_offset(ref), je32_to_cpu(rd->node_crc), crc);
jffs2_mark_node_obsolete(c, ref);
jffs2_free_full_dirent(fd);
return 0;
}
#endif
}

fd->nhash = full_name_hash(NULL, fd->name, rd->nsize);
Expand Down
32 changes: 26 additions & 6 deletions fs/jffs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static int jffs2_show_options(struct seq_file *s, struct dentry *root)

if (opts->override_compr)
seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr));
if (opts->rp_size)
if (opts->set_rp_size)
seq_printf(s, ",rp_size=%u", opts->rp_size / 1024);

return 0;
Expand Down Expand Up @@ -202,11 +202,8 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
case Opt_rp_size:
if (result.uint_32 > UINT_MAX / 1024)
return invalf(fc, "jffs2: rp_size unrepresentable");
opt = result.uint_32 * 1024;
if (opt > c->mtd->size)
return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
c->mtd->size / 1024);
c->mount_opts.rp_size = opt;
c->mount_opts.rp_size = result.uint_32 * 1024;
c->mount_opts.set_rp_size = true;
break;
default:
return -EINVAL;
Expand All @@ -215,11 +212,30 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
return 0;
}

static inline void jffs2_update_mount_opts(struct fs_context *fc)
{
struct jffs2_sb_info *new_c = fc->s_fs_info;
struct jffs2_sb_info *c = JFFS2_SB_INFO(fc->root->d_sb);

mutex_lock(&c->alloc_sem);
if (new_c->mount_opts.override_compr) {
c->mount_opts.override_compr = new_c->mount_opts.override_compr;
c->mount_opts.compr = new_c->mount_opts.compr;
}
if (new_c->mount_opts.set_rp_size) {
c->mount_opts.set_rp_size = new_c->mount_opts.set_rp_size;
c->mount_opts.rp_size = new_c->mount_opts.rp_size;
}
mutex_unlock(&c->alloc_sem);
}

static int jffs2_reconfigure(struct fs_context *fc)
{
struct super_block *sb = fc->root->d_sb;

sync_filesystem(sb);
jffs2_update_mount_opts(fc);

return jffs2_do_remount_fs(sb, fc);
}

Expand Down Expand Up @@ -249,6 +265,10 @@ static int jffs2_fill_super(struct super_block *sb, struct fs_context *fc)
c->mtd = sb->s_mtd;
c->os_priv = sb;

if (c->mount_opts.rp_size > c->mtd->size)
return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
c->mtd->size / 1024);

/* Initialize JFFS2 superblock locks, the further initialization will
* be done later */
mutex_init(&c->alloc_sem);
Expand Down
4 changes: 3 additions & 1 deletion fs/ubifs/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,10 @@ int ubifs_init_authentication(struct ubifs_info *c)
c->authenticated = true;

c->log_hash = ubifs_hash_get_desc(c);
if (IS_ERR(c->log_hash))
if (IS_ERR(c->log_hash)) {
err = PTR_ERR(c->log_hash);
goto out_free_hmac;
}

err = 0;

Expand Down
4 changes: 2 additions & 2 deletions fs/ubifs/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,13 +701,13 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)

out_dump:
ubifs_err(c, "dumping index node (iip=%d)", i->iip);
ubifs_dump_node(c, idx);
ubifs_dump_node(c, idx, ubifs_idx_node_sz(c, c->fanout));
list_del(&i->list);
kfree(i);
if (!list_empty(&list)) {
i = list_entry(list.prev, struct idx_node, list);
ubifs_err(c, "dumping parent index node");
ubifs_dump_node(c, &i->idx);
ubifs_dump_node(c, &i->idx, ubifs_idx_node_sz(c, c->fanout));
}
out_free:
while (!list_empty(&list)) {
Expand Down
Loading

0 comments on commit 787fec8

Please sign in to comment.