Kipper
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # OS筆記-Chapter 14: Protection ###### tags: `OS` --- #### 目錄 * 總論 [Chapter 1: Introduction](https://hackmd.io/NoZq3J7IQvOQpcbo_tctjA) [Chapter 2: Operating-System Structures](https://hackmd.io/OKykRLBESI6v9a13HgS35A) * 行程管理 [Chapter 3: Processes](https://hackmd.io/HOqN-iQ3RIKIC-NB9QjBIQ) [Chapter 4: Threads](https://hackmd.io/qzAIHeSASmKuecdkqidmHw) [Chapter 5: CPU Scheduling](https://hackmd.io/IT5g2wHzTdOtMSDXPVEpOw) [Chapter 6: Process Synchronization](https://hackmd.io/rv-PNe3ESxi08PElyUTc4Q) [Chapter 7: Deadlocks](https://hackmd.io/Uu0jDK-rSyKNKq690y146g) * 記憶體管理 [Chapter 8: Main Memory](https://hackmd.io/4KS_yPkBQzGZfHDisPciog) [Chapter 9: Virtual Memory](https://hackmd.io/yirxZFn8Rz2wT56AAR7Sxw) * 儲存裝置 [Chapter 10: File-System Interface](https://hackmd.io/aNPWKsFhTlGc-WFgQ__KRg) [Chapter 11: File System Implementation](https://hackmd.io/bFcrlmefQsGp6hZdbI1MHQ) [Chapter 12: Mass-Storage Systems](https://hackmd.io/9Y7Qo0OERda6htK7OOI36Q) [Chapter 13: I/O Systems](https://hackmd.io/VNwXrhJPSo-l_t9tUBhYIg) * 保護和安全 <font color="red">Chapter 14: Protection</font> [Chapter 15: Security](https://hackmd.io/ofyvDidvQf-PxLMMZYhtsg) --- ### 保護的目的 * 防止使用者惡意的破壞系統上的存取限制 * 確保系統內工作的每一個程式都能在與指定政策一致的方式下使用系統支援 * 提供方法以區分有權限和無權限的使用 * 防止應用程式子系統產生和支援的資源被誤用 ### 保護的原則 * 最小特權原則(princple of least privilege) * 程式、使用者甚至系統只需有足夠的特權來執行他們的工作 * 造成最小的傷害 * 提供機制應用程式需要的時候可以使用特權,不需要的時候,則不使用特權 ### 保護的範圍 * 必須知道原則(need-to-know principle):一個行程只能存取完成任務所需要的最小資源 * 領域結構 * 保護領域(protection domain):設定行程可存取的資源,是存取權(access right)與資源的組合 * 領域D有存取權<file,{read,write,excute}> ![](https://i.imgur.com/3TLHiSG.png) * 行程與領域之間可為靜態或動態 * 動態的則提供一個機制允許領域轉換(domain switching) * UNIX例子 * 領域轉換相當於暫時改變使用者的身分 * setuid位元=領域位元 * A使用屬於B的檔案時,當執行且設定setuid,使用者識別碼(userID)被暫時設為檔案擁有者B,當行程結束,暫時的使用者識別碼才變回來 * 若一個使用者設法產生一個使用者使別碼為root的檔案,則它能暫時成為root執行各種權限 * 有些系統開機時啟動守護行程(daemon process),當程式需要設施時便對守護行程發出要求 * MULTICS例子 * 環狀結構 * 若j<i,則Dᵢ⊆Dⱼ;在領域Dⱼ內執行的行程比在Dᵢ中有更多特權 ![](https://i.imgur.com/bA7m1KT.png) ### 存取矩陣(access matrix) * 將保護的觀念看成是矩陣 * 四個領域及四個物件 * 紀錄領域能存取的物件 ![](https://i.imgur.com/Oz3r9ag.png) * 當一行程從一領域轉換到另一領域時,我們執行switch * 將領域視為物件 ![](https://i.imgur.com/h8e3XPJ.png) * 擁有拷貝權力以* 表示,能將存取權拷貝至其他領域 * (a)經過拷貝修改為(b) ![](https://i.imgur.com/6JIcXwO.png) * 擁有者權力能為該物件加入或移除存取權 * (a)經過擁有者修改為(b) ![](https://i.imgur.com/gHRWX7s.png) * 控制權力能移去領域中任何一個存取權 * 經控制權力修改,移除D₄ ![](https://i.imgur.com/iBQk6od.png) * 監禁問題(confinement problem):防止一個物件內原先擁有的資訊不會移到執行環境外的問題 * 拷貝與擁有者權利提供限制存取權的機制,但不能防止資訊傳播 ### 存取矩陣的製作(Implementation of Access Matrix) * 全域表 * 製作一個含有<Domain,Object,rights-set>的表 * 表格太大 * 物件的存取串列(access list) * 每個物件都有自己的串列 * 紀錄<Domain,rights-set> * 領域的資格串列(capability list) * 若領域內行程的資格串列有此物件的資格項,則表示允許該行程使用此物件 * 兩種分法區隔資格項與一班可存資料項 * 每個物件都附帶一個標籤(tag) * 將位址空間分為兩部分 * 鎖與鑰匙的機制(lock-key scheme) * 每個物件有唯一的位元串列,稱為鎖 * 每個領域有唯一的位元串列,稱為鑰匙 * 鎖與鑰匙相符才能使用該物件 ### 存取控制(Access Control) * 每一檔案和目錄被指定有使用者、團體或一串列的使用者,存取控制信息被分配給這些實體 * Solaris 10以角色為基礎的存取控制(RBAC,role-based access control)加少許特權的原則 * 特權是執行系統呼叫的權力,可以被分配到行程 * 特權與程式可以分配到角色 * 分配角色給使用者 ![](https://i.imgur.com/oQMhMuV.png) ### 存取權利的取消(Revocation of Access Rights) * 當取消存取權時,會有一些問題產生 * 立即(immediate)/延後(delayed):取消是立即發生或延後發生? * 選擇性的(selective)/一般性的(general):當一個存取權被取消時,會對所有有此物件存取權的使用者早成影響嗎 * 部分(partial)/全部(total):能否部分集合對此物件的權利被取消? * 暫時性的(remporary)/永久性的(permanent) * 存取串列(access list) * 容易取消存取權 * 搜尋串列並移除 * 立即、選擇性的/一般性的、部分/全部、暫時性的/永久性的 * 資格串列(capability list) * 資格散佈在系統中,不易取消 * 再獲得(reacqusition):如果一個行程想要使用資格,他可發現該資格已被刪除,再嘗試獲取資格 * 返回指標(back-pointer):每一個物件都建立一個指標串列,指向附屬於該物件的資格 * 間接(indirection):資格不是直接而是間接的指向物件,每一資格指向全域表中唯一的紀錄 * 鑰匙(key):將鑰匙換新 ### 以資格為基礎的系統(Capability-Based Systems) * Hydra * 以資格為主的保護系統 * 提供一個固定集合的可能存取權利 * 提供使用者外加權利的方法 * 附加權(auxiliary right):將處理使用者定義類型的物件,使用者定義的處理程序的名稱必須指明給保護系統 * 權利擴大(rights amplification):允許一個處理程序作用在一個標明類型的正規參數上得到值得信賴的保證 * 當一行程在一物件A上引發動作P,如控制傳到P的程式碼實體,對A存取的資格可以被擴大 * 相互猜疑子系統問題(problem of mutually suspicious subsystem) * 劍橋CAP * 兩種資格 * 資料資格(data capability):提供物件的存取,標準讀寫或個別儲存分段與物件相關的執行 * 軟體資格(software capability):一個行程可以暫時的要求一個軟體資格來對自己的內容做讀或寫的權利 ### 以語言為基礎的保護系統(Language-Based Protection) * 保護不再單獨被認為是系統設計者的工作。它應也適用於當做應用設計者的工具 * 編譯器為基礎的實行 * 集合成為一個語言,保護伴隨著資料類型被宣稱 * 有下列數個好處 * 只需要做保護簡單的宣稱,而不是以一串對作業系統處理程序的呼叫寫出 * 保護需求的陳述可以與特別的作業系統所提供的設備無關 * 實行的方法不必由子系統的設計者提供 * 一個宣稱的標示很自然,因為存取特權與資料類型的語言觀念相關 * 一個語言的製作方式可能提供標準、保護的處理程序來解釋軟體資格 * 一個編譯器能分別尋找,從那些可能發生違反的地方找到保證沒有違反保護會發生的地方,並不同的對待他們 * 安全性(security):經由核心比由編譯器產生的保護檢查碼,對保護系統提供更高度的安全性 * 彈性(flexibility):利用程式語言,可以依需要來宣稱及強行保護政策 * 效率性(efficiency):以語言為基礎的強行有固定存取強行可以在編譯時離線被修改 * 對資料結構緘封(seal):阻止它的內容被任何沒有擁有緘封或開啟(unseal)特權的程式存取 * Java的保護 * Java由類別(class)所組成,每一個類別則是資料欄位以及操作這些欄位的函數(method)的集合 * JVM載入類別時,會設定一個給予該類別許可範圍的保護領域 * 堆疊檢查(stack inspection):找出堆疊內使否有兩種型態的堆疊,決定存取是否被允許 * Java不能夠直接修改記憶體,只能處理有參考(reference)的物件,這種包裝(encapsulate)保護類別的資料和方法

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully