Changes in kernel/generic/src/ddi/ddi.c [d7533c7:77429d3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
rd7533c7 r77429d3 104 104 { 105 105 ASSERT(TASK); 106 107 if ((pf % FRAME_SIZE) != 0) 108 return EBADMEM; 109 110 if ((vp % PAGE_SIZE) != 0) 111 return EBADMEM; 112 113 /* 114 * Unprivileged tasks are only allowed to map pareas 115 * which are explicitly marked as such. 116 */ 117 bool priv = 118 ((cap_get(TASK) & CAP_MEM_MANAGER) == CAP_MEM_MANAGER); 106 ASSERT((pf % FRAME_SIZE) == 0); 107 ASSERT((vp % PAGE_SIZE) == 0); 108 109 /* 110 * Make sure the caller is authorised to make this syscall. 111 */ 112 cap_t caps = cap_get(TASK); 113 if (!(caps & CAP_MEM_MANAGER)) 114 return EPERM; 119 115 120 116 mem_backend_data_t backend_data; … … 127 123 128 124 if (znum == (size_t) -1) { 129 /* 130 * Frames not found in any zone 131 * -> assume it is a hardware device and allow mapping 132 * for privileged tasks. 125 /* Frames not found in any zones 126 * -> assume it is hardware device and allow mapping 133 127 */ 134 128 irq_spinlock_unlock(&zones.lock, true); 135 136 if (!priv)137 return EPERM;138 139 129 goto map; 140 130 } 141 131 142 132 if (zones.info[znum].flags & ZONE_FIRMWARE) { 143 /* 144 * Frames are part of firmware 145 * -> allow mapping for privileged tasks. 146 */ 133 /* Frames are part of firmware */ 147 134 irq_spinlock_unlock(&zones.lock, true); 148 149 if (!priv)150 return EPERM;151 152 135 goto map; 153 136 } … … 155 138 if (zone_flags_available(zones.info[znum].flags)) { 156 139 /* 157 * Frames are part of physical memory, check 158 * if the memoryregion is enabled for mapping.140 * Frames are part of physical memory, check if the memory 141 * region is enabled for mapping. 159 142 */ 160 143 irq_spinlock_unlock(&zones.lock, true); … … 167 150 if ((!parea) || (parea->frames < pages)) { 168 151 mutex_unlock(&parea_lock); 169 return ENOENT; 170 } 171 172 if (!priv) { 173 if (!parea->unpriv) { 174 mutex_unlock(&parea_lock); 175 return EPERM; 176 } 152 goto err; 177 153 } 178 154 … … 182 158 183 159 irq_spinlock_unlock(&zones.lock, true); 160 161 err: 184 162 return ENOENT; 185 163
Note:
See TracChangeset
for help on using the changeset viewer.