Ignore:
Timestamp:
2011-12-16T18:27:50Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e1c6dde9
Parents:
0edaf0f6
Message:

Fix serious race in packet_return().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/generic/packet_remote.c

    r0edaf0f6 rab9378b4  
    3838#include <async.h>
    3939#include <errno.h>
     40#include <fibril_synch.h>
    4041#include <ipc/packet.h>
    4142#include <sys/mman.h>
     
    4647#include <net/packet.h>
    4748#include <net/packet_header.h>
     49
     50static FIBRIL_MUTEX_INITIALIZE(packet_return_lock);
    4851
    4952/** Obtain the packet from the packet server as the shared memory block.
     
    6669    packet_id_t packet_id, size_t size)
    6770{
     71        /*
     72         * Prevent racing for address space with other invocations
     73         * of packet_return().
     74         *
     75         * XXX This of course does not prevent us racing with other
     76         * competitors for address space mapping.
     77         */
     78        fibril_mutex_lock(&packet_return_lock);
    6879        *packet = (packet_t *) as_get_mappable_page(size);
    6980       
     
    7990        if (rc != EOK) {
    8091                munmap(*packet, size);
     92                fibril_mutex_unlock(&packet_return_lock);
    8193                return rc;
    8294        }
     
    8597        if (rc != EOK) {
    8698                munmap(*packet, size);
     99                fibril_mutex_unlock(&packet_return_lock);
    87100                return rc;
    88101        }
    89102       
     103        fibril_mutex_unlock(&packet_return_lock);
    90104        return result;
    91105}
Note: See TracChangeset for help on using the changeset viewer.