lkml.org 
[lkml]   [2017]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 12/13] xen/pvcalls: implement release command
From
Date

>> + */
>> + map->active.ring->in_error = -EBADF;
>> + wake_up_interruptible(&map->active.inflight_conn_req);
>> +
>> + /*
>> + * Wait until there are no more waiters on the mutexes.
>> + * We know that no new waiters can be added because sk_send_head
>> + * is set to NULL -- we only need to wait for the existing
>> + * waiters to return.
>> + */
>> + while (!mutex_trylock(&map->active.in_mutex) ||
>> + !mutex_trylock(&map->active.out_mutex))
>> + cpu_relax();
>
> What if you manage to grab the locks before waiters get to run? for
> example, in recvmsg:
>
> while (!(flags & MSG_DONTWAIT) && !pvcalls_front_read_todo(map)) {
> wait_event_interruptible(map->active.inflight_conn_req,
> pvcalls_front_read_todo(map));
> }
> ret = __read_ring(map->active.ring, &map->active.data,
> &msg->msg_iter, len, flags);
>
> map will be freed (by pvcalls_front_free_map() below) before __read_ring
> is passed the just-freed ring.

Actually, since you don't drop the locks I am not sure recvmsg side will
even get there.

-boris

>
>
>> +
>> + pvcalls_front_free_map(bedata, map);
>> + kfree(map);
>
> -boris
>
>

\
 
 \ /
  Last update: 2017-09-23 00:49    [W:0.061 / U:4.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site