From: Daniel Rosenberg Date: Tue, 27 Jun 2017 01:21:56 +0000 (-0700) Subject: ANDROID: squashfs: Fix endianness issue X-Git-Tag: release-20171130_firefly~4^2~100^2~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a564a0755fa91baef1cb0ce82a67e331bbf6f94a;p=firefly-linux-kernel-4.4.55.git ANDROID: squashfs: Fix endianness issue Code in squashfs_process_blocks was not correctly assigning length. Casting to u16* introduced endianness issues on some architectures. Signed-off-by: Daniel Rosenberg Bug: 35257858 Change-Id: I9efaef4bc531b7469de79cf94738ade2dd6e6a8c --- diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index 4e3e0863f5ea..b3b95e2ae2ff 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c @@ -121,11 +121,12 @@ static void squashfs_process_blocks(struct squashfs_read_request *req) if (req->data_processing == SQUASHFS_METADATA) { /* Extract the length of the metadata block */ - if (req->offset != msblk->devblksize - 1) - length = *((u16 *)(bh[0]->b_data + req->offset)); - else { - length = bh[0]->b_data[req->offset]; - length |= bh[1]->b_data[0] << 8; + if (req->offset != msblk->devblksize - 1) { + length = le16_to_cpup((__le16 *) + (bh[0]->b_data + req->offset)); + } else { + length = (unsigned char)bh[0]->b_data[req->offset]; + length |= (unsigned char)bh[1]->b_data[0] << 8; } req->compressed = SQUASHFS_COMPRESSED(length); req->data_processing = req->compressed ? SQUASHFS_DECOMPRESS