diff options
author | Kinsey Moore <kinsey.moore@oarcorp.com> | 2024-07-23 15:58:05 -0500 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2024-11-14 20:56:19 +0100 |
commit | fe051552f5078fa02d593847529a3884305a6ffe (patch) | |
tree | 8b3fc70de308e8cb20923c06eebcc72344033b52 /fs/jffs2/compr_rtime.c | |
parent | 7c8e694bdb7ba75d13854b59f3af6d66f0ea6df2 (diff) |
jffs2: Prevent rtime decompress memory corruption
The rtime decompression routine does not fully check bounds during the
entirety of the decompression pass and can corrupt memory outside the
decompression buffer if the compressed data is corrupted. This adds the
required check to prevent this failure mode.
Cc: stable@vger.kernel.org
Signed-off-by: Kinsey Moore <kinsey.moore@oarcorp.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/jffs2/compr_rtime.c')
-rw-r--r-- | fs/jffs2/compr_rtime.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c index 79e771ab624f..2b9ef713b844 100644 --- a/fs/jffs2/compr_rtime.c +++ b/fs/jffs2/compr_rtime.c @@ -95,6 +95,9 @@ static int jffs2_rtime_decompress(unsigned char *data_in, positions[value]=outpos; if (repeat) { + if ((outpos + repeat) >= destlen) { + return 1; + } if (backoffs + repeat >= outpos) { while(repeat) { cpage_out[outpos++] = cpage_out[backoffs++]; |