[U-Boot] [RFC][PATCH] Generate CRC of structure of Global Data for standalone apps
Wolfgang Denk
wd at denx.de
Sat Sep 3 14:13:19 CEST 2011
Dear Graeme Russ,
In message <1315048903-23217-1-git-send-email-graeme.russ at gmail.com> you wrote:
> There has been some discussion of late on the mailing list as to whether
> or not a change to the Global Data structure should trigger an increment
> to XF_VERSION. The issue is complicated by the fact that some arches have
> #ifdef's in the definition of the structure.
>
> This patch auto-generates a CRC32 checksum of the structure (as opposed to
> the contents) of the Global Data structure. Standalone applications can
> read U-Boot's CRC via the new exported get_gd_crc(). If the CRCs do not
> match, using Global Data in the standalone application would be very
> unwise.
>
> This method allows the global data structure to be modified without having
> to worry about whether existing standalone applications will suddenly fail
> with unexpected results when accessing global data - Of course, this will
> only work for standalone applications which actually use get_gd_crc() - By
> incrementing XF_VERSION, all existing standalone application (should) fail
> gracefully on a version mismatch anyway
>
> The CRC is generated by:
> - Pre-processing common.h (which includes global_data.h after all the
> board, arch and SoC defines are set)
> - Searches for a chunk of text delimited by 'typedef struct global_data {'
> and '} gd_t;'
> - Strips all blank lines and whitespaces (pre-processor already took care
> of comments)
> - Pipes the result through 'tools/gencrc32header/gencrc32header'
Sorry, but I don't consider this an even halfway robust or reliable
method. Minor changes to the text formatting, changes to remove for
example the typedef, renames of fields or appending additional fields
will all break this, while tere will actually be no problems with the
code.
THis is a level of make-believe security that is fragile, and I doubt
if it's really useful, or needed.
It's a nice idea, but the problem it addresses is mostly a theoretical
one - has anybody seen any actual bug reports that this has ever been
a real problem?
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 prejudices people feel about each other disappear when then
get to know each other.
-- Kirk, "Elaan of Troyius", stardate 4372.5
More information about the U-Boot
mailing list