forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uboot-2024.04: fix boot from btrfs fs
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
patch/u-boot/v2024.04/general-btrfs-fix-out-of-bounds-write.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Alex Shumsky <[email protected]> | ||
Date: Mon, 14 Jun 2024 19:01:48 +0000 | ||
Subject: fs/btrfs: fix out of bounds write | ||
|
||
Signed-off-by: Alex Shumsky <[email protected]> | ||
--- | ||
fs/btrfs/inode.c | 4 ++-- | ||
1 file changed, 2 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c | ||
index 4691612eda..b51f578b49 100644 | ||
--- a/fs/btrfs/inode.c | ||
+++ b/fs/btrfs/inode.c | ||
@@ -638,11 +638,11 @@ static int read_and_truncate_page(struct btrfs_path *path, | ||
return -ENOMEM; | ||
|
||
extent_type = btrfs_file_extent_type(leaf, fi); | ||
if (extent_type == BTRFS_FILE_EXTENT_INLINE) { | ||
ret = btrfs_read_extent_inline(path, fi, buf); | ||
- memcpy(dest, buf + page_off, min(page_len, ret)); | ||
+ memcpy(dest, buf + page_off, min(min(page_len, ret), len)); | ||
free(buf); | ||
return len; | ||
} | ||
|
||
ret = btrfs_read_extent_reg(path, fi, | ||
@@ -650,11 +650,11 @@ static int read_and_truncate_page(struct btrfs_path *path, | ||
fs_info->sectorsize, buf); | ||
if (ret < 0) { | ||
free(buf); | ||
return ret; | ||
} | ||
- memcpy(dest, buf + page_off, page_len); | ||
+ memcpy(dest, buf + page_off, min(page_len, len)); | ||
free(buf); | ||
return len; | ||
} | ||
|
||
int btrfs_file_read(struct btrfs_root *root, u64 ino, u64 file_offset, u64 len, | ||
-- | ||
Created with Armbian build tools https://github.com/armbian/build | ||
|