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

[JFFS2] Better fix for all-zero node headers

No need to check for all-zero header since the header cannot
be zero due to other checks.

Replace the all-zero header check in readinode.c with a
check for the magic word.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>

authored by

Joakim Tjernlund and committed by
David Woodhouse
0dec4c8b df8e96f3

+5 -15
+4 -4
fs/jffs2/readinode.c
··· 1054 1054 jffs2_mark_node_obsolete(c, ref); 1055 1055 goto cont; 1056 1056 } 1057 - /* Due to poor choice of crc32 seed, an all-zero node will have a correct CRC */ 1058 - if (!je32_to_cpu(node->u.hdr_crc) && !je16_to_cpu(node->u.nodetype) && 1059 - !je16_to_cpu(node->u.magic) && !je32_to_cpu(node->u.totlen)) { 1060 - JFFS2_NOTICE("All zero node header at %#08x.\n", ref_offset(ref)); 1057 + if (je16_to_cpu(node->u.magic) != JFFS2_MAGIC_BITMASK) { 1058 + /* Not a JFFS2 node, whinge and move on */ 1059 + JFFS2_NOTICE("Wrong magic bitmask 0x%04x in node header at %#08x.\n", 1060 + je16_to_cpu(node->u.magic), ref_offset(ref)); 1061 1061 jffs2_mark_node_obsolete(c, ref); 1062 1062 goto cont; 1063 1063 }
+1 -11
fs/jffs2/scan.c
··· 741 741 ofs += 4; 742 742 continue; 743 743 } 744 - /* Due to poor choice of crc32 seed, an all-zero node will have a correct CRC */ 745 - if (!je32_to_cpu(node->hdr_crc) && !je16_to_cpu(node->nodetype) && 746 - !je16_to_cpu(node->magic) && !je32_to_cpu(node->totlen)) { 747 - noisy_printk(&noise, "jffs2_scan_eraseblock(): All zero node header at 0x%08x.\n", ofs); 748 - if ((err = jffs2_scan_dirty_space(c, jeb, 4))) 749 - return err; 750 - ofs += 4; 751 - continue; 752 - } 753 744 754 - if (ofs + je32_to_cpu(node->totlen) > 755 - jeb->offset + c->sector_size) { 745 + if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { 756 746 /* Eep. Node goes over the end of the erase block. */ 757 747 printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", 758 748 ofs, je32_to_cpu(node->totlen));