btrfs: lzo: reject inline extents without both headers
PATCH 1/1 btrfs: lzo: reject inline extents without both headers
inline Btrfs LZO payload shorter than two LZO headers.
Fix the validation or lifetime rule at the vulnerable boundary so malformed or racing input cannot reach the faulting path.
---
Trail of Bits has a reproducer for this bug demonstrating Kernel Panic which can be shared further if needed.
fs/btrfs/lzo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/lzo.c +2 -1
@@ -552,7 +552,8 @@ int lzo_decompress(struct list_head *ws, const u8 *data_in,size_t max_segment_len =workspace_buf_length (fs_info);int ret; -if (unlikely (srclen <LZO_LEN || srclen > max_segment_len +LZO_LEN *2 )) +if (unlikely (srclen <LZO_LEN *2 || + srclen > max_segment_len +LZO_LEN *2 ))return -EUCLEAN ; in_len =get_unaligned_le32 (data_in);
Quoted 17 lines · David Lee
inline Btrfs LZO payload shorter than two LZO headers.
Fix the validation or lifetime rule at the vulnerable boundary so malformed or racing input cannot reach the faulting path.
Signed-off-by David Lee <[email protected]>Assisted-by Codex:gpt-5.5---
Trail of Bits has a reproducer for this bug demonstrating Kernel Panic which can be shared further if needed.
fs/btrfs/lzo.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/lzo.c int lzo_decompress(struct list_head *ws, const u8 *data_in, · line 555
Quoted 5 lines
fs/btrfs/lzo.c +1
-1@@ -552,7 +552,8 @@ int lzo_decompress(struct list_head *ws, const u8 *data_in,size_t max_segment_len =workspace_buf_length (fs_info);int ret; -if (unlikely (srclen <LZO_LEN || srclen > max_segment_len +LZO_LEN *2 )) + if (unlikely(srclen < LZO_LEN * 2 ||
srclen == LZO_LEN * 2 is also invalid, as that means the lzo payload is empty.
Also your base is a little too old.
The latest for-next branch has extra error messages, thus your patch doesn't apply cleanly.
Please rebase to the latest for-next branch:
https://github.com/btrfs/linux.git for-next
Otherwise the fix looks good to me.
Thanks,
Qu
Quoted 6 lines
fs/btrfs/lzo.c +1
-0+ srclen > max_segment_len + LZO_LEN * 2))return -EUCLEAN ; in_len =get_unaligned_le32 (data_in);
Quoted 5 lines · Qu Wenruo
Quoted 2 lines · David Lee
inline Btrfs LZO payload shorter than two LZO headers.
Quoted 7 lines
Quoted 7 lines
Fix the validation or lifetime rule at the vulnerable boundary so malformed or racing input cannot reach the faulting path.
Signed-off-by David Lee <[email protected]>Assisted-by Codex:gpt-5.5---
Trail of Bits has a reproducer for this bug demonstrating Kernel Panic which can be shared further if needed.
Also forgot to mention, it's always better to provide the full calltrace.
It will benefit people who hit a similar crash to determine if it's already fixed.
Quoted 38 lines
Quoted 8 lines
fs/btrfs/lzo.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)fs/btrfs/lzo.c int lzo_decompress(struct list_head *ws, const u8 · line 556
Quoted 6 lines
fs/btrfs/lzo.c +1
-1@@ -552,7 +552,8 @@ int lzo_decompress(struct list_head *ws, const u8 *data_in, size_t max_segment_len = workspace_buf_length(fs_info); int ret; - if (unlikely(srclen < LZO_LEN || srclen > max_segment_len + LZO_LEN * 2)) + if (unlikely(srclen < LZO_LEN * 2 ||srclen ==
LZO_LEN* 2 is also invalid, as that means the lzo payload is empty.Also your base is a little too old.
The latest for-next branch has extra error messages, thus your patch doesn't apply cleanly.
Please rebase to the latest for-next branch:
https://github.com/btrfs/linux.git for-next
Otherwise the fix looks good to me.
Thanks,
QuQuoted 5 lines
fs/btrfs/lzo.c +1
-0+ srclen > max_segment_len + LZO_LEN * 2)) return -EUCLEAN; in_len = get_unaligned_le32(data_in);