Changeset 17aca1c in mainline for kernel/generic/src/ddi/ddi.c


Ignore:
Timestamp:
2011-02-04T20:56:52Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0397e5a4, e29e09cf
Parents:
e778543 (diff), 0b37882 (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/ddi.c

    re778543 r17aca1c  
    104104{
    105105        ASSERT(TASK);
    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;
     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);
    115119       
    116120        mem_backend_data_t backend_data;
     
    123127       
    124128        if (znum == (size_t) -1) {
    125                 /* Frames not found in any zones
    126                  * -> assume it is hardware device and allow mapping
     129                /*
     130                 * Frames not found in any zone
     131                 * -> assume it is a hardware device and allow mapping
     132                 *    for privileged tasks.
    127133                 */
    128134                irq_spinlock_unlock(&zones.lock, true);
     135               
     136                if (!priv)
     137                        return EPERM;
     138               
    129139                goto map;
    130140        }
    131141       
    132142        if (zones.info[znum].flags & ZONE_FIRMWARE) {
    133                 /* Frames are part of firmware */
     143                /*
     144                 * Frames are part of firmware
     145                 * -> allow mapping for privileged tasks.
     146                 */
    134147                irq_spinlock_unlock(&zones.lock, true);
     148               
     149                if (!priv)
     150                        return EPERM;
     151               
    135152                goto map;
    136153        }
     
    138155        if (zone_flags_available(zones.info[znum].flags)) {
    139156                /*
    140                  * Frames are part of physical memory, check if the memory
    141                  * region is enabled for mapping.
     157                 * Frames are part of physical memory, check
     158                 * if the memory region is enabled for mapping.
    142159                 */
    143160                irq_spinlock_unlock(&zones.lock, true);
     
    150167                if ((!parea) || (parea->frames < pages)) {
    151168                        mutex_unlock(&parea_lock);
    152                         goto err;
     169                        return ENOENT;
     170                }
     171               
     172                if (!priv) {
     173                        if (!parea->unpriv) {
     174                                mutex_unlock(&parea_lock);
     175                                return EPERM;
     176                        }
    153177                }
    154178               
     
    158182       
    159183        irq_spinlock_unlock(&zones.lock, true);
    160        
    161 err:
    162184        return ENOENT;
    163185       
Note: See TracChangeset for help on using the changeset viewer.