|
|
fd0330 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
fd0330 |
From: Daniel Axtens <dja@axtens.net>
|
|
|
fd0330 |
Date: Tue, 18 Jan 2022 14:29:20 +1100
|
|
|
fd0330 |
Subject: [PATCH] net/tftp: Avoid a trivial UAF
|
|
|
fd0330 |
|
|
|
fd0330 |
Under tftp errors, we print a tftp error message from the tftp header.
|
|
|
fd0330 |
However, the tftph pointer is a pointer inside nb, the netbuff. Previously,
|
|
|
fd0330 |
we were freeing the nb and then dereferencing it. Don't do that, use it
|
|
|
fd0330 |
and then free it later.
|
|
|
fd0330 |
|
|
|
fd0330 |
This isn't really _bad_ per se, especially as we're single-threaded, but
|
|
|
fd0330 |
it trips up fuzzers.
|
|
|
fd0330 |
|
|
|
fd0330 |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
fd0330 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
fd0330 |
(cherry picked from commit 956f4329cec23e4375182030ca9b2be631a61ba5)
|
|
|
fd0330 |
---
|
|
|
fd0330 |
grub-core/net/tftp.c | 2 +-
|
|
|
fd0330 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
fd0330 |
|
|
|
fd0330 |
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
|
|
|
fd0330 |
index 788ad1dc44..a95766dcbd 100644
|
|
|
fd0330 |
--- a/grub-core/net/tftp.c
|
|
|
fd0330 |
+++ b/grub-core/net/tftp.c
|
|
|
fd0330 |
@@ -251,9 +251,9 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)),
|
|
|
fd0330 |
return GRUB_ERR_NONE;
|
|
|
fd0330 |
case TFTP_ERROR:
|
|
|
fd0330 |
data->have_oack = 1;
|
|
|
fd0330 |
- grub_netbuff_free (nb);
|
|
|
fd0330 |
grub_error (GRUB_ERR_IO, "%s", tftph->u.err.errmsg);
|
|
|
fd0330 |
grub_error_save (&data->save_err);
|
|
|
fd0330 |
+ grub_netbuff_free (nb);
|
|
|
fd0330 |
return GRUB_ERR_NONE;
|
|
|
fd0330 |
default:
|
|
|
fd0330 |
grub_netbuff_free (nb);
|