JFFS2: unaligned accesses may happen in jffs2_sum_process_sum_data

wang.bo116 at zte.com.cn wang.bo116 at zte.com.cn
Wed Mar 11 02:41:07 PDT 2015


	In JFFS2 summary, "#define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))",because of x here is dir's name, the result of JFFS2_SUMMARY_DIRENT_SIZE may be unaligned. So in function "jffs2_sum_process_sum_data", may access unaligned pointer "sp" when excute "switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype))".

	Some machine not allowed unaligned accesses, for example, in linux mips systerms, unaligned accesses may cause a exception,but luckly,in linux, function "handle_adel" can handle it well.But when JFFS2 use in other operating systerm, this unaligned accesses may be a problem.

	To fix it,the simple way is redefine JFFS2_SUMMARY_DIRENT_SIZE like "#define JFFS2_SUMMARY_DIRENT_SIZE(x) PAD((sizeof(struct jffs2_sum_dirent_flash) + (x)))",make it aligned.But the problem is SUMMARY became incompatible!






More information about the linux-mtd mailing list