Ignore:
Timestamp:
2018-03-13T18:01:48Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
87e7a18
Parents:
50dd854
git-author:
Jakub Jermar <jakub@…> (2018-03-10 18:18:12)
git-committer:
Jakub Jermar <jakub@…> (2018-03-13 18:01:48)
Message:

Allow phone_alloc to not publish the capability

This makes it possible and race-free to defer publishing the new
capability until the phone object is connected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ops/conctmeto.c

    r50dd854 r334c103  
    4242static errno_t request_preprocess(call_t *call, phone_t *phone)
    4343{
     44        /*
     45         * Create the new phone and capability, but don't publish them yet.
     46         * That will be done once the phone is connected.
     47         */
    4448        cap_handle_t phone_handle;
    45         errno_t rc = phone_alloc(TASK, &phone_handle);
     49        kobject_t *phone_obj;
     50        errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj);
    4651        if (rc != EOK) {
    4752                call->priv = -1;
    4853                return rc;
    49         }
    50 
    51         /*
    52          * The capability is now published, but the phone is not connected yet.
    53          * The user cannot use it to send anything over it, in fact the
    54          * userspace can only unpublish and free the capability at this point.
    55          *
    56          * We now proceed to test the capability is still there. We don't care
    57          * if the user destroyed the old one and recreated a new published one
    58          * of the same type under the same handle.
    59          *
    60          * If the capability is in place we temporarily unpublish it to make
    61          * sure the user cannot fiddle with it while we are connecting.
    62          */
    63 
    64         kobject_t *phone_obj = cap_unpublish(TASK, phone_handle,
    65             KOBJECT_TYPE_PHONE);
    66         if (!phone_obj) {
    67                 /*
    68                  * Another thread of the same task can destroy the new
    69                  * capability before we manage to get a reference from it.
    70                  */
    71                 call->priv = -1;
    72                 return ENOENT;
    7354        }
    7455
Note: See TracChangeset for help on using the changeset viewer.