* [PATCH] fs/btrfs: Zero file data not backed by extents
@ 2023-10-05 13:57 Fabian Vogt
2023-10-05 16:51 ` Daniel Kiper
2023-10-05 21:12 ` Qu Wenruo
0 siblings, 2 replies; 3+ messages in thread
From: Fabian Vogt @ 2023-10-05 13:57 UTC (permalink / raw)
To: grub-devel; +Cc: Qu Wenruo, Michael Chang
Implicit holes in file data need to be zeroed explicitly, instead of
just leaving the data in the buffer uninitialized.
This led to kernels randomly failing to boot in "fun" ways when loaded
from btrfs with the no_holes feature enabled, because large blocks of
zeros in the kernel file contained random data instead.
Signed-off-by: Fabian Vogt <fvogt@suse.de>
---
grub-core/fs/btrfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 19bff4610..ba0c58352 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -1603,6 +1603,8 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
csize = grub_le_to_cpu64 (key_out.offset) - pos;
if (csize > len)
csize = len;
+
+ grub_memset (buf, 0, csize);
buf += csize;
pos += csize;
len -= csize;
--
2.42.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/btrfs: Zero file data not backed by extents
2023-10-05 13:57 [PATCH] fs/btrfs: Zero file data not backed by extents Fabian Vogt
@ 2023-10-05 16:51 ` Daniel Kiper
2023-10-05 21:12 ` Qu Wenruo
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Kiper @ 2023-10-05 16:51 UTC (permalink / raw)
To: Fabian Vogt; +Cc: grub-devel, Qu Wenruo, Michael Chang
On Thu, Oct 05, 2023 at 03:57:44PM +0200, Fabian Vogt wrote:
> Implicit holes in file data need to be zeroed explicitly, instead of
> just leaving the data in the buffer uninitialized.
>
> This led to kernels randomly failing to boot in "fun" ways when loaded
> from btrfs with the no_holes feature enabled, because large blocks of
> zeros in the kernel file contained random data instead.
>
> Signed-off-by: Fabian Vogt <fvogt@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/btrfs: Zero file data not backed by extents
2023-10-05 13:57 [PATCH] fs/btrfs: Zero file data not backed by extents Fabian Vogt
2023-10-05 16:51 ` Daniel Kiper
@ 2023-10-05 21:12 ` Qu Wenruo
1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2023-10-05 21:12 UTC (permalink / raw)
To: Fabian Vogt, grub-devel; +Cc: Michael Chang
On 2023/10/6 00:27, Fabian Vogt wrote:
> Implicit holes in file data need to be zeroed explicitly, instead of
> just leaving the data in the buffer uninitialized.
>
> This led to kernels randomly failing to boot in "fun" ways when loaded
> from btrfs with the no_holes feature enabled, because large blocks of
> zeros in the kernel file contained random data instead.
>
> Signed-off-by: Fabian Vogt <fvogt@suse.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> grub-core/fs/btrfs.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
> index 19bff4610..ba0c58352 100644
> --- a/grub-core/fs/btrfs.c
> +++ b/grub-core/fs/btrfs.c
> @@ -1603,6 +1603,8 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
> csize = grub_le_to_cpu64 (key_out.offset) - pos;
> if (csize > len)
> csize = len;
> +
> + grub_memset (buf, 0, csize);
> buf += csize;
> pos += csize;
> len -= csize;
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-05 21:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-05 13:57 [PATCH] fs/btrfs: Zero file data not backed by extents Fabian Vogt
2023-10-05 16:51 ` Daniel Kiper
2023-10-05 21:12 ` Qu Wenruo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.