Skip to content
Snippets Groups Projects
Forked from drm / msm
354754 commits behind the upstream repository.
  • Dimitri John Ledkov's avatar
    2c484419
    lib/decompress_unlz4.c: correctly handle zero-padding around initrds. · 2c484419
    Dimitri John Ledkov authored
    lz4 compatible decompressor is simple.  The format is underspecified and
    relies on EOF notification to determine when to stop.  Initramfs buffer
    format[1] explicitly states that it can have arbitrary number of zero
    padding.  Thus when operating without a fill function, be extra careful to
    ensure that sizes less than 4, or apperantly empty chunksizes are treated
    as EOF.
    
    To test this I have created two cpio initrds, first a normal one,
    main.cpio.  And second one with just a single /test-file with content
    "second" second.cpio.  Then i compressed both of them with gzip, and with
    lz4 -l.  Then I created a padding of 4 bytes (dd if=/dev/zero of=pad4 bs=1
    count=4).  To create four testcase initrds:
    
     1) main.cpio.gzip + extra.cpio.gzip = pad0.gzip
     2) main.cpio.lz4  + extra.cpio.lz4 = pad0.lz4
     3) main.cpio.gzip + pad4 + extra.cpio.gzip = pad4.gzip
     4) main.cpio.lz4  + pad4 + extra.cpio.lz4 = pad4.lz4
    
    The pad4 test-cases replicate the initrd...
    2c484419
    History
    lib/decompress_unlz4.c: correctly handle zero-padding around initrds.
    Dimitri John Ledkov authored
    lz4 compatible decompressor is simple.  The format is underspecified and
    relies on EOF notification to determine when to stop.  Initramfs buffer
    format[1] explicitly states that it can have arbitrary number of zero
    padding.  Thus when operating without a fill function, be extra careful to
    ensure that sizes less than 4, or apperantly empty chunksizes are treated
    as EOF.
    
    To test this I have created two cpio initrds, first a normal one,
    main.cpio.  And second one with just a single /test-file with content
    "second" second.cpio.  Then i compressed both of them with gzip, and with
    lz4 -l.  Then I created a padding of 4 bytes (dd if=/dev/zero of=pad4 bs=1
    count=4).  To create four testcase initrds:
    
     1) main.cpio.gzip + extra.cpio.gzip = pad0.gzip
     2) main.cpio.lz4  + extra.cpio.lz4 = pad0.lz4
     3) main.cpio.gzip + pad4 + extra.cpio.gzip = pad4.gzip
     4) main.cpio.lz4  + pad4 + extra.cpio.lz4 = pad4.lz4
    
    The pad4 test-cases replicate the initrd...