[U-Boot] [PATCH] fsl: board EEPROM has the CRC in the wrong location
Wolfgang Denk
wd at denx.de
Mon Jul 16 21:57:06 CEST 2012
Dear Scott,
In message <5000AB43.6090406 at freescale.com> you wrote:
>
> > You are interpreting something which can be random data.
> >
> >> if (e.version == 0)
> >> crc_offset = 0x72;
> >>
> >> So here we're reading the 'version' field before we validate the data,
> >> because we need to check the version to know where the CRC is.
> >
> > Argh. More crap ...
>
> And how would you do it? You have to look at *something* first, and
> whatever that is could be a coincidence if you think people are going to
> stuff arbitrary data into the EEPROM.
If you cannot avoid using binary data structures you must make sure
the design allows extensions which do not break the design. This was
attempted here (CRC at fixed position 0xFC), which is supposed to be
"at the end" - unless the EEPROM size changes one day.
Accessing _any_ data fields in the binary structure must always be
done only _after_ the CRC has been verified. It makes zero sense to
try to interpret a version field without knowing if it is valid at
all.
Such code shows undefined behaviour. You may argument that the
likelyhood of a false match is small, but this doesn't matter: it's
still undefined behaviour.
With all the previous explanations already given (only very fewsystems
affected) it is best to remove all this crap, and provide a manual
recovery tool (to be run under close supervision of the user).
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The two most common things in the universe are hydrogen and stupi-
dity."
More information about the U-Boot
mailing list