Commit aa262928 authored by Halil Pasic's avatar Halil Pasic Committed by Michael S. Tsirkin
Browse files

event_notifier: prevent accidental use after close



Let's set the handles to the underlying facilities to their extremal
value so no accidental misuse can happen, and to make it obvious that the
notifier is dysfunctional. E.g. if we just close an fd but do not touch
the int holding the fd eventually a read/write could succeed again when
the fd gets reused, and corrupt the file addressed by the fd.

Signed-off-by: default avatarHalil Pasic <pasic@linux.vnet.ibm.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent df904636
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -81,8 +81,10 @@ void event_notifier_cleanup(EventNotifier *e)
{
    if (e->rfd != e->wfd) {
        close(e->rfd);
        e->rfd = -1;
    }
    close(e->wfd);
    e->wfd = -1;
}

int event_notifier_get_fd(const EventNotifier *e)
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ int event_notifier_init(EventNotifier *e, int active)
void event_notifier_cleanup(EventNotifier *e)
{
    CloseHandle(e->event);
    e->event = NULL;
}

HANDLE event_notifier_get_handle(EventNotifier *e)