Changeset 2569ec90 in mainline for generic/src/security/cap.c


Ignore:
Timestamp:
2006-06-05T18:15:30Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b65caba1
Parents:
31e8ddd
Message:

In task_kill(), remove the task from the tasks_btree before proceeding.
Thus, when the kernel finds the task in the tasks_btree and locks it before
releasing tasks_lock, it is guaranteed that the task will not be destroyed
until the lock is held. If the kernel needs to unlock the task, do some operation
and lock it again, it should increase its refcount before doing so. In that case,
when releasing the lock, it must decrement the refcount and if it reaches
zero, it must call task_destroy().

File:
1 edited

Legend:

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

    r31e8ddd r2569ec90  
    113113                return (__native) ENOENT;
    114114        }
     115       
     116        spinlock_lock(&t->lock);
     117        cap_set(t, cap_get(t) | caps);
     118        spinlock_unlock(&t->lock);
     119       
    115120        spinlock_unlock(&tasks_lock);
    116121       
    117         cap_set(t, cap_get(t) | caps);
     122
    118123       
    119124        interrupts_restore(ipl);       
     
    150155                return (__native) ENOENT;
    151156        }
    152         spinlock_unlock(&tasks_lock);
    153157
    154158        /*
     
    158162         */
    159163        if (!(cap_get(TASK) & CAP_CAP) || !(t == TASK)) {
     164                spinlock_unlock(&tasks_lock);
    160165                interrupts_restore(ipl);
    161166                return (__native) EPERM;
    162167        }
     168       
     169        spinlock_lock(&t->lock);
     170        cap_set(t, cap_get(t) & ~caps);
     171        spinlock_unlock(&t->lock);
    163172
    164         cap_set(t, cap_get(t) & ~caps);
    165        
     173        spinlock_unlock(&tasks_lock);
     174
    166175        interrupts_restore(ipl);
    167176        return 0;
Note: See TracChangeset for help on using the changeset viewer.