[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] bug: unable to LZ4 decompress ub1910 installer kernel when launching domU



On 04.12.2019 08:14, Jeremi Piotrowski wrote:
> I'm able to repro, and I isolated the code from xc_dom_bzimageloader.c,
> xc_dom_decompress_lz4.c and /xen/common/lz4/decompress.c such that I can
> test more easily (I'm using code from 4.12.1). I'm testing with
> vmlinuz-5.3.0-23-generic installed in ubuntu-19.10.
> 
> What I see is that the code fails at the first frame at decompress.c:282
> (if (unlikely((unsigned long)cpy < (unsigned long)op))).
> because cpy == (op - 1).
> decompress.c:265 (cpy = op + length - (STEPSIZE-4);) gets executed twice and
> prints:
> 
> length=4
> length=3
> 
> STEPSIZE is 8 (x86_64). So this has to fail. The STEPSIZE gave me the
> idea to rebuild the code as 32-bit and decompression works correctly.

Thanks a lot for the analysis.

> Any suggestions how to proceed?

Please give the patch below a try.

Jan

lz4: revert half of 9143a6c55ef7 for the 64-bit case

I clearly went too far there: While the LZ4_WILDCOPY() instances indeed
need prior guarding, LZ4_SECURECOPY() needs this only in the 32-bit case
(where it simply aliases LZ4_WILDCOPY()). "cpy" can validly point
(slightly) below "op" in these cases, due to

                cpy = op + length - (STEPSIZE - 4);

where length can be as low as 0 and STEPSIZE is 8.

Reported-by: Mark Pryor <pryorm09@xxxxxxxxx>
Reported-by: Jeremi Piotrowski <jeremi.piotrowski@xxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- unstable.orig/xen/common/lz4/decompress.c
+++ unstable/xen/common/lz4/decompress.c
@@ -147,8 +147,10 @@ static int INIT lz4_uncompress(const uns
                                goto _output_error;
                        continue;
                }
+#if !LZ4_ARCH64
                if (unlikely((unsigned long)cpy < (unsigned long)op))
                        goto _output_error;
+#endif
                LZ4_SECURECOPY(ref, op, cpy);
                op = cpy; /* correction */
        }
@@ -279,8 +281,10 @@ static int lz4_uncompress_unknownoutputs
                                goto _output_error;
                        continue;
                }
+#if !LZ4_ARCH64
                if (unlikely((unsigned long)cpy < (unsigned long)op))
                        goto _output_error;
+#endif
                LZ4_SECURECOPY(ref, op, cpy);
                op = cpy; /* correction */
        }


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.