Changeset f2cb80a in mainline for kernel/generic/src/security/perm.c


Ignore:
Timestamp:
2024-02-23T17:57:23Z (3 months ago)
Author:
GitHub <noreply@…>
Children:
192019f
Parents:
86f862c (diff), 90ba06c (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.
git-author:
boba-buba <120932204+boba-buba@…> (2024-02-23 17:57:23)
git-committer:
GitHub <noreply@…> (2024-02-23 17:57:23)
Message:

Merge branch 'HelenOS:master' into topic/packet-capture

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/security/perm.c

    r86f862c rf2cb80a  
    8989                return EPERM;
    9090
    91         irq_spinlock_lock(&tasks_lock, true);
    9291        task_t *task = task_find_by_id(taskid);
    93 
    94         if ((!task) || (!container_check(CONTAINER, task->container))) {
    95                 irq_spinlock_unlock(&tasks_lock, true);
     92        if (!task)
    9693                return ENOENT;
     94
     95        errno_t rc = ENOENT;
     96
     97        irq_spinlock_lock(&task->lock, true);
     98        if (container_check(CONTAINER, task->container)) {
     99                task->perms |= perms;
     100                rc = EOK;
    97101        }
    98 
    99         irq_spinlock_lock(&task->lock, false);
    100         task->perms |= perms;
    101         irq_spinlock_unlock(&task->lock, false);
    102 
    103         irq_spinlock_unlock(&tasks_lock, true);
    104         return EOK;
     102        irq_spinlock_unlock(&task->lock, true);
     103
     104        task_release(task);
     105        return rc;
    105106}
    106107
     
    118119static errno_t perm_revoke(task_id_t taskid, perm_t perms)
    119120{
    120         irq_spinlock_lock(&tasks_lock, true);
    121 
    122121        task_t *task = task_find_by_id(taskid);
    123         if ((!task) || (!container_check(CONTAINER, task->container))) {
    124                 irq_spinlock_unlock(&tasks_lock, true);
     122        if (!task)
    125123                return ENOENT;
    126         }
    127124
    128125        /*
     
    131128         * doesn't have PERM_PERM.
    132129         */
    133         irq_spinlock_lock(&TASK->lock, false);
    134 
    135         if ((!(TASK->perms & PERM_PERM)) || (task != TASK)) {
    136                 irq_spinlock_unlock(&TASK->lock, false);
    137                 irq_spinlock_unlock(&tasks_lock, true);
     130        if (task != TASK && !(perm_get(TASK) & PERM_PERM)) {
     131                task_release(task);
    138132                return EPERM;
    139133        }
    140134
    141         task->perms &= ~perms;
    142         irq_spinlock_unlock(&TASK->lock, false);
    143 
    144         irq_spinlock_unlock(&tasks_lock, true);
    145         return EOK;
     135        errno_t rc = ENOENT;
     136
     137        irq_spinlock_lock(&task->lock, true);
     138        if (container_check(CONTAINER, task->container)) {
     139                task->perms &= ~perms;
     140                rc = EOK;
     141        }
     142        irq_spinlock_unlock(&task->lock, true);
     143
     144        task_release(task);
     145        return rc;
    146146}
    147147
Note: See TracChangeset for help on using the changeset viewer.