From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Basil Salman <basil@daynix.com>,
qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: Yan Vugenfirer <yan@daynix.com>
Subject: Re: [PATCH v3 3/3] qga-win: prevent crash when executing guest-file-read with large count
Date: Tue, 24 Mar 2020 14:20:07 +0100 [thread overview]
Message-ID: <26fa941f-b578-06e7-947e-34ab426097bc@redhat.com> (raw)
In-Reply-To: <20200311170417.13415-4-basil@daynix.com>
On 3/11/20 6:04 PM, Basil Salman wrote:
> BZ: #1594054
^ This is not very helpful as it... (think to ppl with no knowledge of
'BZ', what to do with this number). Instead ...
> guest-file-read command is currently implemented to read from a
> file handle count number of bytes. when executed with a very large count number
> qemu-ga crashes.
> after some digging turns out that qemu-ga crashes after trying to allocate
> a buffer large enough to save the data read in it, the buffer was allocated using
> g_malloc0 which is not fail safe, and results a crash in case of failure.
> g_malloc0 was replaced with g_try_malloc0() which returns NULL on failure,
> A check was added for that case in order to prevent qemu-ga from crashing
> and to send a response to the qemu-ga client accordingly.
>
... add here (see
https://wiki.qemu.org/Contribute/SubmitAPatch#Write_a_meaningful_commit_message):
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1594054
Also add:
Cc: qemu-stable@nongnu.org
> Signed-off-by: Basil Salman <basil@daynix.com>
> ---
> qga/commands-win32.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 9c744d6405..b49920e201 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -343,7 +343,13 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
> }
>
> fh = gfh->fh;
> - buf = g_malloc0(count+1);
> + buf = g_try_malloc0(count + 1);
> + if (!buf) {
> + error_setg(errp,
> + "failed to allocate sufficient memory "
> + "to complete the requested service");
> + return NULL;
> + }
Can you fix the equivalent problem in qga/commands-posix.c too please?
Also use "PATCH-for-5.0" in the patch subject so we don't miss it for
the next release.
Thanks!
Phil.
> is_ok = ReadFile(fh, buf, count, &read_count, NULL);
> if (!is_ok) {
> error_setg_win32(errp, GetLastError(), "failed to read file");
>
next prev parent reply other threads:[~2020-03-24 13:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 17:04 [PATCH v3 0/3] QGA - Win fixes Basil Salman
2020-03-11 17:04 ` [PATCH v3 1/3] qga: Installer: Wait for installation to finish Basil Salman
2020-03-24 13:12 ` Philippe Mathieu-Daudé
2020-03-24 14:00 ` Marc-André Lureau
2020-03-24 14:03 ` Philippe Mathieu-Daudé
2020-03-11 17:04 ` [PATCH v3 2/3] qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error Basil Salman
2020-03-11 17:04 ` [PATCH v3 3/3] qga-win: prevent crash when executing guest-file-read with large count Basil Salman
2020-03-24 13:20 ` Philippe Mathieu-Daudé [this message]
2020-03-24 13:37 ` Philippe Mathieu-Daudé
2020-03-24 16:49 ` Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=26fa941f-b578-06e7-947e-34ab426097bc@redhat.com \
--to=philmd@redhat.com \
--cc=basil@daynix.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=yan@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).