€•>Œ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/usb/authorization”Œ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/usb/authorization”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(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”…””}”hhZsbah}”(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”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ%/translations/ko_KR/usb/authorization”Œ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/usb/authorization”Œ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/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¼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 <”…””}”(hhÍh²hh³Nh´NubhŒ reference”“”)”}”(hŒinaky@linux.intel.com”h]”hŒinaky@linux.intel.com”…””}”(hh×h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:inaky@linux.intel.com”uh1hÕhhÍubhŒ> 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ñ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ÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hh·h²hubh¶)”}”(hhh]”(h»)”}”(hŒUsage”h]”hŒUsage”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´KubhÌ)”}”(hŒAuthorize a device to connect::”h]”hŒAuthorize a device to connect:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj 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”…””}”hj.sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j,h³hÊh´Khj h²hubhÌ)”}”(hŒDe-authorize a device::”h]”hŒDe-authorize a device:”…””}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj h²hubj-)”}”(hŒ1$ echo 0 > /sys/bus/usb/devices/DEVICE/authorized”h]”hŒ1$ echo 0 > /sys/bus/usb/devices/DEVICE/authorized”…””}”hjLsbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³hÊh´Khj 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):”…””}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj 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”…””}”hjhsbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³hÊh´Khj h²hubhÌ)”}”(hŒRemove the lock down::”h]”hŒRemove the lock down:”…””}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hj 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”…””}”hj„sbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³hÊh´K"hj 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’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K$hj h²hubh¶)”}”(hhh]”(h»)”}”(hŒExample system lockdown (lame)”h]”hŒExample system lockdown (lame)”…””}”(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):”…””}”(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”…””}”hj¿sbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³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:”…””}”(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”…””}”hjÛsbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³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:”…””}”(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 }”…””}”hj÷sbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³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.”…””}”(hjh²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µhj h²hh³hÊh´K*ubh¶)”}”(hhh]”(h»)”}”(hŒInterface authorization”h]”hŒInterface authorization”…””}”(hjh²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,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kbhjh²hubhÌ)”}”(hŒAuthorize an interface::”h]”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”…””}”hjHsbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³hÊh´Kghjh²hubhÌ)”}”(hŒDeauthorize an interface::”h]”hŒDeauthorize an interface:”…””}”(hjVh²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”…””}”hjdsbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³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.”…””}”(hjrh²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:”…””}”(hj€h²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”…””}”hjŽsbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³hÊh´Krhjh²hubhÌ)”}”(hŒDeny interfaces per default::”h]”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”…””}”hjªsbah}”(h]”h ]”h"]”h$]”h&]”j<j=uh1j,h³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¸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Ó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æ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.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khjh²hubeh}”(h]”Œinterface-authorization”ah ]”h"]”Œinterface authorization”ah$]”h&]”uh1hµhj 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”jOŒ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!jjjjjuŒ nametypes”}”(j)‰j!‰j‰j‰uh}”(j&h·jj jj 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.