JFFS2: unaligned accesses may happen in jffs2_sum_process_sum_data
Nick Krause
xerofoify at gmail.com
Mon Mar 16 10:23:44 PDT 2015
On Mon, Mar 16, 2015 at 3:00 AM, <wang.bo116 at zte.com.cn> wrote:
>
>
>
> Nicholas Krause <xerofoify at gmail.com> wrote on 2015-03-13 00:23:27:
>
>> From: Nicholas Krause <xerofoify at gmail.com>
>> To: wang.bo116 at zte.com.cn, linux-mtd at lists.infradead.org, dwmw2 at infradead.org,
>> Cc: cui.yunfeng at zte.com.cn, wang.haitao1 at zte.com.cn, liu.song11 at zte.com.cn, deng.chao1 at zte.com.cn
>> Date: 2015-03-13 00:23
>> Subject: Re: JFFS2: unaligned accesses may happen in jffs2_sum_process_sum_data
>>
>>
>>
>> On March 11, 2015 9:50:01 PM EDT, wang.bo116 at zte.com.cn wrote:
>> >
>> > 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
>> >that SUMMARY became incompatible!
>> >
>> >
>> >
>> >
>> >Are you stating that this is a build issue or causing a bug with hardware that needs this marco unaligned.
>> Nick
Wang,
>
>
> I think this may causing a bug with hardware that needs address aligned,and lose some efficiency.
>
Wang,
I looked into it and you may be right but I don't have flash to test
this on. The best way to find out is testing on a actual system that
requires hardware aligned flash
as this is hard for me to guess out. Other wise I would be able to
tell you off the bat to fix this.
Nick
More information about the linux-mtd
mailing list