public inbox for grub-devel@gnu.org
 help / color / mirror / Atom feed
* [PATCH] aros/hostdisk: Fix use-after-free bug during MsgPort deletion
@ 2025-12-08 10:21 Srish Srinivasan
  2025-12-19  7:07 ` Sudhakar Kuppusamy
  2025-12-29 15:59 ` Daniel Kiper
  0 siblings, 2 replies; 4+ messages in thread
From: Srish Srinivasan @ 2025-12-08 10:21 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, sudhakar, sridharm, ssrish

Inside grub_util_fd_open, a failure while creating an IO
request or opening a device frees ret (the fd) before its
MsgPort is deleted. This leads to a use-after-free scenario.

Fix this by freeing ret after its MsgPort has been deleted.

Signed-off-by: Srish Srinivasan <ssrish@linux.ibm.com>
---
 grub-core/osdep/aros/hostdisk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c
index 08723bd45..c75474933 100644
--- a/grub-core/osdep/aros/hostdisk.c
+++ b/grub-core/osdep/aros/hostdisk.c
@@ -207,8 +207,8 @@ grub_util_fd_open (const char *dev, int flg)
 						 sizeof(struct IOExtTD));
   if (!ret->ioreq)
     {
-      free (ret);
       DeleteMsgPort (ret->mp);
+      free (ret);
       return NULL;
     }
 
@@ -225,9 +225,9 @@ grub_util_fd_open (const char *dev, int flg)
   if (OpenDevice ((unsigned char *) tmp, unit,
 		  (struct IORequest *) ret->ioreq, flags))
     {
-      free (tmp);
-      free (ret);
       DeleteMsgPort (ret->mp);
+      free (ret);
+      free (tmp);
       return NULL;
     }
   free (tmp);
-- 
2.43.0

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-29 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.51.1765213225.32209.grub-devel@gnu.org>
2025-12-09  8:59 ` [PATCH] aros/hostdisk: Fix use-after-free bug during MsgPort deletion Avnish Chouhan
2025-12-08 10:21 Srish Srinivasan
2025-12-19  7:07 ` Sudhakar Kuppusamy
2025-12-29 15:59 ` Daniel Kiper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox