Changeset e39d7b8 in mainline for kernel/generic/src/ipc/sysipc.c


Ignore:
Timestamp:
2019-06-17T15:12:44Z (5 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
64b7854
Parents:
ef705e14
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-16 17:59:34)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-17 15:12:44)
Message:

Change type of uspace pointers in kernel from pointer type to numeric type

From kernel's perspective, userspace addresses are not valid pointers,
and can only be used in calls to copy_to/from_uspace().
Therefore, we change the type of those arguments and variables to
uspace_addr_t which is an alias for sysarg_t.

This allows the compiler to catch accidental direct accesses to
userspace addresses.

Additionally, to avoid losing the type information in code,
a macro uspace_ptr(type) is used that translates to uspace_addr_t.
I makes no functional difference, but allows keeping the type information
in code in case we implement some sort of static checking for it in the future.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/sysipc.c

    ref705e14 re39d7b8  
    419419 *
    420420 */
    421 sys_errno_t sys_ipc_call_async_slow(cap_phone_handle_t handle, ipc_data_t *data,
     421sys_errno_t sys_ipc_call_async_slow(cap_phone_handle_t handle, uspace_ptr(ipc_data_t) data,
    422422    sysarg_t label)
    423423{
     
    437437        }
    438438
    439         errno_t rc = copy_from_uspace(&call->data.args, &data->args,
     439        errno_t rc = copy_from_uspace(&call->data.args, data + offsetof(ipc_data_t, args),
    440440            sizeof(call->data.args));
    441441        if (rc != EOK) {
     
    623623 */
    624624sys_errno_t sys_ipc_forward_slow(cap_call_handle_t chandle,
    625     cap_phone_handle_t phandle, ipc_data_t *data, unsigned int mode)
     625    cap_phone_handle_t phandle, uspace_ptr(ipc_data_t) data, unsigned int mode)
    626626{
    627627        ipc_data_t newdata;
    628         errno_t rc = copy_from_uspace(&newdata.args, &data->args,
     628        errno_t rc = copy_from_uspace(&newdata.args, data + offsetof(ipc_data_t, args),
    629629            sizeof(newdata.args));
    630630        if (rc != EOK)
     
    700700 *
    701701 */
    702 sys_errno_t sys_ipc_answer_slow(cap_call_handle_t chandle, ipc_data_t *data)
     702sys_errno_t sys_ipc_answer_slow(cap_call_handle_t chandle, uspace_ptr(ipc_data_t) data)
    703703{
    704704        kobject_t *kobj = cap_unpublish(TASK, chandle, KOBJECT_TYPE_CALL);
     
    718718                saved = false;
    719719
    720         errno_t rc = copy_from_uspace(&call->data.args, &data->args,
     720        errno_t rc = copy_from_uspace(&call->data.args, data + offsetof(ipc_data_t, args),
    721721            sizeof(call->data.args));
    722722        if (rc != EOK) {
     
    766766 * @return An error code on error.
    767767 */
    768 sys_errno_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
     768sys_errno_t sys_ipc_wait_for_call(uspace_ptr(ipc_data_t) calldata, uint32_t usec,
    769769    unsigned int flags)
    770770{
     
    888888 */
    889889sys_errno_t sys_ipc_irq_subscribe(inr_t inr, sysarg_t imethod,
    890     irq_code_t *ucode, cap_irq_handle_t *uspace_handle)
     890    uspace_ptr(irq_code_t) ucode, uspace_ptr(cap_irq_handle_t) uspace_handle)
    891891{
    892892        if (!(perm_get(TASK) & PERM_IRQ_REG))
     
    918918 *
    919919 */
    920 sys_errno_t sys_ipc_connect_kbox(task_id_t *uspace_taskid,
    921     cap_phone_handle_t *uspace_phone)
     920sys_errno_t sys_ipc_connect_kbox(uspace_ptr(task_id_t) uspace_taskid,
     921    uspace_ptr(cap_phone_handle_t) uspace_phone)
    922922{
    923923#ifdef CONFIG_UDEBUG
Note: See TracChangeset for help on using the changeset viewer.