jffs2: initialize datacrc for inode/dirent entries built from scan
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
@@ -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
Quoted 9 lines · Wagner Popov dos Santos
jffs2_1pass_build_lists()initializes inode and dirent list entries from raw node scanning, but leavesb->datacrcuninitialized in both paths.Later,
jffs2_1pass_read_inode()usesb->datacrcto decide whether to compute and validate the node data CRC, or to discard the entry asCRC_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