smbios: Fix buffer overrun when using path= option
PATCH 1/1 smbios: Fix buffer overrun when using path= option
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)
hw/smbios/smbios.c +3 -0
@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);
Signature · 1 line
2.49.0
Quoted 16 lines · Daan De Meyer
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Fixes bb99f4772f54017490e3356ecbb3df25c5d4537f ("hw/smbios: support loading OEM strings values from a file")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
Signed-off-by Daan De Meyer <[email protected]>--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)hw/smbios/smbios.c +0
-0
hw/smbios/smbios.c static int save_opt_one(void *opaque, · line 1293
Quoted 9 lines
hw/smbios/smbios.c +3
-0@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);
Please make sure to put the maintainers on CC: (done now, for the next time please see the MAINTAINERS file or use the scripts/get_maintainers.pl script), otherwise your patch might go unnoticed.
Thomas
Quoted 12 lines · Thomas Huth
Quoted 11 lines · Daan De Meyer
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Fixes bb99f4772f54017490e3356ecbb3df25c5d4537f ("hw/smbios: support loading OEM strings values from a file")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
Signed-off-by Daan De Meyer <[email protected]>--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 16 lines
hw/smbios/smbios.c static int save_opt_one(void *opaque, · line 1291
Quoted 12 lines
hw/smbios/smbios.c +3
-0@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);Please make sure to put the maintainers on CC: (done now, for the next time please see the
MAINTAINERSfile or use thescripts/get_maintainers.plscript), otherwise your patch might go unnoticed.
Michael, Igor, Ani: This patch is needed for QEMU 10.0. You are the maintainers, please review this patch.
Thanks!
Stefan
Quoted 16 lines · Daan De Meyer
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Fixes bb99f4772f54017490e3356ecbb3df25c5d4537f ("hw/smbios: support loading OEM strings values from a file")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
Signed-off-by Daan De Meyer <[email protected]>--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)hw/smbios/smbios.c +0
-0
hw/smbios/smbios.c static int save_opt_one(void *opaque, · line 1293
Quoted 9 lines
hw/smbios/smbios.c +3
-0@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
CC qemu-stable - this needs cherry-picking into all active stable branches once accepted.
Quoted 25 lines · Daniel P. Berrangé
Quoted 24 lines · Daan De Meyer
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Fixes bb99f4772f54017490e3356ecbb3df25c5d4537f ("hw/smbios: support loading OEM strings values from a file")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
Signed-off-by Daan De Meyer <[email protected]>--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)hw/smbios/smbios.c +3
-0@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd);
Quoted 12 lines
hw/smbios/smbios.c static int save_opt_one(void *opaque, · line 1293
Quoted 1 line
hw/smbios/smbios.c +0
-0*opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);Reviewed-by Daniel P. Berrangé <[email protected]>With regards,
DanielSignature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
+Valentin
Quoted 25 lines · Daan De Meyer
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Fixes bb99f4772f54017490e3356ecbb3df25c5d4537f ("hw/smbios: support loading OEM strings values from a file")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
Signed-off-by Daan De Meyer <[email protected]>--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)hw/smbios/smbios.c +3
-0@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1);
Hi,
Unless I'm missing something, I don't think the patch has been merged yet. Any chance it might have been missed?
Cheers,
Daan
Quoted 29 lines · Daan De Meyer
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Fixes bb99f4772f54017490e3356ecbb3df25c5d4537f ("hw/smbios: support loading OEM strings values from a file")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
Signed-off-by Daan De Meyer <[email protected]>--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)hw/smbios/smbios.c +3
-1@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1); --2.49.0
Hi Daan,
Quoted 4 lines · Daan De Meyer
Hi,
Unless I'm missing something, I don't think the patch has been merged yet. Any chance it might have been missed?
I have it tagged, as sensible enough, in case nobody else takes it. IIRC it was sent the same day I posted my latest pull request, so it'd go in the next one, due before next Tuesday. Also I was hoping I could get feedback from Valentin.
Quoted 36 lines
Cheers,
Daan
Quoted 29 lines · Daan De Meyer
We have to make sure the array of bytes read from the path= file is null-terminated, otherwise we run into a buffer overrun later on.
Fixes bb99f4772f54017490e3356ecbb3df25c5d4537f ("hw/smbios: support loading OEM strings values from a file")Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2879
Signed-off-by Daan De Meyer <[email protected]>--- hw/smbios/smbios.c | 3 +++ 1 file changed, 3 insertions(+)hw/smbios/smbios.c +3
-1@@ -1285,6 +1285,9 @@ static int save_opt_one(void *opaque,g_byte_array_append (data, (guint8 *)buf, ret); } + buf[0 ] ='\0' ; +g_byte_array_append (data, (guint8 *)buf,1 ); +qemu_close (fd); *opt->dest = g_renew(char *, *opt->dest, (*opt->ndest) + 1); --2.49.0
Quoted 3 lines · Philippe Mathieu-Daudé
Also I was hoping I could get feedback from Valentin.
Sorry, I did not realize that you wanted my feedback. Daan's patch looks fine to me. I have manually tested it and it fixes my issue.
Philippe Mathieu-Daudé
Tested-by Valentin DavidQuoted 6 lines · Valentin David
On Thu, Apr 3, 2025 at 9:37 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
Also I was hoping I could get feedback from Valentin.
Sorry, I did not realize that you wanted my feedback. Daan's patch looks fine to me. I have manually tested it and it fixes my issue.
Thanks! Might I add your tag then?
Yes.
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Valentin David
On Thu, Apr 3, 2025 at 9:37 PM Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
Also I was hoping I could get feedback from Valentin.
Sorry, I did not realize that you wanted my feedback. Daan's patch looks fine to me. I have manually tested it and it fixes my issue.
Thanks! Might I add your tag then?
Tested-by Valentin David <[email protected]>