Changeset d088616 in mainline for kernel/generic/src/cap/cap.c


Ignore:
Timestamp:
2017-10-28T08:49:42Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d470ec8
Parents:
9b642f92
Message:

Provide locked versions of cap_unpublish() and cap_free()

This is necessary so that capabilities can be unpublished and freed from a
caps_apply_to_kobject_type() callback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/cap/cap.c

    r9b642f92 rd088616  
    8484
    8585static slab_cache_t *cap_slab;
    86 
    87 static kobject_t *cap_unpublish_locked(task_t *, cap_handle_t, kobject_type_t);
    8886
    8987static size_t caps_hash(const ht_link_t *item)
     
    320318}
    321319
    322 static kobject_t *
     320/** @copydoc cap_unpublish()
     321 *
     322 * Can only be called internally by the capability subsytem or from a
     323 * caps_apply_to_kobject_type() callback.
     324 */
     325kobject_t *
    323326cap_unpublish_locked(task_t *task, cap_handle_t handle, kobject_type_t type)
    324327{
     
    361364}
    362365
    363 /** Free allocated capability
    364  *
    365  * @param task    Task in which to free the capability.
    366  * @param handle  Capability handle.
    367  */
    368 void cap_free(task_t *task, cap_handle_t handle)
     366/** @copydoc cap_free()
     367 *
     368 * Can only be called internally by the capability subsytem or from a
     369 * caps_apply_to_kobject_type() callback.
     370 */
     371void cap_free_locked(task_t *task, cap_handle_t handle)
    369372{
    370373        assert(handle >= 0);
    371374        assert(handle < MAX_CAPS);
    372375
    373         mutex_lock(&task->cap_info->lock);
    374376        cap_t *cap = cap_get(task, handle, CAP_STATE_ALLOCATED);
    375377
     
    379381        ra_free(task->cap_info->handles, handle, 1);
    380382        slab_free(cap_slab, cap);
     383}
     384
     385/** Free allocated capability
     386 *
     387 * @param task    Task in which to free the capability.
     388 * @param handle  Capability handle.
     389 */
     390void cap_free(task_t *task, cap_handle_t handle)
     391{
     392        mutex_lock(&task->cap_info->lock);
     393        cap_free_locked(task, handle);
    381394        mutex_unlock(&task->cap_info->lock);
    382395}
Note: See TracChangeset for help on using the changeset viewer.