Exemplo n.º 1
0
static void checkStubs(void* addr)
{
	vm_prot_t perm = getPermission(addr);
	if ( (perm == 0) || ((perm & VM_PROT_WRITE) != 0) ) {
		FAIL("read-only-stubs: bad permissions %d at address %p", perm, addr);
		exit(0);
	}
}
Exemplo n.º 2
0
/**
 * @brief 
 *
 * @param print_buffer
 */
static void uart_dev_write(char *print_buffer)
{
    if(getPermission(DEVICE_ID) == 1){
        serial_puts(print_buffer);
    }else{
        serial_puts("\n\rSW: No Permission to access UART device \r\n");
    }
    return;
}
Exemplo n.º 3
0
bool Block::handlePageFault(task_t* i_task, uint64_t i_addr, bool i_store)
{
    // Check containment, call down chain if address isn't in this block.
    if (!isContained(i_addr))
    {
        return (iv_nextBlock ?
                    iv_nextBlock->handlePageFault(i_task, i_addr, i_store) :
                    false);
    }

    // Calculate page aligned virtual address.
    uint64_t l_addr_palign = (i_addr / PAGESIZE) * PAGESIZE;

    ShadowPTE* pte = getPTE(l_addr_palign);

    // If the page table entry has default permission settings
    if (getPermission(pte) == NO_ACCESS)
    {
      printkd("handle page fault.. Permission not set for addr =  0x%.lX\n",
              (uint64_t)l_addr_palign);
      // return false because permission have not been set.
      return false;
    }

    // Mark the page as dirty if this is a store to it.
    if (i_store)
    {
        if (pte->isWritable())
        {
            pte->setDirty(true);
        }
        else // Store to non-writable page!  This is a permission fault, so
             // return unhandled.
        {
            return false;
        }
    }

    if (!pte->isPresent())
    {
        if (this->iv_readMsgHdlr != NULL)
        {
            void* l_page = reinterpret_cast<void*>(pte->getPageAddr());
            //If the page data is zero, create the page
            if (pte->getPage() == 0)
            {
                l_page = PageManager::allocatePage();
                //Add to ShadowPTE
                pte->setPageAddr(reinterpret_cast<uint64_t>(l_page));
            }


            this->iv_readMsgHdlr->sendMessage(MSG_MM_RP_READ,
                    reinterpret_cast<void*>(l_addr_palign),l_page,i_task);
            //Done(waiting for response)
            return true;
        }
        else if (pte->isAllocateFromZero())
        {
            void* l_page = PageManager::allocatePage();

            // set the permission of the physical address pte entry to
            // READ_ONLY now that we have handled the page fault and
            // have a SPTE entry for that VA.
            if (BaseSegment::mmSetPermission(reinterpret_cast<void*>(l_page),
                                             0, READ_ONLY))
            {
               // Did not set permission..
               printkd("handle page fault.. Set Permission failed for physical"
                       " addr =  0x%.lX\n", (uint64_t)l_page);
            }

            memset(l_page, '\0', PAGESIZE);

            pte->setPageAddr(reinterpret_cast<uint64_t>(l_page));
            pte->setPresent(true);

        }
        else
        {
            return false;
        }
    }

    // Determine access type.
    uint64_t l_access = (iv_mappedToPhysical ? BYPASS_HRMOR : 0);
    if (pte->isExecutable())
    {
        l_access |= EXECUTABLE;
    }
    else if (pte->isWritable() && pte->isDirty())
    {
        l_access |= WRITABLE;
    }
    else
    {
        l_access |= READ_ONLY;
    }

    PageTableManager::addEntry(
            l_addr_palign,
            pte->getPage(),
            l_access);

    return true;

}
Exemplo n.º 4
0
int Block::setPermSPTE( ShadowPTE* i_spte, uint64_t i_access_type)
{

    // If read_only
    if ( i_access_type & READ_ONLY)
    {
        // If the writable, executable, write_tracked
        // or allocate from zero access bits are set
        // we have an invalid combination.. return error
        if ((i_access_type & WRITABLE) ||
            (i_access_type & EXECUTABLE) ||
            (i_access_type & WRITE_TRACKED) ||
            (i_access_type & ALLOCATE_FROM_ZERO))
        {
            return -EINVAL;
        }

        // Set the bits after we have verified
        // the valid combinations so if we are setting
        // permissions on a range only the first page would
        // get set to READ_ONLY before we fail.
        i_spte->setReadable(true);
        i_spte->setExecutable(false);
        i_spte->setWritable(false);
    }
    // if writable
    else if ( i_access_type & WRITABLE)
    {
        if (i_access_type & EXECUTABLE)
        {
            return -EINVAL;
        }

        i_spte->setReadable(true);
        i_spte->setWritable(true);
        i_spte->setExecutable(false);
    }
    // if executable
    else if ( i_access_type & EXECUTABLE)
    {
        i_spte->setReadable(true);
        i_spte->setExecutable(true);
        i_spte->setWritable(false);
    }

    // if write_tracked
    if ( i_access_type & WRITE_TRACKED)
    {
        // If the page is already READ_ONLY
        // you cannot set to WRITE_TRACKED
        if (getPermission(i_spte) == READ_ONLY)
        {
            return -EINVAL;
        }
        else if (NULL == iv_writeMsgHdlr)
        {
            return -EINVAL;
        }

        i_spte->setWriteTracked(true);
    }
    else
    {
        i_spte->setWriteTracked(false);
    }

    // if Allocate from zero
    if ( i_access_type & ALLOCATE_FROM_ZERO)
    {
        // If the page is already READ_ONLY
        // you cannot set to ALLOCATE_FROM_ZERO
        if (getPermission(i_spte) == READ_ONLY)
        {
            return -EINVAL;
        }

        i_spte->setAllocateFromZero(true);
    }
    // not allocated from zero
    else
    {
        i_spte->setAllocateFromZero(false);
    }

    // if no access
    if ( i_access_type & NO_ACCESS)
    {
        i_spte->setReadable(false);
        i_spte->setExecutable(false);
        i_spte->setWritable(false);
        i_spte->setAllocateFromZero(false);
        i_spte->setWriteTracked(false);
    }

    return 0;
}
Exemplo n.º 5
0
void PermissionManager::checkPermissionThrows( const String& rName, camp::Value& rValue, 
    const String& rSrc )
{
    if( ClientPlugin::isOfflineMode() ) return;
    getPermission( rName ).checkPermissionThrows( rValue, rSrc );
}
Exemplo n.º 6
0
bool PermissionManager::checkPermissionAllowed( const String& rName, camp::Value& rValue )
{
    if( ClientPlugin::isOfflineMode() ) return true;
    return getPermission( rName ).checkPermissionAllowed( rValue );
}
Exemplo n.º 7
0
Permission::ResultType PermissionManager::checkPermission( const String& rName, camp::Value& rValue )
{
    if( ClientPlugin::isOfflineMode() ) return Permission::Permission_Allowed;
    return getPermission( rName ).checkPermission( rValue );
}
Exemplo n.º 8
0
QString AdobeDRM::getPermissionString( dpdoc::Document* doc, const char* type ,  bool* drmFile )
{
    QString perm_str;
    Permission perm;

    if (!m_proc || !doc) return QString();

    perm = getPermission(doc, type);

    qDebug() << Q_FUNC_INFO << perm;

    if(!perm.valid)
    {
        perm_str.append("Not allowed");
        if(drmFile) *drmFile = true;
        return perm_str;
    }

    // Legal device ?
    if( perm.type == QString("print"))
    {
        perm_str.append("Any Device");
        return perm_str;
    }

    if( perm.type == QString("excerpt"))
    {
        perm_str.append("Any Device");
        return perm_str;
    }

    if(perm.deviceId.isEmpty())
    {
        perm_str.append("Any Device");
    }
    else
    {
        bool isLegalDevice = false;

        dp::list<dpdrm::Activation> activations = m_proc->getActivations();
        unsigned int size = activations.length();
        for (unsigned int i = 0; i < size; ++i)
        {
            dp::ref<dpdrm::Activation> activation = activations[i];
            QString deviceId = QString::fromUtf8(activation->getDeviceID().utf8());
            if( deviceId == perm.deviceId )
            {
                isLegalDevice = true;
                break;
            }
        }

        if(isLegalDevice)
            perm_str.append("Only this Device");
        else
            perm_str.append("Not this Device");

    }

    // Expiration ?
    if(perm.maxResolution != 0 && perm.type == QString("print"))
    {
        perm_str.append(QString(", Max. resolution is %1 dpi").arg(perm.maxResolution));
    }

    if(perm.expiration.toTime_t() != 0)
    {
        perm_str.append(", Until ");
        perm_str.append(perm.expiration.toLocalTime().toString(Qt::SystemLocaleDate));
    }

    if(drmFile)
    {
        QString drm_string("Any Device");
        if(perm_str.compare(drm_string, Qt::CaseSensitive)!= 0)
            *drmFile = true;
        else
            *drmFile = false;
    }

    return perm_str;
}
 //print permission, name, owner, size and last modification time 
 void Directory :: outputLong() const
 {
     cout << getPermission() + " " + getName() + " "  + 
             getOwner() + " " <<  getSize() <<  " "  + getTime() << endl;
 }