From: "Daniel P. Berrangé" <berrange@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [PATCH] ui/clipboard: fix use-after-free regression
Date: Mon, 14 Feb 2022 12:02:05 +0000 [thread overview]
Message-ID: <YgpEvZW1dkbivQL2@redhat.com> (raw)
In-Reply-To: <20220214115917.1679568-1-marcandre.lureau@redhat.com>
On Mon, Feb 14, 2022 at 03:59:17PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> The same info may be used to update the clipboard, and may be freed
> before being ref'ed again.
Ewww, subtle.
> Fixes: 70a54b01693ed ("ui: avoid compiler warnings from unused clipboard info variable")
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> ui/clipboard.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/ui/clipboard.c b/ui/clipboard.c
> index 5f15cf853d07..9079ef829b51 100644
> --- a/ui/clipboard.c
> +++ b/ui/clipboard.c
> @@ -66,8 +66,10 @@ void qemu_clipboard_update(QemuClipboardInfo *info)
>
> notifier_list_notify(&clipboard_notifiers, ¬ify);
>
> - qemu_clipboard_info_unref(cbinfo[info->selection]);
> - cbinfo[info->selection] = qemu_clipboard_info_ref(info);
> + if (cbinfo[info->selection] != info) {
> + qemu_clipboard_info_unref(cbinfo[info->selection]);
> + cbinfo[info->selection] = qemu_clipboard_info_ref(info);
> + }
> }
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Regards,
Daniel
--
|: 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 :|
prev parent reply other threads:[~2022-02-14 12:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 11:59 [PATCH] ui/clipboard: fix use-after-free regression marcandre.lureau
2022-02-14 12:02 ` Daniel P. Berrangé [this message]
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=YgpEvZW1dkbivQL2@redhat.com \
--to=berrange@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--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).