Changeset 719a208 in mainline for kernel/generic/src
- Timestamp:
- 2017-05-30T05:59:09Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2460a50
- Parents:
- 456c086
- Location:
- kernel/generic/src
- Files:
-
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
r456c086 r719a208 42 42 #include <ddi/ddi.h> 43 43 #include <proc/task.h> 44 #include <security/ cap.h>44 #include <security/perm.h> 45 45 #include <mm/frame.h> 46 46 #include <mm/as.h> … … 96 96 * 97 97 * @return EOK on success. 98 * @return EPERM if the caller lacks capabilities to use this syscall.98 * @return EPERM if the caller lacks permissions to use this syscall. 99 99 * @return EBADMEM if phys is not page aligned. 100 100 * @return ENOENT if there is no task matching the specified ID or … … 116 116 */ 117 117 bool priv = 118 (( cap_get(TASK) & CAP_MEM_MANAGER) == CAP_MEM_MANAGER);118 ((perm_get(TASK) & PERM_MEM_MANAGER) == PERM_MEM_MANAGER); 119 119 120 120 mem_backend_data_t backend_data; … … 260 260 * @param size Size of the enabled I/O space. 261 261 * 262 * @return 0 on success, EPERM if the caller lacks capabilities to use this262 * @return 0 on success, EPERM if the caller lacks permissions to use this 263 263 * syscall, ENOENT if there is no task matching the specified ID. 264 264 * … … 269 269 * Make sure the caller is authorised to make this syscall. 270 270 */ 271 cap_t caps = cap_get(TASK);272 if (!( caps & CAP_IO_MANAGER))271 perm_t perms = perm_get(TASK); 272 if (!(perms & PERM_IO_MANAGER)) 273 273 return EPERM; 274 274 … … 301 301 * @param size Size of the enabled I/O space. 302 302 * 303 * @return 0 on success, EPERM if the caller lacks capabilities to use this303 * @return 0 on success, EPERM if the caller lacks permissions to use this 304 304 * syscall, ENOENT if there is no task matching the specified ID. 305 305 * … … 310 310 * Make sure the caller is authorised to make this syscall. 311 311 */ 312 cap_t caps = cap_get(TASK);313 if (!( caps & CAP_IO_MANAGER))312 perm_t perms = perm_get(TASK); 313 if (!(perms & PERM_IO_MANAGER)) 314 314 return EPERM; 315 315 -
kernel/generic/src/ipc/sysipc.c
r456c086 r719a208 48 48 #include <arch/interrupt.h> 49 49 #include <syscall/copy.h> 50 #include <security/ cap.h>50 #include <security/perm.h> 51 51 #include <console/console.h> 52 52 #include <print.h> … … 811 811 irq_code_t *ucode) 812 812 { 813 if (!( cap_get(TASK) & CAP_IRQ_REG))813 if (!(perm_get(TASK) & PERM_IRQ_REG)) 814 814 return EPERM; 815 815 … … 827 827 sysarg_t sys_ipc_irq_unsubscribe(inr_t inr, devno_t devno) 828 828 { 829 if (!( cap_get(TASK) & CAP_IRQ_REG))829 if (!(perm_get(TASK) & PERM_IRQ_REG)) 830 830 return EPERM; 831 831 -
kernel/generic/src/main/kinit.c
r456c086 r719a208 64 64 #include <interrupt.h> 65 65 #include <console/kconsole.h> 66 #include <security/ cap.h>66 #include <security/perm.h> 67 67 #include <lib/rd.h> 68 68 #include <ipc/ipc.h> … … 259 259 if (programs[i].task != NULL) { 260 260 /* 261 * Set capabilities to init userspace tasks.261 * Set permissions to init userspace tasks. 262 262 */ 263 cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER | 264 CAP_IO_MANAGER | CAP_IRQ_REG); 263 perm_set(programs[i].task, 264 PERM_PERM | PERM_MEM_MANAGER | 265 PERM_IO_MANAGER | PERM_IRQ_REG); 265 266 266 267 if (!ipc_phone_0) { -
kernel/generic/src/proc/program.c
r456c086 r719a208 46 46 #include <ipc/ipc.h> 47 47 #include <ipc/ipcrsc.h> 48 #include <security/ cap.h>48 #include <security/perm.h> 49 49 #include <lib/elf_load.h> 50 50 #include <errno.h> … … 244 244 return rc; 245 245 246 // FIXME: control the capabilities247 cap_set(prg.task, cap_get(TASK));246 // FIXME: control the permissions 247 perm_set(prg.task, perm_get(TASK)); 248 248 program_ready(&prg); 249 249 -
kernel/generic/src/proc/task.c
r456c086 r719a208 203 203 204 204 task->container = CONTAINER; 205 task-> capabilities = 0;205 task->perms = 0; 206 206 task->ucycles = 0; 207 207 task->kcycles = 0; -
kernel/generic/src/security/perm.c
r456c086 r719a208 32 32 33 33 /** 34 * @file cap.c35 * @brief Capabilities control.36 * 37 * @see cap.h38 */ 39 40 #include <security/ cap.h>34 * @file perm.c 35 * @brief Task permissions control. 36 * 37 * @see perm.h 38 */ 39 40 #include <security/perm.h> 41 41 #include <proc/task.h> 42 42 #include <synch/spinlock.h> … … 45 45 #include <errno.h> 46 46 47 /** Set capabilities.48 * 49 * @param task Task whose capabilities are to be changed.50 * @param caps New set of capabilities.51 * 52 */ 53 void cap_set(task_t *task, cap_t caps)47 /** Set permissions. 48 * 49 * @param task Task whose permissions are to be changed. 50 * @param perms New set of permissions. 51 * 52 */ 53 void perm_set(task_t *task, perm_t perms) 54 54 { 55 55 irq_spinlock_lock(&task->lock, true); 56 task-> capabilities = caps;56 task->perms = perms; 57 57 irq_spinlock_unlock(&task->lock, true); 58 58 } 59 59 60 /** Get capabilities.61 * 62 * @param task Task whose capabilities are to be returned.63 * 64 * @return Task's capabilities.65 * 66 */ 67 cap_t cap_get(task_t *task)60 /** Get permissions. 61 * 62 * @param task Task whose permissions are to be returned. 63 * 64 * @return Task's permissions. 65 * 66 */ 67 perm_t perm_get(task_t *task) 68 68 { 69 69 irq_spinlock_lock(&task->lock, true); 70 cap_t caps = task->capabilities;70 perm_t perms = task->perms; 71 71 irq_spinlock_unlock(&task->lock, true); 72 72 73 return caps;74 } 75 76 /** Grant capabilities to a task.77 * 78 * The calling task must have the CAP_CAP capability.79 * 80 * @param taskid Destination task ID. 81 * @param caps Capabilities to grant.82 * 83 * @return Zero on success or an error code from @ref errno.h. 84 * 85 */ 86 static sysarg_t cap_grant(task_id_t taskid, cap_t caps)87 { 88 if (!( cap_get(TASK) & CAP_CAP))73 return perms; 74 } 75 76 /** Grant permissions to a task. 77 * 78 * The calling task must have the PERM_PERM permission. 79 * 80 * @param taskid Destination task ID. 81 * @param perms Permissions to grant. 82 * 83 * @return Zero on success or an error code from @ref errno.h. 84 * 85 */ 86 static sysarg_t perm_grant(task_id_t taskid, perm_t perms) 87 { 88 if (!(perm_get(TASK) & PERM_PERM)) 89 89 return (sysarg_t) EPERM; 90 90 … … 98 98 99 99 irq_spinlock_lock(&task->lock, false); 100 task-> capabilities |= caps;100 task->perms |= perms; 101 101 irq_spinlock_unlock(&task->lock, false); 102 102 … … 105 105 } 106 106 107 /** Revoke capabilities from a task.108 * 109 * The calling task must have the CAP_CAP capabilityor the caller must110 * attempt to revoke capabilities from itself.111 * 112 * @param taskid Destination task ID. 113 * @param caps Capabilities to revoke.114 * 115 * @return Zero on success or an error code from @ref errno.h. 116 * 117 */ 118 static sysarg_t cap_revoke(task_id_t taskid, cap_t caps)107 /** Revoke permissions from a task. 108 * 109 * The calling task must have the PERM_PERM permission or the caller must 110 * attempt to revoke permissions from itself. 111 * 112 * @param taskid Destination task ID. 113 * @param perms Permissions to revoke. 114 * 115 * @return Zero on success or an error code from @ref errno.h. 116 * 117 */ 118 static sysarg_t perm_revoke(task_id_t taskid, perm_t perms) 119 119 { 120 120 irq_spinlock_lock(&tasks_lock, true); … … 127 127 128 128 /* 129 * Revoking capabilities is different from granting them in that130 * a task can revoke capabilities from itself even if it131 * doesn't have CAP_CAP.129 * Revoking permissions is different from granting them in that 130 * a task can revoke permissions from itself even if it 131 * doesn't have PERM_PERM. 132 132 */ 133 133 irq_spinlock_unlock(&TASK->lock, false); 134 134 135 if ((!(TASK-> capabilities & CAP_CAP)) || (task != TASK)) {135 if ((!(TASK->perms & PERM_PERM)) || (task != TASK)) { 136 136 irq_spinlock_unlock(&TASK->lock, false); 137 137 irq_spinlock_unlock(&tasks_lock, true); … … 139 139 } 140 140 141 task-> capabilities &= ~caps;141 task->perms &= ~perms; 142 142 irq_spinlock_unlock(&TASK->lock, false); 143 143 … … 148 148 #ifdef __32_BITS__ 149 149 150 /** Grant capabilities to a task (32 bits)151 * 152 * The calling task must have the CAP_CAP capability.150 /** Grant permissions to a task (32 bits) 151 * 152 * The calling task must have the PERM_PERM permission. 153 153 * 154 154 * @param uspace_taskid User-space pointer to destination task ID. 155 * @param caps Capabilities to grant.156 * 157 * @return Zero on success or an error code from @ref errno.h. 158 * 159 */ 160 sysarg_t sys_ cap_grant(sysarg64_t *uspace_taskid, cap_t caps)155 * @param perms Permissions to grant. 156 * 157 * @return Zero on success or an error code from @ref errno.h. 158 * 159 */ 160 sysarg_t sys_perm_grant(sysarg64_t *uspace_taskid, perm_t perms) 161 161 { 162 162 sysarg64_t taskid; … … 165 165 return (sysarg_t) rc; 166 166 167 return cap_grant((task_id_t) taskid, caps);168 } 169 170 /** Revoke capabilities from a task (32 bits)171 * 172 * The calling task must have the CAP_CAP capabilityor the caller must173 * attempt to revoke capabilities from itself.167 return perm_grant((task_id_t) taskid, perms); 168 } 169 170 /** Revoke permissions from a task (32 bits) 171 * 172 * The calling task must have the PERM_PERM permission or the caller must 173 * attempt to revoke permissions from itself. 174 174 * 175 175 * @param uspace_taskid User-space pointer to destination task ID. 176 * @param caps Capabilities to revoke.177 * 178 * @return Zero on success or an error code from @ref errno.h. 179 * 180 */ 181 sysarg_t sys_ cap_revoke(sysarg64_t *uspace_taskid, cap_t caps)176 * @param perms Perms to revoke. 177 * 178 * @return Zero on success or an error code from @ref errno.h. 179 * 180 */ 181 sysarg_t sys_perm_revoke(sysarg64_t *uspace_taskid, perm_t perms) 182 182 { 183 183 sysarg64_t taskid; … … 186 186 return (sysarg_t) rc; 187 187 188 return cap_revoke((task_id_t) taskid, caps);188 return perm_revoke((task_id_t) taskid, perms); 189 189 } 190 190 … … 193 193 #ifdef __64_BITS__ 194 194 195 /** Grant capabilities to a task (64 bits)196 * 197 * The calling task must have the CAP_CAP capability.198 * 199 * @param taskid Destination task ID. 200 * @param caps Capabilities to grant.201 * 202 * @return Zero on success or an error code from @ref errno.h. 203 * 204 */ 205 sysarg_t sys_ cap_grant(sysarg_t taskid, cap_t caps)206 { 207 return cap_grant((task_id_t) taskid, caps);208 } 209 210 /** Revoke capabilities from a task (64 bits)211 * 212 * The calling task must have the CAP_CAP capabilityor the caller must213 * attempt to revoke capabilities from itself.214 * 215 * @param taskid Destination task ID. 216 * @param caps Capabilities to revoke.217 * 218 * @return Zero on success or an error code from @ref errno.h. 219 * 220 */ 221 sysarg_t sys_ cap_revoke(sysarg_t taskid, cap_t caps)222 { 223 return cap_revoke((task_id_t) taskid, caps);195 /** Grant permissions to a task (64 bits) 196 * 197 * The calling task must have the PERM_PERM permission. 198 * 199 * @param taskid Destination task ID. 200 * @param perms Permissions to grant. 201 * 202 * @return Zero on success or an error code from @ref errno.h. 203 * 204 */ 205 sysarg_t sys_perm_grant(sysarg_t taskid, perm_t perms) 206 { 207 return perm_grant((task_id_t) taskid, perms); 208 } 209 210 /** Revoke permissions from a task (64 bits) 211 * 212 * The calling task must have the PERM_PERM permission or the caller must 213 * attempt to revoke permissions from itself. 214 * 215 * @param taskid Destination task ID. 216 * @param perms Permissions to revoke. 217 * 218 * @return Zero on success or an error code from @ref errno.h. 219 * 220 */ 221 sysarg_t sys_perm_revoke(sysarg_t taskid, perm_t perms) 222 { 223 return perm_revoke((task_id_t) taskid, perms); 224 224 } 225 225 -
kernel/generic/src/syscall/syscall.c
r456c086 r719a208 53 53 #include <ddi/ddi.h> 54 54 #include <ipc/event.h> 55 #include <security/ cap.h>55 #include <security/perm.h> 56 56 #include <sysinfo/sysinfo.h> 57 57 #include <console/console.h> … … 171 171 (syshandler_t) sys_ipc_event_unmask, 172 172 173 /* Capabilitiesrelated syscalls. */174 (syshandler_t) sys_ cap_grant,175 (syshandler_t) sys_ cap_revoke,173 /* Permission related syscalls. */ 174 (syshandler_t) sys_perm_grant, 175 (syshandler_t) sys_perm_revoke, 176 176 177 177 /* DDI related syscalls. */
Note:
See TracChangeset
for help on using the changeset viewer.