[SECURITY PATCH 72/73] loader/i386/linux: Cast left shift to grub_uint32_t

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown The Coverity complains that we might overflow into a negative value when setting linux_params.kernel_alignment to (1 << align). We can remedy this by casting it to grub_uint32_t. Fixes: CID 473876 Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper --- grub-core/loader/i386/

Re: [PATCH] powerpc: increase MIN RMA size for CAS negotiation

2025-02-18 Thread Leo Sandoval
LGTM Reviewed-by: Leo Sandoval On Mon, Feb 17, 2025 at 12:44 PM Mukesh Kumar Chaurasiya < mchau...@linux.ibm.com> wrote: > On Wed, Jan 15, 2025 at 05:46:05PM +0530, Avnish Chouhan wrote: > > Change RMA size from 512 MB to 768 MB which will result > > in more memory at boot time for PowerPC. When

[SECURITY PATCH 62/73] net: Prevent overflows when allocating memory for arrays

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Use grub_calloc() when allocating memory for arrays to ensure proper overflow checks are in place. Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper --- grub-core/net/dns.c | 4 ++-- grub-core/net/net.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --gi

Re: [SECURITY PATCH 00/73] GRUB2 vulnerabilities - 2025/02/18

2025-02-18 Thread Didier Spaier via Grub-devel
Hi Daniel and all, sorry for top posting but this is a question and a request, not a comment. maintaining a distribution alone I can't afford to carry as many patches as Debian, so: could please mention the commit to which checkout when all these patches will be applied upstream? Thanks in advan

[SECURITY PATCH 66/73] osdep/unix/getroot: Fix potential underflow

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The entry_len is initialized in grub_find_root_devices_from_mountinfo() to 0 before the while loop iterates through /proc/self/mountinfo. If the file is empty or contains only invalid entries entry_len remains 0 causing entry_len - 1 in the subsequent for loop initialization to

Re: [SECURITY PATCH 00/73] GRUB2 vulnerabilities - 2025/02/18

2025-02-18 Thread Tobias Powalowski via Grub-devel
Am 18.02.25 um 19:00 schrieb Daniel Kiper via Grub-devel: I am posting all the GRUB2 upstream patches which fix all security bugs found and reported up until now. Major Linux distros carry or will carry soon one form or another of these patches. Now all the GRUB2 upstream patches are in the GRUB2

[SECURITY PATCH 46/73] commands/memrw: Disable memory reading in lockdown mode

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn With the rest of module being blocked in lockdown mode it does not make a lot of sense to leave memory reading enabled. This also goes in par with disabling the dump command. Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/commands/memrw.c | 21

[SECURITY PATCH 25/73] kern/disk: Limit recursion depth

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The grub_disk_read() may trigger other disk reads, e.g. via loopbacks. This may lead to very deep recursion which can corrupt the heap. So, fix the issue by limiting reads depth. Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/kern/disk.c | 27 +

[SECURITY PATCH 59/73] fs/zfs: Check if returned pointer for allocated memory is NULL

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen When using grub_malloc() or grub_zalloc(), these functions can fail if we are out of memory. After allocating memory we should check if these functions returned NULL and handle this error if they did. Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper --- grub-core/fs/zfs/

[SECURITY PATCH 08/73] fs/iso9660: Set a grub_errno if mount fails

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was possible for a grub_errno to not be set if mount of an ISO 9660 filesystem failed when set_rockridge() returned 0. This isn't known to be exploitable as the other filesystems due to filesystem helper checking the requested file type. Though fixing as a precaution. Reported-b

[SECURITY PATCH 18/73] fs/ntfs: Implement attribute verification

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was possible to read OOB when an attribute had a size that exceeded the allocated buffer. This resolves that by making sure all attributes that get read are fully in the allocated space by implementing a function to validate them. Defining the offsets in include/grub/ntfs.h but t

[SECURITY PATCH 20/73] fs/xfs: Ensuring failing to mount sets a grub_errno

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was previously possible for grub_xfs_mount() to return NULL without setting grub_errno if the XFS version was invalid. This resulted in it being possible for grub_dl_unref() to be called twice allowing the XFS module to be unloaded while there were still references to it. Fixing

[SECURITY PATCH 09/73] fs/iso9660: Fix invalid free

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Michael Chang The ctx->filename can point to either a string literal or a dynamically allocated string. The ctx->filename_alloc field is used to indicate the type of allocation. An issue has been identified where ctx->filename is reassigned to a string literal in susp_iterate_dir() but ctx

[SECURITY PATCH 21/73] kern/file: Ensure file->data is set

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn This is to avoid a generic issue were some filesystems would not set data and also not set a grub_errno. This meant it was possible for many filesystems to grub_dl_unref() themselves multiple times resulting in it being possible to unload the filesystems while there were still refere

[SECURITY PATCH 39/73] normal: Remove variables hooks on module unload

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The normal module does not entirely cleanup after itself in its GRUB_MOD_FINI() leaving a few variables hooks in place. It is not possible to unload normal module now but fix the issues for completeness. On the occasion replace 0s with NULLs for "pager" variable hooks unregister. F

[SECURITY PATCH 13/73] fs/jfs: Inconsistent signed/unsigned types usage in return values

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The getblk() returns a value of type grub_int64_t which is assigned to iagblk and inoblk, both of type grub_uint64_t, in grub_jfs_read_inode() via grub_jfs_blkno(). This patch fixes the type mismatch in the functions. Additionally, the getblk() will return 0 instead of -1 on fai

[SECURITY PATCH 61/73] net: Use safe math macros to prevent overflows

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Replace direct arithmetic operations with macros from include/grub/safemath.h to prevent potential overflow issues when calculating the memory sizes. Signed-off-by: Lidong Chen Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper --- grub-core/net/bootp.c |

[SECURITY PATCH 56/73] fs: Prevent overflows when assigning returned values from read_number()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The direct assignment of the unsigned long long value returned by read_number() can potentially lead to an overflow on a 32-bit systems. The fix replaces the direct assignments with calls to grub_cast() which detects the overflows and safely assigns the values if no overflow is

[SECURITY PATCH 42/73] gettext: Integer overflow leads to heap OOB write

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The size calculation of the translation buffer in grub_gettext_getstr_from_position() may overflow to 0 leading to heap OOB write. This patch fixes the issue by using grub_add() and checking for an overflow. Fixes: CVE-2024-45777 Reported-by: Nils Langius Signed-off-by: Lidon

[SECURITY PATCH 47/73] commands/hexdump: Disable memory reading in lockdown mode

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/commands/hexdump.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/hexdump.c b/grub-core/commands/hexdump.c index eaa12465b..d6f61d98a 100644 --- a/grub-

[SECURITY PATCH 63/73] net: Check if returned pointer for allocated memory is NULL

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown When using grub_malloc(), the function can fail if we are out of memory. After allocating memory we should check if this function returned NULL and handle this error if it did. Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper --- grub-core/net/net.c | 5 + 1 file chang

[SECURITY PATCH 65/73] script/execute: Fix potential underflow and NULL dereference

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The result is initialized to 0 in grub_script_arglist_to_argv(). If the for loop condition is not met both result.args and result.argc remain 0 causing result.argc - 1 to underflow and/or result.args NULL dereference. Fix the issues by adding relevant checks. Fixes: CID 473880

[SECURITY PATCH 73/73] loader/i386/bsd: Use safe math to avoid underflow

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown The operation kern_end - kern_start may underflow when we input it into grub_relocator_alloc_chunk_addr() call. To avoid this we can use safe math for this subtraction. Fixes: CID 73845 Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper --- grub-core/loader/i386/bsd.c | 14

[SECURITY PATCH 71/73] kern/misc: Add sanity check after grub_strtoul() call

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen When the format string, fmt0, includes a positional argument grub_strtoul() or grub_strtoull() is called to extract the argument position. However, the returned argument position isn't fully validated. If the format is something like "%0$x" then these functions return 0 which le

[SECURITY PATCH 70/73] kern/partition: Add sanity check after grub_strtoul() call

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The current code incorrectly assumes that both the input and the values returned by grub_strtoul() are always valid which can lead to potential errors. This fix ensures proper validation to prevent any unintended issues. Fixes: CID 473843 Signed-off-by: Lidong Chen Reviewed-b

[SECURITY PATCH 69/73] normal/menu: Use safe math to avoid an integer overflow

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown The Coverity indicates that the variable current_entry might overflow. To prevent this use safe math when adding GRUB_MENU_PAGE_SIZE to current_entry. On the occasion fix limiting condition which was broken. Fixes: CID 473853 Signed-off-by: Alec Brown Reviewed-by: Daniel Kipe

[SECURITY PATCH 45/73] commands/minicmd: Block the dump command in lockdown mode

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The dump enables a user to read memory which should not be possible in lockdown mode. Fixes: CVE-2025-1118 Reported-by: B Horn Reported-by: Jonathan Bar Or Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/commands/minicmd.c | 4 ++-- 1 file changed, 2 insertions(+

[SECURITY PATCH 57/73] fs/zfs: Use safe math macros to prevent overflows

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Replace direct arithmetic operations with macros from include/grub/safemath.h to prevent potential overflow issues when calculating the memory sizes. Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper --- grub-core/fs/zfs/zfs.c | 50

[SECURITY PATCH 48/73] fs/bfs: Disable under lockdown

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Daniel Axtens The BFS is not fuzz-clean. Don't allow it to be loaded under lockdown. This will also disable the AFS. Fixes: CVE-2024-45778 Fixes: CVE-2024-45779 Reported-by: Nils Langius Signed-off-by: Daniel Axtens Reviewed-by: Daniel Kiper --- grub-core/fs/bfs.c | 11 --- 1

[SECURITY PATCH 68/73] bus/usb/ehci: Define GRUB_EHCI_TOGGLE as grub_uint32_t

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown The Coverity indicates that GRUB_EHCI_TOGGLE is an int that contains a negative value and we are using it for the variable token which is grub_uint32_t. To remedy this we can cast the definition to grub_uint32_t. Fixes: CID 473851 Signed-off-by: Alec Brown Reviewed-by: Daniel

[SECURITY PATCH 26/73] kern/partition: Limit recursion in part_iterate()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The part_iterate() is used by grub_partition_iterate() as a callback in the partition iterate functions. However, part_iterate() may also call the partition iterate functions which may lead to recursion. Fix potential issue by limiting the recursion depth. Signed-off-by: B Horn Rev

[SECURITY PATCH 44/73] commands/test: Stack overflow due to unlimited recursion depth

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The test_parse() evaluates test expression recursively. Due to lack of recursion depth check a specially crafted expression may cause a stack overflow. The recursion is only triggered by the parentheses usage and it can be unlimited. However, sensible expressions are unlikely to

[SECURITY PATCH 41/73] gettext: Integer overflow leads to heap OOB write or read

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Calculation of ctx->grub_gettext_msg_list size in grub_mofile_open() may overflow leading to subsequent OOB write or read. This patch fixes the issue by replacing grub_zalloc() and explicit multiplication with grub_calloc() which does the same thing in safe manner. Fixes: CVE-2

[SECURITY PATCH 58/73] fs/zfs: Prevent overflows when allocating memory for arrays

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Use grub_calloc() when allocating memory for arrays to ensure proper overflow checks are in place. Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper --- grub-core/fs/zfs/zfs.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/zfs/zfs

[SECURITY PATCH 67/73] misc: Ensure consistent overflow error messages

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Update the overflow error messages to make them consistent across the GRUB code. Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper --- grub-core/fs/ntfs.c | 2 +- grub-core/fs/ntfscomp.c | 2 +- grub-core/video/readers/png.c | 2 +- 3 files changed, 3 inse

[SECURITY PATCH 64/73] fs/sfs: Check if allocated memory is NULL

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown When using grub_zalloc(), if we are out of memory, this function can fail. After allocating memory, we should check if grub_zalloc() returns NULL. If so, we should handle this error. Fixes: CID 473856 Signed-off-by: Alec Brown Reviewed-by: Ross Philipson Reviewed-by: Daniel K

[SECURITY PATCH 55/73] fs: Prevent overflows when allocating memory for arrays

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Use grub_calloc() when allocating memory for arrays to ensure proper overflow checks are in place. The HFS+ and squash4 security vulnerabilities were reported by Jonathan Bar Or . Fixes: CVE-2025-0678 Fixes: CVE-2025-1125 Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper

[SECURITY PATCH 60/73] fs/zfs: Add missing NULL check after grub_strdup() call

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper --- grub-core/fs/zfs/zfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 6a964974f..376042631 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@

[SECURITY PATCH 49/73] fs: Disable many filesystems under lockdown

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Daniel Axtens The idea is to permit the following: btrfs, cpio, exfat, ext, f2fs, fat, hfsplus, iso9660, squash4, tar, xfs and zfs. The JFS, ReiserFS, romfs, UDF and UFS security vulnerabilities were reported by Jonathan Bar Or . Fixes: CVE-2025-0677 Fixes: CVE-2025-0684 Fixes: CVE-2025-0

[SECURITY PATCH 54/73] fs: Use safe math macros to prevent overflows

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Replace direct arithmetic operations with macros from include/grub/safemath.h to prevent potential overflow issues when calculating the memory sizes. Signed-off-by: Lidong Chen Reviewed-by: Daniel Kiper --- grub-core/fs/archelp.c | 9 - grub-core/fs/btrfs.c

[SECURITY PATCH 38/73] commands/pgp: Unregister the "check_signatures" hooks on module unload

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn If the hooks are not removed they can be called after the module has been unloaded leading to an use-after-free. Fixes: CVE-2025-0622 Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/commands/pgp.c | 2 ++ 1 file changed, 2 insertions(+) diff -

[SECURITY PATCH 51/73] disk: Prevent overflows when allocating memory for arrays

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown Use grub_calloc() when allocating memory for arrays to ensure proper overflow checks are in place. Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper --- grub-core/disk/cryptodisk.c | 2 +- grub-core/disk/lvm.c| 6 ++ 2 files changed, 3 insertions(+), 5 deletions

[SECURITY PATCH 32/73] video/readers/jpeg: Do not permit duplicate SOF0 markers in JPEG

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Daniel Axtens Otherwise a subsequent header could change the height and width allowing future OOB writes. Fixes: CVE-2024-45774 Reported-by: Nils Langius Signed-off-by: Daniel Axtens Reviewed-by: Daniel Kiper --- grub-core/video/readers/jpeg.c | 4 1 file changed, 4 insertions(+)

[SECURITY PATCH 43/73] commands/read: Fix an integer overflow when supplying more than 2^31 characters

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Jonathan Bar Or The grub_getline() function currently has a signed integer variable "i" that can be overflown when user supplies more than 2^31 characters. It results in a memory corruption of the allocated line buffer as well as supplying large negative values to grub_realloc(). Fixes: CV

[SECURITY PATCH 37/73] commands/ls: Fix NULL dereference

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The grub_strrchr() may return NULL when the dirname do not contain "/". This can happen on broken filesystems. Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/commands/ls.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a

[SECURITY PATCH 53/73] disk/ieee1275/ofdisk: Call grub_ieee1275_close() when grub_malloc() fails

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown In the dev_iterate() function a handle is opened but isn't closed when grub_malloc() returns NULL. We should fix this by closing it on error. Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper --- grub-core/disk/ieee1275/ofdisk.c | 5 - 1 file changed, 4 insertions(+), 1

[SECURITY PATCH 50/73] disk: Use safe math macros to prevent overflows

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown Replace direct arithmetic operations with macros from include/grub/safemath.h to prevent potential overflow issues when calculating the memory sizes. Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper --- grub-core/disk/cryptodisk.c | 36 ++-- grub-c

[SECURITY PATCH 52/73] disk: Check if returned pointer for allocated memory is NULL

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Alec Brown When using grub_malloc(), grub_zalloc() or grub_calloc(), these functions can fail if we are out of memory. After allocating memory we should check if these functions returned NULL and handle this error if they did. On the occasion make a NULL check in ATA code more obvious. Si

[SECURITY PATCH 40/73] gettext: Remove variables hooks on module unload

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The gettext module does not entirely cleanup after itself in its GRUB_MOD_FINI() leaving a few variables hooks in place. It is not possible to unload gettext module because normal module depends on it. Though fix the issues for completeness. Fixes: CVE-2025-0622 Reported-by: B Horn

[SECURITY PATCH 34/73] kern/dl: Use correct segment in grub_dl_set_mem_attrs()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The previous code would never actually call grub_update_mem_attrs() as sh_info will always be zero for the sections that exist in memory. Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/kern/dl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletio

[SECURITY PATCH 22/73] kern/file: Implement filesystem reference counting

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The grub_file_open() and grub_file_close() should be the only places that allow a reference to a filesystem to stay open. So, add grub_dl_t to grub_fs_t and set this in the GRUB_MOD_INIT() for each filesystem to avoid issues when filesystems forget to do it themselves or do not track

[SECURITY PATCH 35/73] kern/dl: Check for the SHF_INFO_LINK flag in grub_dl_relocate_symbols()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The grub_dl_relocate_symbols() iterates through the sections in an ELF looking for relocation sections. According to the spec [1] the SHF_INFO_LINK flag should be set if the sh_info field is meant to be a section index. [1] https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html

[SECURITY PATCH 36/73] commands/extcmd: Missing check for failed allocation

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The grub_extcmd_dispatcher() calls grub_arg_list_alloc() to allocate a grub_arg_list struct but it does not verify the allocation was successful. In case of failed allocation the NULL state pointer can be accessed in parse_option() through grub_arg_parse() which may lead to a se

[SECURITY PATCH 28/73] net: Unregister net_default_ip and net_default_mac variables hooks on unload

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The net module is a dependency of normal. So, it shouldn't be possible to unload the net. Though unregister variables hooks as a precaution. It also gets in line with unregistering the other net module hooks. Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/net/net.c

[SECURITY PATCH 33/73] kern/dl: Fix for an integer overflow in grub_dl_ref()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was possible to overflow the value of mod->ref_count, a signed integer, by repeatedly invoking insmod on an already loaded module. This led to a use-after-free. As once ref_count was overflowed it became possible to unload the module while there was still references to it. This r

[SECURITY PATCH 30/73] net: Fix OOB write in grub_net_search_config_file()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The function included a call to grub_strcpy() which copied data from an environment variable to a buffer allocated in grub_cmd_normal(). The grub_cmd_normal() didn't consider the length of the environment variable. So, the copy operation could exceed the allocation and lead to an OOB

[SECURITY PATCH 27/73] script/execute: Limit the recursion depth

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn If unbounded recursion is allowed it becomes possible to collide the stack with the heap. As UEFI firmware often lacks guard pages this becomes an exploitable issue as it is possible in some cases to do a controlled overwrite of a section of this heap region with arbitrary data. Rep

[SECURITY PATCH 31/73] net/tftp: Fix stack buffer overflow in tftp_open()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn An overly long filename can be passed to tftp_open() which would cause grub_normalize_filename() to write out of bounds. Fixed by adding an extra argument to grub_normalize_filename() for the space available, making it act closer to a strlcpy(). As several fixed strings are strcpy()

[SECURITY PATCH 24/73] disk/loopback: Reference tracking for the loopback

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was possible to delete a loopback while there were still references to it. This led to an exploitable use-after-free. Fixed by implementing a reference counting in the grub_loopback struct. Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/dis

[SECURITY PATCH 29/73] net: Remove variables hooks when interface is unregisted

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The grub_net_network_level_interface_unregister(), previously implemented in a header, did not remove the variables hooks that were registered in grub_net_network_level_interface_register(). Fix this by implementing the same logic used to register the variables and move the function

[SECURITY PATCH 17/73] fs/ntfs: Use a helper function to access attributes

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn Right now to access the next attribute the code reads the length of the current attribute and adds that to the current pointer. This is error prone as bounds checking needs to be performed all over the place. So, implement a helper and ensure its used across find_attr() and read_attr

[SECURITY PATCH 10/73] fs/jfs: Fix OOB read in jfs_getent()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen The JFS fuzzing revealed an OOB read in grub_jfs_getent(). The crash was caused by an invalid leaf nodes count, diro->dirpage->header.count, which was larger than the maximum number of leaf nodes allowed in an inode. This fix is to ensure that the leaf nodes count is validated i

[SECURITY PATCH 16/73] fs/ntfs: Track the end of the MFT attribute buffer

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn The end of the attribute buffer should be stored alongside the rest of the attribute struct as right now it is not possible to implement bounds checking when accessing attributes sequentially. This is done via: - updating init_attr() to set at->end and check is is not initially ou

[SECURITY PATCH 19/73] fs/xfs: Fix out-of-bounds read

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Michael Chang The number of records in the root key array read from disk was not being validated against the size of the root node. This could lead to an out-of-bounds read. This patch adds a check to ensure that the number of records in the root key array does not exceed the expected size

[SECURITY PATCH 14/73] fs/ext2: Fix out-of-bounds read for inline extents

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Michael Chang When inline extents are used, i.e. the extent tree depth equals zero, a maximum of four entries can fit into the inode's data block. If the extent header states a number of entries greater than four the current ext2 implementation causes an out-of-bounds read. Fix this issue b

[SECURITY PATCH 23/73] disk/cryptodisk: Require authentication after TPM unlock for CLI access

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Michael Chang The GRUB may use TPM to verify the integrity of boot components and the result can determine whether a previously sealed key can be released. If everything checks out, showing nothing has been tampered with, the key is released and GRUB unlocks the encrypted root partition for

[SECURITY PATCH 15/73] fs/ntfs: Fix out-of-bounds read

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Michael Chang When parsing NTFS file records the presence of the 0xFF marker indicates the end of the attribute list. This value signifies that there are no more attributes to process. However, when the end marker is missing due to corrupted metadata the loop continues to read beyond the a

[SECURITY PATCH 12/73] fs/jfs: Use full 40 bits offset and address for a data extent

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen An extent's logical offset and address are represented as a 40-bit value split into two parts: the most significant 8 bits and the least significant 32 bits. Currently the JFS code uses only the least significant 32 bits value for offsets and addresses assuming the data size wil

[SECURITY PATCH 11/73] fs/jfs: Fix OOB read caused by invalid dir slot index

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen While fuzz testing JFS with ASAN enabled an OOB read was detected in grub_jfs_opendir(). The issue occurred due to an invalid directory slot index in the first entry of the sorted directory slot array in the inode directory header. The fix ensures the slot index is validated bef

[SECURITY PATCH 06/73] fs/f2fs: Set a grub_errno if mount fails

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was previously possible for grub_errno to not be set when grub_f2fs_mount() failed if nat_bitmap_ptr() returned NULL. This issue is solved by ensuring a grub_errno is set in the fail case. Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/fs/f

[SECURITY PATCH 07/73] fs/hfsplus: Set a grub_errno if mount fails

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was possible for mount to fail but not set grub_errno. This led to a possible double decrement of the module reference count if the NULL page was mapped. Fixing in general as a similar bug was fixed in commit 61b13c187 (fs/hfsplus: Set grub_errno to prevent NULL pointer access) a

[SECURITY PATCH 05/73] fs/tar: Integer overflow leads to heap OOB write

2025-02-18 Thread Daniel Kiper via Grub-devel
From: Lidong Chen Both namesize and linksize are derived from hd.size, a 12-digit octal number parsed by read_number(). Later direct arithmetic calculation like "namesize + 1" and "linksize + 1" may exceed the maximum value of grub_size_t leading to heap OOB write. This patch fixes the issue by u

[SECURITY PATCH 04/73] fs/tar: Initialize name in grub_cpio_find_file()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn It was possible to iterate through grub_cpio_find_file() without allocating name and not setting mode to GRUB_ARCHELP_ATTR_END, which would cause the uninitialized value for name to be used as an argument for canonicalize() in grub_archelp_dir(). Reported-by: B Horn Signed-off-by:

[SECURITY PATCH 03/73] fs/hfs: Fix stack OOB write with grub_strcpy()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn Replaced with grub_strlcpy(). Fixes: CVE-2024-45782 Fixes: CVE-2024-56737 Fixes: https://savannah.gnu.org/bugs/?66599 Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- grub-core/fs/hfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g

[SECURITY PATCH 01/73] misc: Implement grub_strlcpy()

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn grub_strlcpy() acts the same way as strlcpy() does on most *NIX, returning the length of src and ensuring dest is always NUL terminated except when size is 0. Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- include/grub/misc.h | 39 +++ 1 f

[SECURITY PATCH 02/73] fs/ufs: Fix a heap OOB write

2025-02-18 Thread Daniel Kiper via Grub-devel
From: B Horn grub_strcpy() was used to copy a symlink name from the filesystem image to a heap allocated buffer. This led to a OOB write to adjacent heap allocations. Fix by using grub_strlcpy(). Fixes: CVE-2024-45781 Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper --- g

[SECURITY PATCH 00/73] GRUB2 vulnerabilities - 2025/02/18

2025-02-18 Thread Daniel Kiper via Grub-devel
Hi all, This patch set contains a bundle of fixes for various security flaws discovered, as part of a pro-active hardening effort, in the GRUB2 code recently. The most severe ones, i.e. potentially exploitable, have CVEs assigned and are listed at the end of this email. Details of exactly what ne