€•wAŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”(hhŒparent”hubaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ%/translations/zh_CN/usb/authorization”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”(hhhh2ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/zh_TW/usb/authorization”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”(hhhhFubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/it_IT/usb/authorization”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”(hhhhZubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ja_JP/usb/authorization”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”(hhhhnubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ko_KR/usb/authorization”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”(hhhh‚ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/sp_SP/usb/authorization”Œ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Œ>Authorizing (or not) your USB devices to connect to the system”h]”hŒ>Authorizing (or not) your USB devices to connect to the system”…””}”(hhªhh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒ?/var/lib/git/docbuild/linux/Documentation/usb/authorization.rst”h KubhŒ paragraph”“”)”}”(hŒQCopyright (C) 2007 Inaky Perez-Gonzalez Intel Corporation”h]”(hŒ)Copyright (C) 2007 Inaky Perez-Gonzalez <”…””}”(hŒ)Copyright (C) 2007 Inaky Perez-Gonzalez <”hh¹hžhhŸNh NubhŒ reference”“”)”}”(hŒinaky@linux.intel.com”h]”hŒinaky@linux.intel.com”…””}”(hhhhÄhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:inaky@linux.intel.com”uh1hÂhh¹ubhŒ> Intel Corporation”…””}”(hŒ> Intel Corporation”hh¹hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khh£hžhubh¸)”}”(hŒ¹This feature allows you to control if a USB device can be used (or not) in a system. This feature will allow you to implement a lock-down of USB devices, fully controlled by user space.”h]”hŒ¹This feature allows you to control if a USB device can be used (or not) in a system. This feature will allow you to implement a lock-down of USB devices, fully controlled by user space.”…””}”(hháhhßhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khh£hžhubh¸)”}”(hŒëAs of now, when a USB device is connected it is configured and its interfaces are immediately made available to the users. With this modification, only if root authorizes the device to be configured will then it be possible to use it.”h]”hŒëAs of now, when a USB device is connected it is configured and its interfaces are immediately made available to the users. With this modification, only if root authorizes the device to be configured will then it be possible to use it.”…””}”(hhïhhíhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K hh£hžhubh¢)”}”(hhh]”(h§)”}”(hŒUsage”h]”hŒUsage”…””}”(hjhhþhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hhûhžhhŸh¶h Kubh¸)”}”(hŒAuthorize a device to connect::”h]”hŒAuthorize a device to connect:”…””}”(hŒAuthorize a device to connect:”hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KhhûhžhubhŒ literal_block”“”)”}”(hŒ1$ echo 1 > /sys/bus/usb/devices/DEVICE/authorized”h]”hŒ1$ echo 1 > /sys/bus/usb/devices/DEVICE/authorized”…””}”(hhhjubah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jhŸh¶h Khhûhžhubh¸)”}”(hŒDe-authorize a device::”h]”hŒDe-authorize a device:”…””}”(hŒDe-authorize a device:”hj-hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khhûhžhubj)”}”(hŒ1$ echo 0 > /sys/bus/usb/devices/DEVICE/authorized”h]”hŒ1$ echo 0 > /sys/bus/usb/devices/DEVICE/authorized”…””}”(hhhj<ubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h Khhûhžhubh¸)”}”(hŒRSet new devices connected to hostX to be deauthorized by default (ie: lock down)::”h]”hŒQSet new devices connected to hostX to be deauthorized by default (ie: lock down):”…””}”(hŒQSet new devices connected to hostX to be deauthorized by default (ie: lock down):”hjJhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khhûhžhubj)”}”(hŒ7$ echo 0 > /sys/bus/usb/devices/usbX/authorized_default”h]”hŒ7$ echo 0 > /sys/bus/usb/devices/usbX/authorized_default”…””}”(hhhjYubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h Khhûhžhubh¸)”}”(hŒRemove the lock down::”h]”hŒRemove the lock down:”…””}”(hŒRemove the lock down:”hjghžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K hhûhžhubj)”}”(hŒ7$ echo 1 > /sys/bus/usb/devices/usbX/authorized_default”h]”hŒ7$ echo 1 > /sys/bus/usb/devices/usbX/authorized_default”…””}”(hhhjvubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h K"hhûhžhubh¸)”}”(hŒ´By default, all USB devices are authorized. Writing "2" to the authorized_default attribute causes the kernel to authorize by default only devices connected to internal USB ports.”h]”hŒ¸By default, all USB devices are authorized. Writing “2†to the authorized_default attribute causes the kernel to authorize by default only devices connected to internal USB ports.”…””}”(hj†hj„hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K$hhûhžhubh¢)”}”(hhh]”(h§)”}”(hŒExample system lockdown (lame)”h]”hŒExample system lockdown (lame)”…””}”(hj—hj•hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hj’hžhhŸh¶h K*ubh¸)”}”(hŒ”Imagine you want to implement a lockdown so only devices of type XYZ can be connected (for example, it is a kiosk machine with a visible USB port)::”h]”hŒ“Imagine you want to implement a lockdown so only devices of type XYZ can be connected (for example, it is a kiosk machine with a visible USB port):”…””}”(hŒ“Imagine you want to implement a lockdown so only devices of type XYZ can be connected (for example, it is a kiosk machine with a visible USB port):”hj£hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K,hj’hžhubj)”}”(hŒkboot up rc.local -> for host in /sys/bus/usb/devices/usb* do echo 0 > $host/authorized_default done”h]”hŒkboot up rc.local -> for host in /sys/bus/usb/devices/usb* do echo 0 > $host/authorized_default done”…””}”(hhhj²ubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h K0hj’hžhubh¸)”}”(hŒ/Hookup an script to udev, for new USB devices::”h]”hŒ.Hookup an script to udev, for new USB devices:”…””}”(hŒ.Hookup an script to udev, for new USB devices:”hjÀhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K8hj’hžhubj)”}”(hŒFif device_is_my_type $DEV then echo 1 > $device_path/authorized done”h]”hŒFif device_is_my_type $DEV then echo 1 > $device_path/authorized done”…””}”(hhhjÏubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h K:hj’hžhubh¸)”}”(hXgNow, device_is_my_type() is where the juice for a lockdown is. Just checking if the class, type and protocol match something is the worse security verification you can make (or the best, for someone willing to break it). If you need something secure, use crypto and Certificate Authentication or stuff like that. Something simple for an storage key could be::”h]”hXfNow, device_is_my_type() is where the juice for a lockdown is. Just checking if the class, type and protocol match something is the worse security verification you can make (or the best, for someone willing to break it). If you need something secure, use crypto and Certificate Authentication or stuff like that. Something simple for an storage key could be:”…””}”(hXfNow, device_is_my_type() is where the juice for a lockdown is. Just checking if the class, type and protocol match something is the worse security verification you can make (or the best, for someone willing to break it). If you need something secure, use crypto and Certificate Authentication or stuff like that. Something simple for an storage key could be:”hjÝhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K@hj’hžhubj)”}”(hX¡function device_is_my_type() { echo 1 > authorized # temporarily authorize it # FIXME: make sure none can mount it mount DEVICENODE /mntpoint sum=$(md5sum /mntpoint/.signature) if [ $sum = $(cat /etc/lockdown/keysum) ] then echo "We are good, connected" umount /mntpoint # Other stuff so others can use it else echo 0 > authorized fi }”h]”hX¡function device_is_my_type() { echo 1 > authorized # temporarily authorize it # FIXME: make sure none can mount it mount DEVICENODE /mntpoint sum=$(md5sum /mntpoint/.signature) if [ $sum = $(cat /etc/lockdown/keysum) ] then echo "We are good, connected" umount /mntpoint # Other stuff so others can use it else echo 0 > authorized fi }”…””}”(hhhjìubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h KGhj’hžhubh¸)”}”(hXOf course, this is lame, you'd want to do a real certificate verification stuff with PKI, so you don't depend on a shared secret, etc, but you get the idea. Anybody with access to a device gadget kit can fake descriptors and device info. Don't trust that. You are welcome.”h]”hXOf course, this is lame, you’d want to do a real certificate verification stuff with PKI, so you don’t depend on a shared secret, etc, but you get the idea. Anybody with access to a device gadget kit can fake descriptors and device info. Don’t trust that. You are welcome.”…””}”(hjühjúhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KXhj’hžhubeh}”(h]”Œexample-system-lockdown-lame”ah ]”h"]”Œexample system lockdown (lame)”ah$]”h&]”uh1h¡hhûhžhhŸh¶h K*ubh¢)”}”(hhh]”(h§)”}”(hŒInterface authorization”h]”hŒInterface authorization”…””}”(hjhjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjhžhhŸh¶h K`ubh¸)”}”(hŒzThere is a similar approach to allow or deny specific USB interfaces. That allows to block only a subset of an USB device.”h]”hŒzThere is a similar approach to allow or deny specific USB interfaces. That allows to block only a subset of an USB device.”…””}”(hj#hj!hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kbhjhžhubh¸)”}”(hŒAuthorize an interface::”h]”hŒAuthorize an interface:”…””}”(hŒAuthorize an interface:”hj/hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kehjhžhubj)”}”(hŒ4$ echo 1 > /sys/bus/usb/devices/INTERFACE/authorized”h]”hŒ4$ echo 1 > /sys/bus/usb/devices/INTERFACE/authorized”…””}”(hhhj>ubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h Kghjhžhubh¸)”}”(hŒDeauthorize an interface::”h]”hŒDeauthorize an interface:”…””}”(hŒDeauthorize an interface:”hjLhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kihjhžhubj)”}”(hŒ4$ echo 0 > /sys/bus/usb/devices/INTERFACE/authorized”h]”hŒ4$ echo 0 > /sys/bus/usb/devices/INTERFACE/authorized”…””}”(hhhj[ubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h Kkhjhžhubh¸)”}”(hŒQThe default value for new interfaces on a particular USB bus can be changed, too.”h]”hŒQThe default value for new interfaces on a particular USB bus can be changed, too.”…””}”(hjkhjihžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kmhjhžhubh¸)”}”(hŒAllow interfaces per default::”h]”hŒAllow interfaces per default:”…””}”(hŒAllow interfaces per default:”hjwhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kphjhžhubj)”}”(hŒA$ echo 1 > /sys/bus/usb/devices/usbX/interface_authorized_default”h]”hŒA$ echo 1 > /sys/bus/usb/devices/usbX/interface_authorized_default”…””}”(hhhj†ubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h Krhjhžhubh¸)”}”(hŒDeny interfaces per default::”h]”hŒDeny interfaces per default:”…””}”(hŒDeny interfaces per default:”hj”hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Kthjhžhubj)”}”(hŒA$ echo 0 > /sys/bus/usb/devices/usbX/interface_authorized_default”h]”hŒA$ echo 0 > /sys/bus/usb/devices/usbX/interface_authorized_default”…””}”(hhhj£ubah}”(h]”h ]”h"]”h$]”h&]”j+j,uh1jhŸh¶h Kvhjhžhubh¸)”}”(hŒfPer default the interface_authorized_default bit is 1. So all interfaces would authorized per default.”h]”hŒfPer default the interface_authorized_default bit is 1. So all interfaces would authorized per default.”…””}”(hj³hj±hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KxhjhžhubhŒdefinition_list”“”)”}”(hhh]”hŒdefinition_list_item”“”)”}”(hŒ™Note: If a deauthorized interface will be authorized so the driver probing must be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe ”h]”(hŒterm”“”)”}”(hŒNote:”h]”hŒNote:”…””}”(hjÎhjÌhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÊhŸh¶h K}hjÆubhŒ definition”“”)”}”(hhh]”h¸)”}”(hŒ’If a deauthorized interface will be authorized so the driver probing must be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe”h]”hŒ’If a deauthorized interface will be authorized so the driver probing must be triggered manually by writing INTERFACE to /sys/bus/usb/drivers_probe”…””}”(hjáhjßhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K|hjÜubah}”(h]”h ]”h"]”h$]”h&]”uh1jÚhjÆubeh}”(h]”h ]”h"]”h$]”h&]”uh1jÄhŸh¶h K}hjÁubah}”(h]”h ]”h"]”h$]”h&]”uh1j¿hjhžhhŸh¶h Nubh¸)”}”(hŒžFor drivers that need multiple interfaces all needed interfaces should be authorized first. After that the drivers should be probed. This avoids side effects.”h]”hŒžFor drivers that need multiple interfaces all needed interfaces should be authorized first. After that the drivers should be probed. This avoids side effects.”…””}”(hjhjÿhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khjhžhubeh}”(h]”Œinterface-authorization”ah ]”h"]”Œinterface authorization”ah$]”h&]”uh1h¡hhûhžhhŸh¶h K`ubeh}”(h]”Œusage”ah ]”h"]”Œusage”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubeh}”(h]”Œauthorizing (or not) your usb devices to connect to the system”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”jHŒ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Œ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”‰Œfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œ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”‰Œ embed_images”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j"jjjj j jjuŒ nametypes”}”(j"NjNj NjNuh}”(jh£jhûj j’jjuŒ 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.