Skip to content
  • Kees Cook's avatar
    x86/boot: Clean up pointer casting · 2bc1cd39
    Kees Cook authored
    Currently extract_kernel() defines the input and output buffer pointers
    as "unsigned char *" since that's effectively what they are. It passes
    these to the decompressor routine and to the ELF parser, which both
    logically deal with buffer pointers too. There is some casting ("unsigned
    long") done to validate the numerical value of the pointers, but it is
    relatively limited.
    However, choose_random_location() operates almost exclusively on the
    numerical representation of these pointers, so it ended up carrying
    a lot of "unsigned long" casts. With the future physical/virtual split
    these casts were going to multiply, so this attempts to solve the
    problem by doing all the casting in choose_random_location()'s entry
    and return instead of through-out the code. Adjusts argument names to
    be more meaningful, and changes one us of "choice" to "output" to make
    the future physical/virtual split more clear (i.e. "choice" should be
    strictly a function return value and not used as an intermediate).
    Suggested-by: default avatarIngo Molnar <>
    Signed-off-by: default avatarKees Cook <>
    Cc: Andrew Morton <>
    Cc: Andy Lutomirski <>
    Cc: Andy Lutomirski <>
    Cc: Baoquan He <>
    Cc: Borislav Petkov <>
    Cc: Brian Gerst <>
    Cc: Dave Young <>
    Cc: Denys Vlasenko <>
    Cc: H. Peter Anvin <>
    Cc: Linus Torvalds <>
    Cc: Peter Zijlstra <>
    Cc: Thomas Gleixner <>
    Cc: Vivek Goyal <>
    Cc: Yinghai Lu <>
    Signed-off-by: default avatarIngo Molnar <>