[libvirt] [v0.9.12-maint 06/11] rpc: Fix crash on error paths of message dispatching

This patch resolves CVE-2013-0170: https://bugzilla.redhat.com/show_bug.cgi?id=893450 When reading and dispatching of a message failed the message was freed but wasn't removed from the message queue. After that when the connection was about to be closed the pointer for the message was still present in the queue and it was passed to virNetMessageFree which tried to call the callback function from an uninitialized pointer. This patch removes the message from the queue before it's freed. * rpc/virnetserverclient.c: virNetServerClientDispatchRead: - avoid use after free of RPC messages (cherry picked from commit 46532e3e8ed5f5a736a02f67d6c805492f9ca720) --- src/rpc/virnetserverclient.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 67600fd..3838136 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -840,6 +840,7 @@ readmore: /* Decode the header so we can use it for routing decisions */ if (virNetMessageDecodeHeader(msg) < 0) { + virNetMessageQueueServe(&client->rx); virNetMessageFree(msg); client->wantClose = true; return; @@ -849,6 +850,7 @@ readmore: * file descriptors */ if (msg->header.type == VIR_NET_CALL_WITH_FDS && virNetMessageDecodeNumFDs(msg) < 0) { + virNetMessageQueueServe(&client->rx); virNetMessageFree(msg); client->wantClose = true; return; /* Error */ @@ -858,6 +860,7 @@ readmore: for (i = msg->donefds ; i < msg->nfds ; i++) { int rv; if ((rv = virNetSocketRecvFD(client->sock, &(msg->fds[i]))) < 0) { + virNetMessageQueueServe(&client->rx); virNetMessageFree(msg); client->wantClose = true; return; -- 1.8.4.rc3

On 09/11/13 16:00, Peter Krempa wrote: ^^^^^^^^^^^^ Guido, you should recofigure your git-send-email or other mailer so that it sends patches in your name with a separate "From:" line in the body. This now looks as if I've sent the mail which is not the case. Peter
This patch resolves CVE-2013-0170: https://bugzilla.redhat.com/show_bug.cgi?id=893450
When reading and dispatching of a message failed the message was freed but wasn't removed from the message queue.
After that when the connection was about to be closed the pointer for the message was still present in the queue and it was passed to virNetMessageFree which tried to call the callback function from an uninitialized pointer.
This patch removes the message from the queue before it's freed.
* rpc/virnetserverclient.c: virNetServerClientDispatchRead: - avoid use after free of RPC messages
(cherry picked from commit 46532e3e8ed5f5a736a02f67d6c805492f9ca720) ---

On 09/11/2013 08:51 AM, Peter Krempa wrote:
On 09/11/13 16:00, Peter Krempa wrote: ^^^^^^^^^^^^
Guido, you should recofigure your git-send-email or other mailer so that it sends patches in your name with a separate "From:" line in the body. This now looks as if I've sent the mail which is not the case.
I think the setting you are looking for is: git config sendemail.envelopesender Also, double check your settings for threading. Your cover letter came as id <20130911135856.GA21921@bogon.sigxcpu.org>, while your patches were sent as in-reply-to: <cover.1378907654.git.agx@sigxcpu.org>; since they don't match, they weren't actually threaded to the cover letter. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Peter Krempa