From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, qemu-block <qemu-block@nongnu.org>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Eric Blake" <eblake@redhat.com>
Subject: Re: [PATCH] util/iov: Avoid dynamic stack allocation
Date: Thu, 31 Aug 2023 10:26:17 +0200 [thread overview]
Message-ID: <358c92fd-8384-97b6-f47c-0ba60bd024af@linaro.org> (raw)
In-Reply-To: <20230824164706.2652277-1-peter.maydell@linaro.org>
Cc'ing qemu-block@ (I suppose this will go via a block tree)
On 24/8/23 18:47, Peter Maydell wrote:
> From: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> Use autofree heap allocation instead of variable-length array on the
> stack.
>
> The codebase has very few VLAs, and if we can get rid of them all we
> can make the compiler error on new additions. This is a defensive
> measure against security bugs where an on-stack dynamic allocation
> isn't correctly size-checked (e.g. CVE-2021-3527).
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Usual "only tested with make check/make check-avocado" caveat.
>
> util/iov.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/iov.c b/util/iov.c
> index 866fb577f30..7e73948f5e3 100644
> --- a/util/iov.c
> +++ b/util/iov.c
> @@ -571,7 +571,7 @@ static int sortelem_cmp_src_index(const void *a, const void *b)
> */
> void qemu_iovec_clone(QEMUIOVector *dest, const QEMUIOVector *src, void *buf)
> {
> - IOVectorSortElem sortelems[src->niov];
> + g_autofree IOVectorSortElem *sortelems = g_new(IOVectorSortElem, src->niov);
> void *last_end;
> int i;
>
next prev parent reply other threads:[~2023-08-31 8:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 16:47 [PATCH] util/iov: Avoid dynamic stack allocation Peter Maydell
2023-08-24 19:36 ` Eric Blake
2023-08-31 8:26 ` Philippe Mathieu-Daudé [this message]
2023-08-31 13:34 ` Eric Blake
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=358c92fd-8384-97b6-f47c-0ba60bd024af@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).