€•»FŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ(/translations/zh_CN/admin-guide/LSM/Yama”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/zh_TW/admin-guide/LSM/Yama”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/it_IT/admin-guide/LSM/Yama”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ja_JP/admin-guide/LSM/Yama”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ko_KR/admin-guide/LSM/Yama”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/sp_SP/admin-guide/LSM/Yama”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒYama”h]”hŒYama”…””}”(hh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒB/var/lib/git/docbuild/linux/Documentation/admin-guide/LSM/Yama.rst”h KubhŒ paragraph”“”)”}”(hXYama is a Linux Security Module that collects system-wide DAC security protections that are not handled by the core kernel itself. This is selectable at build-time with ``CONFIG_SECURITY_YAMA``, and can be controlled at run-time through sysctls in ``/proc/sys/kernel/yama``:”h]”(hŒ©Yama is a Linux Security Module that collects system-wide DAC security protections that are not handled by the core kernel itself. This is selectable at build-time with ”…””}”(hh¹hžhhŸNh NubhŒliteral”“”)”}”(hŒ``CONFIG_SECURITY_YAMA``”h]”hŒCONFIG_SECURITY_YAMA”…””}”(hhÃhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhh¹ubhŒ7, and can be controlled at run-time through sysctls in ”…””}”(hh¹hžhhŸNh NubhÂ)”}”(hŒ``/proc/sys/kernel/yama``”h]”hŒ/proc/sys/kernel/yama”…””}”(hhÕhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhh¹ubhŒ:”…””}”(hh¹hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khh£hžhubh¢)”}”(hhh]”(h§)”}”(hŒ ptrace_scope”h]”hŒ ptrace_scope”…””}”(hhðhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hhíhžhhŸh¶h K ubh¸)”}”(hX$As Linux grows in popularity, it will become a larger target for malware. One particularly troubling weakness of the Linux process interfaces is that a single user is able to examine the memory and running state of any of their processes. For example, if one application (e.g. Pidgin) was compromised, it would be possible for an attacker to attach to other running processes (e.g. Firefox, SSH sessions, GPG agent, etc) to extract additional credentials and continue to expand the scope of their attack without resorting to user-assisted phishing.”h]”hX$As Linux grows in popularity, it will become a larger target for malware. One particularly troubling weakness of the Linux process interfaces is that a single user is able to examine the memory and running state of any of their processes. For example, if one application (e.g. Pidgin) was compromised, it would be possible for an attacker to attach to other running processes (e.g. Firefox, SSH sessions, GPG agent, etc) to extract additional credentials and continue to expand the scope of their attack without resorting to user-assisted phishing.”…””}”(hhþhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K hhíhžhubh¸)”}”(hXÁThis is not a theoretical problem. `SSH session hijacking `_ and `arbitrary code injection `_ attacks already exist and remain possible if ptrace is allowed to operate as before. Since ptrace is not commonly used by non-developers and non-admins, system builders should be allowed the option to disable this debugging system.”h]”(hŒ#This is not a theoretical problem. ”…””}”(hj hžhhŸNh NubhŒ reference”“”)”}”(hŒ``SSH session hijacking `_”h]”hŒSSH session hijacking”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒSSH session hijacking”Œrefuri”ŒEhttps://www.blackhat.com/presentations/bh-usa-05/bh-us-05-boileau.pdf”uh1jhj ubhŒtarget”“”)”}”(hŒH ”h]”h}”(h]”Œssh-session-hijacking”ah ]”h"]”Œssh session hijacking”ah$]”h&]”Œrefuri”j'uh1j(Œ referenced”Khj ubhŒ and ”…””}”(hj hžhhŸNh Nubj)”}”(hŒQ`arbitrary code injection `_”h]”hŒarbitrary code injection”…””}”(hj<hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œarbitrary code injection”j&Œ3https://c-skills.blogspot.com/2007/05/injectso.html”uh1jhj ubj))”}”(hŒ6 ”h]”h}”(h]”Œarbitrary-code-injection”ah ]”h"]”Œarbitrary code injection”ah$]”h&]”Œrefuri”jLuh1j(j7Khj ubhŒè attacks already exist and remain possible if ptrace is allowed to operate as before. Since ptrace is not commonly used by non-developers and non-admins, system builders should be allowed the option to disable this debugging system.”…””}”(hj hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khhíhžhubh¸)”}”(hX‚For a solution, some applications use ``prctl(PR_SET_DUMPABLE, ...)`` to specifically disallow such ptrace attachment (e.g. ssh-agent), but many do not. A more general solution is to only allow ptrace directly from a parent to a child process (i.e. direct "gdb EXE" and "strace EXE" still work), or with ``CAP_SYS_PTRACE`` (i.e. "gdb --pid=PID", and "strace -p PID" still work as root).”h]”(hŒ&For a solution, some applications use ”…””}”(hjdhžhhŸNh NubhÂ)”}”(hŒ``prctl(PR_SET_DUMPABLE, ...)``”h]”hŒprctl(PR_SET_DUMPABLE, ...)”…””}”(hjlhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjdubhŒó to specifically disallow such ptrace attachment (e.g. ssh-agent), but many do not. A more general solution is to only allow ptrace directly from a parent to a child process (i.e. direct “gdb EXE†and “strace EXE†still work), or with ”…””}”(hjdhžhhŸNh NubhÂ)”}”(hŒ``CAP_SYS_PTRACE``”h]”hŒCAP_SYS_PTRACE”…””}”(hj~hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjdubhŒH (i.e. “gdb --pid=PIDâ€, and “strace -p PID†still work as root).”…””}”(hjdhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khhíhžhubh¸)”}”(hXêIn mode 1, software that has defined application-specific relationships between a debugging process and its inferior (crash handlers, etc), ``prctl(PR_SET_PTRACER, pid, ...)`` can be used. An inferior can declare which other process (and its descendants) are allowed to call ``PTRACE_ATTACH`` against it. Only one such declared debugging process can exists for each inferior at a time. For example, this is used by KDE, Chromium, and Firefox's crash handlers, and by Wine for allowing only Wine processes to ptrace each other. If a process wishes to entirely disable these ptrace restrictions, it can call ``prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, ...)`` so that any otherwise allowed process (even those in external pid namespaces) may attach.”h]”(hŒŒIn mode 1, software that has defined application-specific relationships between a debugging process and its inferior (crash handlers, etc), ”…””}”(hj–hžhhŸNh NubhÂ)”}”(hŒ#``prctl(PR_SET_PTRACER, pid, ...)``”h]”hŒprctl(PR_SET_PTRACER, pid, ...)”…””}”(hjžhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhj–ubhŒd can be used. An inferior can declare which other process (and its descendants) are allowed to call ”…””}”(hj–hžhhŸNh NubhÂ)”}”(hŒ``PTRACE_ATTACH``”h]”hŒ PTRACE_ATTACH”…””}”(hj°hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhj–ubhX< against it. Only one such declared debugging process can exists for each inferior at a time. For example, this is used by KDE, Chromium, and Firefox’s crash handlers, and by Wine for allowing only Wine processes to ptrace each other. If a process wishes to entirely disable these ptrace restrictions, it can call ”…””}”(hj–hžhhŸNh NubhÂ)”}”(hŒ2``prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, ...)``”h]”hŒ.prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, ...)”…””}”(hjÂhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhj–ubhŒZ so that any otherwise allowed process (even those in external pid namespaces) may attach.”…””}”(hj–hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K%hhíhžhubh¸)”}”(hŒ@The sysctl settings (writable only with ``CAP_SYS_PTRACE``) are:”h]”(hŒ(The sysctl settings (writable only with ”…””}”(hjÚhžhhŸNh NubhÂ)”}”(hŒ``CAP_SYS_PTRACE``”h]”hŒCAP_SYS_PTRACE”…””}”(hjâhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjÚubhŒ) are:”…””}”(hjÚhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K1hhíhžhubhŒdefinition_list”“”)”}”(hhh]”(hŒdefinition_list_item”“”)”}”(hX0 - classic ptrace permissions: a process can ``PTRACE_ATTACH`` to any other process running under the same uid, as long as it is dumpable (i.e. did not transition uids, start privileged, or have called ``prctl(PR_SET_DUMPABLE...)`` already). Similarly, ``PTRACE_TRACEME`` is unchanged. ”h]”(hŒterm”“”)”}”(hŒ0 - classic ptrace permissions:”h]”hŒ0 - classic ptrace permissions:”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h K8hjubhŒ definition”“”)”}”(hhh]”h¸)”}”(hŒþa process can ``PTRACE_ATTACH`` to any other process running under the same uid, as long as it is dumpable (i.e. did not transition uids, start privileged, or have called ``prctl(PR_SET_DUMPABLE...)`` already). Similarly, ``PTRACE_TRACEME`` is unchanged.”h]”(hŒa process can ”…””}”(hjhžhhŸNh NubhÂ)”}”(hŒ``PTRACE_ATTACH``”h]”hŒ PTRACE_ATTACH”…””}”(hj"hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjubhŒŒ to any other process running under the same uid, as long as it is dumpable (i.e. did not transition uids, start privileged, or have called ”…””}”(hjhžhhŸNh NubhÂ)”}”(hŒ``prctl(PR_SET_DUMPABLE...)``”h]”hŒprctl(PR_SET_DUMPABLE...)”…””}”(hj4hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjubhŒ already). Similarly, ”…””}”(hjhžhhŸNh NubhÂ)”}”(hŒ``PTRACE_TRACEME``”h]”hŒPTRACE_TRACEME”…””}”(hjFhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjubhŒ is unchanged.”…””}”(hjhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K4hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÿhŸh¶h K8hjüubj)”}”(hX¸1 - restricted ptrace: a process must have a predefined relationship with the inferior it wants to call ``PTRACE_ATTACH`` on. By default, this relationship is that of only its descendants when the above classic criteria is also met. To change the relationship, an inferior can call ``prctl(PR_SET_PTRACER, debugger, ...)`` to declare an allowed debugger PID to call ``PTRACE_ATTACH`` on the inferior. Using ``PTRACE_TRACEME`` is unchanged. ”h]”(j)”}”(hŒ1 - restricted ptrace:”h]”hŒ1 - restricted ptrace:”…””}”(hjnhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h KAhjjubj)”}”(hhh]”h¸)”}”(hX a process must have a predefined relationship with the inferior it wants to call ``PTRACE_ATTACH`` on. By default, this relationship is that of only its descendants when the above classic criteria is also met. To change the relationship, an inferior can call ``prctl(PR_SET_PTRACER, debugger, ...)`` to declare an allowed debugger PID to call ``PTRACE_ATTACH`` on the inferior. Using ``PTRACE_TRACEME`` is unchanged.”h]”(hŒQa process must have a predefined relationship with the inferior it wants to call ”…””}”(hjhžhhŸNh NubhÂ)”}”(hŒ``PTRACE_ATTACH``”h]”hŒ PTRACE_ATTACH”…””}”(hj‡hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjubhŒ¡ on. By default, this relationship is that of only its descendants when the above classic criteria is also met. To change the relationship, an inferior can call ”…””}”(hjhžhhŸNh NubhÂ)”}”(hŒ(``prctl(PR_SET_PTRACER, debugger, ...)``”h]”hŒ$prctl(PR_SET_PTRACER, debugger, ...)”…””}”(hj™hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjubhŒ, to declare an allowed debugger PID to call ”…””}”(hjhžhhŸNh NubhÂ)”}”(hŒ``PTRACE_ATTACH``”h]”hŒ PTRACE_ATTACH”…””}”(hj«hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjubhŒ on the inferior. Using ”…””}”(hjhžhhŸNh NubhÂ)”}”(hŒ``PTRACE_TRACEME``”h]”hŒPTRACE_TRACEME”…””}”(hj½hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjubhŒ is unchanged.”…””}”(hjhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K;hj|ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÿhŸh¶h KAhjühžhubj)”}”(hŒœ2 - admin-only attach: only processes with ``CAP_SYS_PTRACE`` may use ptrace, either with ``PTRACE_ATTACH`` or through children calling ``PTRACE_TRACEME``. ”h]”(j)”}”(hŒ2 - admin-only attach:”h]”hŒ2 - admin-only attach:”…””}”(hjåhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h KEhjáubj)”}”(hhh]”h¸)”}”(hŒ„only processes with ``CAP_SYS_PTRACE`` may use ptrace, either with ``PTRACE_ATTACH`` or through children calling ``PTRACE_TRACEME``.”h]”(hŒonly processes with ”…””}”(hjöhžhhŸNh NubhÂ)”}”(hŒ``CAP_SYS_PTRACE``”h]”hŒCAP_SYS_PTRACE”…””}”(hjþhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjöubhŒ may use ptrace, either with ”…””}”(hjöhžhhŸNh NubhÂ)”}”(hŒ``PTRACE_ATTACH``”h]”hŒ PTRACE_ATTACH”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjöubhŒ or through children calling ”…””}”(hjöhžhhŸNh NubhÂ)”}”(hŒ``PTRACE_TRACEME``”h]”hŒPTRACE_TRACEME”…””}”(hj"hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhjöubhŒ.”…””}”(hjöhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KDhjóubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjáubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÿhŸh¶h KEhjühžhubj)”}”(hŒ3 - no attach: no processes may use ptrace with ``PTRACE_ATTACH`` nor via ``PTRACE_TRACEME``. Once set, this sysctl value cannot be changed. ”h]”(j)”}”(hŒ3 - no attach:”h]”hŒ3 - no attach:”…””}”(hjJhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¶h KIhjFubj)”}”(hhh]”h¸)”}”(hŒ}no processes may use ptrace with ``PTRACE_ATTACH`` nor via ``PTRACE_TRACEME``. Once set, this sysctl value cannot be changed.”h]”(hŒ!no processes may use ptrace with ”…””}”(hj[hžhhŸNh NubhÂ)”}”(hŒ``PTRACE_ATTACH``”h]”hŒ PTRACE_ATTACH”…””}”(hjchžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhj[ubhŒ nor via ”…””}”(hj[hžhhŸNh NubhÂ)”}”(hŒ``PTRACE_TRACEME``”h]”hŒPTRACE_TRACEME”…””}”(hjuhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhj[ubhŒ0. Once set, this sysctl value cannot be changed.”…””}”(hj[hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KHhjXubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjFubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÿhŸh¶h KIhjühžhubeh}”(h]”h ]”h"]”h$]”h&]”uh1júhhíhžhhŸh¶h Nubh¸)”}”(hŒMThe original children-only logic was based on the restrictions in grsecurity.”h]”hŒMThe original children-only logic was based on the restrictions in grsecurity.”…””}”(hjŸhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KKhhíhžhubeh}”(h]”Œ ptrace-scope”ah ]”h"]”Œ ptrace_scope”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K ubeh}”(h]”Œyama”ah ]”h"]”Œyama”ah$]”h&]”uh1h¡hhhžhhŸh¶h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h¶uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¦NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jàŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h¶Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jºj·j²j¯j3j0jVjSuŒ nametypes”}”(jº‰j²‰j3ˆjVˆuh}”(j·h£j¯híj0j*jSjMuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.