Skip to content

Commit 787fec8

Browse files
committed
Merge tag 'for-linus-5.11-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 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
2 parents e13300b + b80a974 commit 787fec8

26 files changed

Lines changed: 203 additions & 149 deletions

drivers/mtd/ubi/build.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,8 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
629629
ubi->bad_peb_limit = get_bad_peb_limit(ubi, max_beb_per1024);
630630
}
631631

632-
if (ubi->mtd->type == MTD_NORFLASH) {
633-
ubi_assert(ubi->mtd->writesize == 1);
632+
if (ubi->mtd->type == MTD_NORFLASH)
634633
ubi->nor_flash = 1;
635-
}
636634

637635
ubi->min_io_size = ubi->mtd->writesize;
638636
ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
@@ -1352,8 +1350,6 @@ static int bytes_str_to_int(const char *str)
13521350
fallthrough;
13531351
case 'K':
13541352
result *= 1024;
1355-
if (endp[1] == 'i' && endp[2] == 'B')
1356-
endp += 2;
13571353
case '\0':
13581354
break;
13591355
default:

drivers/mtd/ubi/io.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,14 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)
535535
return -EROFS;
536536
}
537537

538-
if (ubi->nor_flash) {
538+
/*
539+
* If the flash is ECC-ed then we have to erase the ECC block before we
540+
* can write to it. But the write is in preparation to an erase in the
541+
* first place. This means we cannot zero out EC and VID before the
542+
* erase and we just have to hope the flash starts erasing from the
543+
* start of the page.
544+
*/
545+
if (ubi->nor_flash && ubi->mtd->writesize == 1) {
539546
err = nor_erase_prepare(ubi, pnum);
540547
if (err)
541548
return err;

fs/jffs2/debug.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef _JFFS2_DEBUG_H_
1414
#define _JFFS2_DEBUG_H_
1515

16+
#include <linux/printk.h>
1617
#include <linux/sched.h>
1718

1819
#ifndef CONFIG_JFFS2_FS_DEBUG
@@ -99,73 +100,73 @@ do { \
99100
#ifdef JFFS2_DBG_READINODE_MESSAGES
100101
#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
101102
#else
102-
#define dbg_readinode(fmt, ...)
103+
#define dbg_readinode(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
103104
#endif
104105
#ifdef JFFS2_DBG_READINODE2_MESSAGES
105106
#define dbg_readinode2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
106107
#else
107-
#define dbg_readinode2(fmt, ...)
108+
#define dbg_readinode2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
108109
#endif
109110

110111
/* Fragtree build debugging messages */
111112
#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
112113
#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
113114
#else
114-
#define dbg_fragtree(fmt, ...)
115+
#define dbg_fragtree(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
115116
#endif
116117
#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
117118
#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
118119
#else
119-
#define dbg_fragtree2(fmt, ...)
120+
#define dbg_fragtree2(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
120121
#endif
121122

122123
/* Directory entry list manilulation debugging messages */
123124
#ifdef JFFS2_DBG_DENTLIST_MESSAGES
124125
#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
125126
#else
126-
#define dbg_dentlist(fmt, ...)
127+
#define dbg_dentlist(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
127128
#endif
128129

129130
/* Print the messages about manipulating node_refs */
130131
#ifdef JFFS2_DBG_NODEREF_MESSAGES
131132
#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
132133
#else
133-
#define dbg_noderef(fmt, ...)
134+
#define dbg_noderef(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
134135
#endif
135136

136137
/* Manipulations with the list of inodes (JFFS2 inocache) */
137138
#ifdef JFFS2_DBG_INOCACHE_MESSAGES
138139
#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
139140
#else
140-
#define dbg_inocache(fmt, ...)
141+
#define dbg_inocache(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
141142
#endif
142143

143144
/* Summary debugging messages */
144145
#ifdef JFFS2_DBG_SUMMARY_MESSAGES
145146
#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
146147
#else
147-
#define dbg_summary(fmt, ...)
148+
#define dbg_summary(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
148149
#endif
149150

150151
/* File system build messages */
151152
#ifdef JFFS2_DBG_FSBUILD_MESSAGES
152153
#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
153154
#else
154-
#define dbg_fsbuild(fmt, ...)
155+
#define dbg_fsbuild(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
155156
#endif
156157

157158
/* Watch the object allocations */
158159
#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
159160
#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
160161
#else
161-
#define dbg_memalloc(fmt, ...)
162+
#define dbg_memalloc(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
162163
#endif
163164

164165
/* Watch the XATTR subsystem */
165166
#ifdef JFFS2_DBG_XATTR_MESSAGES
166167
#define dbg_xattr(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
167168
#else
168-
#define dbg_xattr(fmt, ...)
169+
#define dbg_xattr(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
169170
#endif
170171

171172
/* "Sanity" checks */

fs/jffs2/jffs2_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct jffs2_mount_opts {
3838
* users. This is implemented simply by means of not allowing the
3939
* latter users to write to the file system if the amount if the
4040
* available space is less then 'rp_size'. */
41+
bool set_rp_size;
4142
unsigned int rp_size;
4243
};
4344

fs/jffs2/nodelist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,14 @@ static inline struct jffs2_node_frag *frag_last(struct rb_root *root)
349349
#define frag_parent(frag) rb_entry(rb_parent(&(frag)->rb), struct jffs2_node_frag, rb)
350350
#define frag_left(frag) rb_entry((frag)->rb.rb_left, struct jffs2_node_frag, rb)
351351
#define frag_right(frag) rb_entry((frag)->rb.rb_right, struct jffs2_node_frag, rb)
352-
#define frag_erase(frag, list) rb_erase(&frag->rb, list);
352+
#define frag_erase(frag, list) rb_erase(&frag->rb, list)
353353

354354
#define tn_next(tn) rb_entry(rb_next(&(tn)->rb), struct jffs2_tmp_dnode_info, rb)
355355
#define tn_prev(tn) rb_entry(rb_prev(&(tn)->rb), struct jffs2_tmp_dnode_info, rb)
356356
#define tn_parent(tn) rb_entry(rb_parent(&(tn)->rb), struct jffs2_tmp_dnode_info, rb)
357357
#define tn_left(tn) rb_entry((tn)->rb.rb_left, struct jffs2_tmp_dnode_info, rb)
358358
#define tn_right(tn) rb_entry((tn)->rb.rb_right, struct jffs2_tmp_dnode_info, rb)
359-
#define tn_erase(tn, list) rb_erase(&tn->rb, list);
359+
#define tn_erase(tn, list) rb_erase(&tn->rb, list)
360360
#define tn_last(list) rb_entry(rb_last(list), struct jffs2_tmp_dnode_info, rb)
361361
#define tn_first(list) rb_entry(rb_first(list), struct jffs2_tmp_dnode_info, rb)
362362

fs/jffs2/readinode.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,22 @@ static inline int read_direntry(struct jffs2_sb_info *c, struct jffs2_raw_node_r
672672
jffs2_free_full_dirent(fd);
673673
return -EIO;
674674
}
675+
676+
#ifdef CONFIG_JFFS2_SUMMARY
677+
/*
678+
* we use CONFIG_JFFS2_SUMMARY because without it, we
679+
* have checked it while mounting
680+
*/
681+
crc = crc32(0, fd->name, rd->nsize);
682+
if (unlikely(crc != je32_to_cpu(rd->name_crc))) {
683+
JFFS2_NOTICE("name CRC failed on dirent node at"
684+
"%#08x: read %#08x,calculated %#08x\n",
685+
ref_offset(ref), je32_to_cpu(rd->node_crc), crc);
686+
jffs2_mark_node_obsolete(c, ref);
687+
jffs2_free_full_dirent(fd);
688+
return 0;
689+
}
690+
#endif
675691
}
676692

677693
fd->nhash = full_name_hash(NULL, fd->name, rd->nsize);

fs/jffs2/super.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static int jffs2_show_options(struct seq_file *s, struct dentry *root)
8888

8989
if (opts->override_compr)
9090
seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr));
91-
if (opts->rp_size)
91+
if (opts->set_rp_size)
9292
seq_printf(s, ",rp_size=%u", opts->rp_size / 1024);
9393

9494
return 0;
@@ -202,11 +202,8 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
202202
case Opt_rp_size:
203203
if (result.uint_32 > UINT_MAX / 1024)
204204
return invalf(fc, "jffs2: rp_size unrepresentable");
205-
opt = result.uint_32 * 1024;
206-
if (opt > c->mtd->size)
207-
return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
208-
c->mtd->size / 1024);
209-
c->mount_opts.rp_size = opt;
205+
c->mount_opts.rp_size = result.uint_32 * 1024;
206+
c->mount_opts.set_rp_size = true;
210207
break;
211208
default:
212209
return -EINVAL;
@@ -215,11 +212,30 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
215212
return 0;
216213
}
217214

215+
static inline void jffs2_update_mount_opts(struct fs_context *fc)
216+
{
217+
struct jffs2_sb_info *new_c = fc->s_fs_info;
218+
struct jffs2_sb_info *c = JFFS2_SB_INFO(fc->root->d_sb);
219+
220+
mutex_lock(&c->alloc_sem);
221+
if (new_c->mount_opts.override_compr) {
222+
c->mount_opts.override_compr = new_c->mount_opts.override_compr;
223+
c->mount_opts.compr = new_c->mount_opts.compr;
224+
}
225+
if (new_c->mount_opts.set_rp_size) {
226+
c->mount_opts.set_rp_size = new_c->mount_opts.set_rp_size;
227+
c->mount_opts.rp_size = new_c->mount_opts.rp_size;
228+
}
229+
mutex_unlock(&c->alloc_sem);
230+
}
231+
218232
static int jffs2_reconfigure(struct fs_context *fc)
219233
{
220234
struct super_block *sb = fc->root->d_sb;
221235

222236
sync_filesystem(sb);
237+
jffs2_update_mount_opts(fc);
238+
223239
return jffs2_do_remount_fs(sb, fc);
224240
}
225241

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

268+
if (c->mount_opts.rp_size > c->mtd->size)
269+
return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
270+
c->mtd->size / 1024);
271+
252272
/* Initialize JFFS2 superblock locks, the further initialization will
253273
* be done later */
254274
mutex_init(&c->alloc_sem);

fs/ubifs/auth.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ int ubifs_init_authentication(struct ubifs_info *c)
337337
c->authenticated = true;
338338

339339
c->log_hash = ubifs_hash_get_desc(c);
340-
if (IS_ERR(c->log_hash))
340+
if (IS_ERR(c->log_hash)) {
341+
err = PTR_ERR(c->log_hash);
341342
goto out_free_hmac;
343+
}
342344

343345
err = 0;
344346

fs/ubifs/commit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,13 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
701701

702702
out_dump:
703703
ubifs_err(c, "dumping index node (iip=%d)", i->iip);
704-
ubifs_dump_node(c, idx);
704+
ubifs_dump_node(c, idx, ubifs_idx_node_sz(c, c->fanout));
705705
list_del(&i->list);
706706
kfree(i);
707707
if (!list_empty(&list)) {
708708
i = list_entry(list.prev, struct idx_node, list);
709709
ubifs_err(c, "dumping parent index node");
710-
ubifs_dump_node(c, &i->idx);
710+
ubifs_dump_node(c, &i->idx, ubifs_idx_node_sz(c, c->fanout));
711711
}
712712
out_free:
713713
while (!list_empty(&list)) {

0 commit comments

Comments
 (0)