ANDROID: dm verity fec: limit error correction recursion

If verity tree itself is sufficiently corrupted in addition to data
blocks, it's possible for error correction to end up in a deep recursive
error correction loop that eventually causes a kernel panic as follows:

[   14.728962] [<ffffffc0008c1a14>] verity_fec_decode+0xa8/0x138
[   14.734691] [<ffffffc0008c3ee0>] verity_verify_level+0x11c/0x180
[   14.740681] [<ffffffc0008c482c>] verity_hash_for_block+0x88/0xe0
[   14.746671] [<ffffffc0008c1508>] fec_decode_rsb+0x318/0x75c
[   14.752226] [<ffffffc0008c1a14>] verity_fec_decode+0xa8/0x138
[   14.757956] [<ffffffc0008c3ee0>] verity_verify_level+0x11c/0x180
[   14.763944] [<ffffffc0008c482c>] verity_hash_for_block+0x88/0xe0

This change limits the recursion to a reasonable level during a single
I/O operation.

Contains subsequent fix:

  Sami Tolvanen <samitolvanen@google.com>:
  ANDROID: dm verity fec: initialize recursion level

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

Bug: 28943429
Patchset: dm-verity

Signed-off-by: Mattias Nissler <mnissler@google.com>
Change-Id: I42d0871f9deb401e05e5985117735dc1f68c5c38
2 files changed