Skip to contentSkip to conversation

jffs2: initialize datacrc for inode/dirent entries built from scan

PATCH In review Wagner Popov dos Santos 2 participants 2 messages Aug 26 – Sep 14 Journalling flash file system V2 (JFFS2)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jffs2: initialize datacrc for inode/dirent entries built from scan

jffs2_1pass_build_lists() initializes inode and dirent list entries from raw node scanning, but leaves b->datacrc uninitialized in both paths.

Later, jffs2_1pass_read_inode() uses b->datacrc to decide whether to compute and validate the node data CRC, or to discard the entry as CRC_BAD. With an undefined value, behavior is non-deterministic:
entries may be incorrectly dropped or CRC verification may be skipped.

Initialize b->datacrc to CRC_UNKNOWN for inode and dirent entries created in jffs2_1pass_build_lists(), matching the summary-based path behavior.

---
 fs/jffs2/jffs2_1pass.c | 2 ++
 1 file changed, 2 insertions(+)
fs/jffs2/jffs2_1pass.c +2 -0
index 137a9585b0b..eb0554f466f 100644
@@ -1726,6 +1726,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 				b->offset = (u32)part->offset + ofs;
 				b->version = node->i.version;
 				b->ino = node->i.ino;
+				b->datacrc = CRC_UNKNOWN;
 				if (max_totlen < node->u.totlen)
 					max_totlen = node->u.totlen;
 				break;
@@ -1764,6 +1765,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 				b->offset = (u32)part->offset + ofs;
 				b->version = node->d.version;
 				b->pino = node->d.pino;
+				b->datacrc = CRC_UNKNOWN;
 				if (max_totlen < node->u.totlen)
 					max_totlen = node->u.totlen;
 				counterN++;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Wagner Popov dos Santos

jffs2_1pass_build_lists() initializes inode and dirent list entries from raw node scanning, but leaves b->datacrc uninitialized in both paths.

Later, jffs2_1pass_read_inode() uses b->datacrc to decide whether to compute and validate the node data CRC, or to discard the entry as CRC_BAD. With an undefined value, behavior is non-deterministic:
entries may be incorrectly dropped or CRC verification may be skipped.

[...]

Applied to u-boot/next, thanks!

[1/1] jffs2: initialize datacrc for inode/dirent entries built from scan

      commit: 7ac3028f4796114786909f486c5d276937b793dd
Signature · 1 line
Tom