€•w2Œ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/dev-tools/ubsan”Œ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/dev-tools/ubsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/it_IT/dev-tools/ubsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/ja_JP/dev-tools/ubsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/ko_KR/dev-tools/ubsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ#/translations/pt_BR/dev-tools/ubsan”Œ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/dev-tools/ubsan”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ=/var/lib/git/docbuild/linux/Documentation/dev-tools/ubsan.rst”h´KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ$Undefined Behavior Sanitizer - UBSAN”h]”hŒ$Undefined Behavior Sanitizer - UBSAN”…””}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ paragraph”“”)”}”(hŒ/UBSAN is a runtime undefined behaviour checker.”h]”hŒ/UBSAN is a runtime undefined behaviour checker.”…””}”(hhßh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÞ)”}”(hXUBSAN uses compile-time instrumentation to catch undefined behavior (UB). Compiler inserts code that perform certain kinds of checks before operations that may cause UB. If check fails (i.e. UB detected) __ubsan_handle_* function called to print error message.”h]”hXUBSAN uses compile-time instrumentation to catch undefined behavior (UB). Compiler inserts code that perform certain kinds of checks before operations that may cause UB. If check fails (i.e. UB detected) __ubsan_handle_* function called to print error message.”…””}”(hhíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÞ)”}”(hŒ‹GCC has that feature since 4.9.x [1_] (see ``-fsanitize=undefined`` option and its suboptions). GCC 5.x has more checkers implemented [2_].”h]”(hŒ"GCC has that feature since 4.9.x [”…””}”(hhûh²hh³Nh´NubhŒ reference”“”)”}”(hŒ1_”h]”hŒ1”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ1”Œrefuri”ŒChttps://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html”uh1jhhûŒresolved”KubhŒ] (see ”…””}”(hhûh²hh³Nh´NubhŒliteral”“”)”}”(hŒ``-fsanitize=undefined``”h]”hŒ-fsanitize=undefined”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhûubhŒD option and its suboptions). GCC 5.x has more checkers implemented [”…””}”(hhûh²hh³Nh´Nubj)”}”(hŒ2_”h]”hŒ2”…””}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ2”jŒ9https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html”uh1jhhûjKubhŒ].”…””}”(hhûh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K hhÊh²hubhÉ)”}”(hhh]”(hÎ)”}”(hŒReport example”h]”hŒReport example”…””}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjKh²hh³hÇh´KubhŒ literal_block”“”)”}”(hXî================================================================================ UBSAN: Undefined behaviour in ../include/linux/bitops.h:110:33 shift exponent 32 is to large for 32-bit type 'unsigned int' CPU: 0 PID: 0 Comm: swapper Not tainted 4.4.0-rc1+ #26 0000000000000000 ffffffff82403cc8 ffffffff815e6cd6 0000000000000001 ffffffff82403cf8 ffffffff82403ce0 ffffffff8163a5ed 0000000000000020 ffffffff82403d78 ffffffff8163ac2b ffffffff815f0001 0000000000000002 Call Trace: [] dump_stack+0x45/0x5f [] ubsan_epilogue+0xd/0x40 [] __ubsan_handle_shift_out_of_bounds+0xeb/0x130 [] ? radix_tree_gang_lookup_slot+0x51/0x150 [] _mix_pool_bytes+0x1e6/0x480 [] ? dmi_walk_early+0x48/0x5c [] add_device_randomness+0x61/0x130 [] ? dmi_save_one_device+0xaa/0xaa [] dmi_walk_early+0x48/0x5c [] dmi_scan_machine+0x278/0x4b4 [] ? vprintk_default+0x1a/0x20 [] ? early_idt_handler_array+0x120/0x120 [] setup_arch+0x405/0xc2c [] ? early_idt_handler_array+0x120/0x120 [] start_kernel+0x83/0x49a [] ? early_idt_handler_array+0x120/0x120 [] x86_64_start_reservations+0x2a/0x2c [] x86_64_start_kernel+0x16b/0x17a ================================================================================”h]”hXî================================================================================ UBSAN: Undefined behaviour in ../include/linux/bitops.h:110:33 shift exponent 32 is to large for 32-bit type 'unsigned int' CPU: 0 PID: 0 Comm: swapper Not tainted 4.4.0-rc1+ #26 0000000000000000 ffffffff82403cc8 ffffffff815e6cd6 0000000000000001 ffffffff82403cf8 ffffffff82403ce0 ffffffff8163a5ed 0000000000000020 ffffffff82403d78 ffffffff8163ac2b ffffffff815f0001 0000000000000002 Call Trace: [] dump_stack+0x45/0x5f [] ubsan_epilogue+0xd/0x40 [] __ubsan_handle_shift_out_of_bounds+0xeb/0x130 [] ? radix_tree_gang_lookup_slot+0x51/0x150 [] _mix_pool_bytes+0x1e6/0x480 [] ? dmi_walk_early+0x48/0x5c [] add_device_randomness+0x61/0x130 [] ? dmi_save_one_device+0xaa/0xaa [] dmi_walk_early+0x48/0x5c [] dmi_scan_machine+0x278/0x4b4 [] ? vprintk_default+0x1a/0x20 [] ? early_idt_handler_array+0x120/0x120 [] setup_arch+0x405/0xc2c [] ? early_idt_handler_array+0x120/0x120 [] start_kernel+0x83/0x49a [] ? early_idt_handler_array+0x120/0x120 [] x86_64_start_reservations+0x2a/0x2c [] x86_64_start_kernel+0x16b/0x17a ================================================================================”…””}”hj^sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j\h³hÇh´KhjKh²hubeh}”(h]”Œreport-example”ah ]”h"]”Œreport example”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KubhÉ)”}”(hhh]”(hÎ)”}”(hŒUsage”h]”hŒUsage”…””}”(hjwh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjth²hh³hÇh´K2ubhÞ)”}”(hŒ,To enable UBSAN, configure the kernel with::”h]”hŒ+To enable UBSAN, configure the kernel with:”…””}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K4hjth²hubj])”}”(hŒCONFIG_UBSAN=y”h]”hŒCONFIG_UBSAN=y”…””}”hj“sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j\h³hÇh´K6hjth²hubhÞ)”}”(hŒ.To exclude files from being instrumented use::”h]”hŒ-To exclude files from being instrumented use:”…””}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K8hjth²hubj])”}”(hŒUBSAN_SANITIZE_main.o := n”h]”hŒUBSAN_SANITIZE_main.o := n”…””}”hj¯sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j\h³hÇh´K:hjth²hubhÞ)”}”(hŒ1and to exclude all targets in one directory use::”h]”hŒ0and to exclude all targets in one directory use:”…””}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khjth²hubhÞ)”}”(hŒDWhen disabled for all targets, specific files can be enabled using::”h]”hŒCWhen disabled for all targets, specific files can be enabled using:”…””}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K@hjth²hubj])”}”(hŒUBSAN_SANITIZE_main.o := y”h]”hŒUBSAN_SANITIZE_main.o := y”…””}”hjçsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1j\h³hÇh´KBhjth²hubhÞ)”}”(hX-Detection of unaligned accesses controlled through the separate option - CONFIG_UBSAN_ALIGNMENT. It's off by default on architectures that support unaligned accesses (CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y). One could still enable it in config, just note that it will produce a lot of UBSAN reports.”h]”hX/Detection of unaligned accesses controlled through the separate option - CONFIG_UBSAN_ALIGNMENT. It’s off by default on architectures that support unaligned accesses (CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y). One could still enable it in config, just note that it will produce a lot of UBSAN reports.”…””}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KDhjth²hubeh}”(h]”Œusage”ah ]”h"]”Œusage”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K2ubhÉ)”}”(hhh]”(hÎ)”}”(hŒ References”h]”hŒ References”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj h²hh³hÇh´KKubhŒtarget”“”)”}”(hŒJ.. _1: https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html”h]”h}”(h]”Œid1”ah ]”h"]”Œ1”ah$]”h&]”jjuh1jh´KMhj h²hh³hÇŒ referenced”Kubj)”}”(hŒ@.. _2: https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html”h]”h}”(h]”Œid2”ah ]”h"]”Œ2”ah$]”h&]”jj@uh1jh´KNhj h²hh³hÇj*Kubj)”}”(hŒB.. _3: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html”h]”h}”(h]”Œid3”ah ]”h"]”Œ3”ah$]”h&]”jŒ;https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html”uh1jh´KOhj h²hh³hÇubeh}”(h]”Œ references”ah ]”h"]”Œ references”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KKubeh}”(h]”Œ"undefined-behavior-sanitizer-ubsan”ah ]”h"]”Œ$undefined behavior sanitizer - ubsan”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”jwŒ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”}”(Œ1”]”jaŒ2”]”j0auŒrefids”}”Œnameids”}”(jQjNjqjnjjjIjFj'j$j4j1j@j=uŒ nametypes”}”(jQ‰jq‰j‰jI‰j'ˆj4ˆj@ˆuh}”(jNhÊjnjKjjtjFj j$jj1j+j=j7uŒ 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”“”}”j…Ks…”R”Œparse_messages”]”Œtransform_messages”]”hŒsystem_message”“”)”}”(hhh]”hÞ)”}”(hhh]”hŒ'Hyperlink target "3" is not referenced.”…””}”hjäsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhjáubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”hÇŒline”KOuh1jßubaŒ transformer”NŒ include_log”]”Œ decoration”Nh²hub.