Ignore:
Timestamp:
2017-09-30T06:29:42Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
300f4c4
Parents:
d076f16 (diff), 6636fb19 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge support for capabilities from lp:~jakub/helenos/caps

This commit introduces capabilities as task-local names for references to kernel
objects. Kernel objects are reference-counted wrappers for a select group of
objects allocated in and by the kernel that can be made accessible to userspace
in a controlled way via integer handles.

So far, a kernel object encapsulates either an irq_t or a phone_t.

Support for the former lead to the removal of kernel-assigned devnos and
unsecure deregistration of IRQs in which a random task was able to unregister
some other task's IRQ.

File:
1 edited

Legend:

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

    rd076f16 r91b60499  
    11/*
    22 * Copyright (c) 2006 Ondrej Palkovsky
    3  * Copyright (c) 2012 Jakub Jermar 
     3 * Copyright (c) 2012 Jakub Jermar
    44 * All rights reserved.
    55 *
     
    4242static int request_process(call_t *call, answerbox_t *box)
    4343{
    44         int phoneid = phone_alloc(TASK);
     44        cap_handle_t phone_handle = phone_alloc(TASK);
    4545
    46         IPC_SET_ARG5(call->data, phoneid);
     46        IPC_SET_ARG5(call->data, phone_handle);
    4747       
    4848        return EOK;
     
    5151static int answer_cleanup(call_t *answer, ipc_data_t *olddata)
    5252{
    53         int phoneid = (int) IPC_GET_ARG5(*olddata);
     53        cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
    5454
    55         if (phoneid >= 0)
    56                 phone_dealloc(phoneid);
     55        if (phone_handle >= 0)
     56                phone_dealloc(phone_handle);
    5757
    5858        return EOK;
     
    6161static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
    6262{
    63         int phoneid = (int) IPC_GET_ARG5(*olddata);
     63        cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata);
    6464
    6565        if (IPC_GET_RETVAL(answer->data) != EOK) {
    6666                /* The connection was not accepted */
    6767                answer_cleanup(answer, olddata);
    68         } else if (phoneid >= 0) {
     68        } else if (phone_handle >= 0) {
    6969                /* The connection was accepted */
    70                 if (phone_connect(phoneid, &answer->sender->answerbox)) {
    71                         /* Set 'phone hash' as arg5 of response */
     70                if (phone_connect(phone_handle, &answer->sender->answerbox)) {
     71                        /* Set 'phone hash' as ARG5 of response */
     72                        kobject_t *phone_obj = kobject_get(TASK, phone_handle,
     73                            KOBJECT_TYPE_PHONE);
    7274                        IPC_SET_ARG5(answer->data,
    73                             (sysarg_t) &TASK->phones[phoneid]);
     75                            (sysarg_t) phone_obj->phone);
     76                        kobject_put(phone_obj);
    7477                } else {
    7578                        /* The answerbox is shutting down. */
Note: See TracChangeset for help on using the changeset viewer.