staging: erofs: avoid loop in submit chains
authorGao Xiang <gaoxiang25@huawei.com>
Wed, 21 Aug 2019 03:09:08 +0000 (11:09 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Aug 2019 12:48:06 +0000 (05:48 -0700)
commitbfc4ccb1584129d3ef051f8bf6155835374f132f
treeec99121b1800ae08ffab9e470796a187b832b6c7
parent2cb05d8788f77ed14b99a0fbb2748346071f3a33
staging: erofs: avoid loop in submit chains

As reported by erofs-utils fuzzer, 2 conditions
can happen in corrupted images, which can cause
unexpected behaviors.
 - access the same pcluster one more time;
 - access the tail end pcluster again, e.g.
            _ access again (will trigger tail merging)
           |
     1 2 3 1 2             ->   1 2 3 1
     |_ tail end of the chain    \___/ (unexpected behavior)
Let's detect and avoid them now.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Link: https://lore.kernel.org/r/20190821030908.40282-1-gaoxiang25@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/erofs/zdata.c