From: Yanteng Si <si.yanteng@linux.dev>
To: Kefan Bai <baikefan@leap-io-kernel.com>, alexs@kernel.org
Cc: dzm91@hust.edu.cn, corbet@lwn.net, linux-doc@vger.kernel.org,
doubled@leap-io-kernel.com
Subject: Re: [PATCH v3 3/8] docs/zh_CN: Add authorization.rst translation
Date: Mon, 1 Dec 2025 14:54:53 +0800 [thread overview]
Message-ID: <343e5b82-e78a-483b-a8db-57bef4f447eb@linux.dev> (raw)
In-Reply-To: <b4328d04b19ca0d16307aeaa3cc8d10ad2c01bdd.1763984424.git.baikefan@leap-io-kernel.com>
在 2025/11/24 21:34, Kefan Bai 写道:
> Translate .../usb/authorization.rst into Chinese
>
> Update the translation through commit f176638af476
> ("USB: Remove Wireless USB and UWB documentation")
>
> Signed-off-by: Kefan Bai <baikefan@leap-io-kernel.com>
> ---
> .../translations/zh_CN/usb/authorization.rst | 125 ++++++++++++++++++
> 1 file changed, 125 insertions(+)
> create mode 100644 Documentation/translations/zh_CN/usb/authorization.rst
>
> diff --git a/Documentation/translations/zh_CN/usb/authorization.rst b/Documentation/translations/zh_CN/usb/authorization.rst
> new file mode 100644
> index 000000000000..2bcb3e9d4c5a
> --- /dev/null
> +++ b/Documentation/translations/zh_CN/usb/authorization.rst
> @@ -0,0 +1,125 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +.. include:: ../disclaimer-zh_CN.rst
> +
> +:Original: Documentation/usb/authorization.rst
> +:翻译:
> +
> + 白钶凡 Kefan Bai <baikefan@leap-io-kernel.com>
> +
> +:校译:
> +
> +
> +==============================================================
> +授权(或不授权)USB设备连接到系统
> +==============================================================
It's too long, please trim them.
Thanks,
Yanteng
> +
> +版权 (C) 2007 Inaky Perez-Gonzalez <inaky@linux.intel.com> 因特尔公司
> +
> +此功能允许你控制系统中USB设备的使用权限。
> +你可以借此实现USB设备的锁定,并由用户空间完全控制。
> +
> +目前为止,当插入一个USB设备时,系统会配置该USB设备,其接口会立即对用户开放。
> +通过此修改,只有在root授权配置设备后,用户才能使用它。
> +
> +
> +使用方法
> +=========
> +
> +授权设备连接::
> +
> + $ echo 1 > /sys/bus/usb/devices/DEVICE/authorized
> +
> +取消授权设备连接::
> + $ echo 0 > /sys/bus/usb/devices/DEVICE/authorized
> +
> +将新连接到hostX的设备默认设置为未授权(即:锁定)::
> +
> + $ echo 0 > /sys/bus/usb/devices/usbX/authorized_default
> +
> +解除锁定::
> +
> + $ echo 1 > /sys/bus/usb/devices/usbX/authorized_default
> +
> +默认情况下,所有USB设备都是授权的。
> +向authorized_default属性写入 "2" 会使内核默认只授权连接到内部USB端口的设备。
> +
> +系统锁定示例(简单示例)
> +------------------------------
> +
> +假设你想实现一个锁定功能,要求只有类型为XYZ的设备可以连接
> +(例如,它是一个带有可见USB端口的自助服务终端)::
> +
> + 启动系统
> + rc.local ->
> +
> + for host in /sys/bus/usb/devices/usb*
> + do
> + echo 0 > $host/authorized_default
> + done
> +
> +将一个脚本挂接到udev,当插入新的USB设备时,该脚本就会被自动触发::
> +
> + if device_is_my_type $DEV
> + then
> + echo 1 > $device_path/authorized
> + done
> +
> +
> +这里的device_is_my_type()就是实现锁定的关键所在。
> +仅仅检查class、type 和protocol是否匹配某个值,
> +是最差的安全验证方式(但对于想要破解的人却是最容易的)。
> +如果你需要真正安全的方案,应使用加密、证书认证等手段。
> +一个针对存储密钥的简单示例::
> +
> + function device_is_my_type()
> + {
> + echo 1 > authorized # 暂时授权它
> + # FIXME: 确保没有人能够挂载它
> + mount DEVICENODE /mntpoint
> + sum=$(md5sum /mntpoint/.signature)
> + if [ $sum = $(cat /etc/lockdown/keysum) ]
> + then
> + echo "We are good, connected"
> + umount /mntpoint
> + # 添加一些额外的内容,以便其他人也可以使用它
> + else
> + echo 0 > authorized
> + fi
> + }
> +
> +
> +当然,这种做法很简陋;实际上你应该使用基于PKI的真正证书验证,
> +这样就不会依赖共享密钥之类的东西。不过你明白我的意思。
> +任何拿到设备仿真工具包的人都能伪造描述符和设备信息。
> +所以千万不要信任这些信息。
> +
> +接口授权
> +---------
> +
> +也有类似的方法用于允许或拒绝特定USB接口。这允许只阻止USB设备的一个子集。
> +
> +授权接口::
> +
> + $ echo 1 > /sys/bus/usb/devices/INTERFACE/authorized
> +
> +取消授权接口::
> +
> + $ echo 0 > /sys/bus/usb/devices/INTERFACE/authorized
> +
> +也可以更改新接口在特定USB总线上的默认值。
> +
> +默认允许接口::
> +
> + $ echo 1 > /sys/bus/usb/devices/usbX/interface_authorized_default
> +
> +默认拒绝接口::
> + $ echo 0 > /sys/bus/usb/devices/usbX/interface_authorized_default
> +
> +默认情况下,interface_authorized_default位为1。
> +因此,所有接口默认都是授权的。
> +
> +注意:
> + 如果要对一个未授权的接口进行授权,则必须通过将INTERFACE写入
> + /sys/bus/usb/drivers_probe来手动触发驱动程序进行探测。
> + 对于使用多个接口的驱动程序,需要先对所有使用的接口进行授权。
> + 之后应探测驱动程序。这样做可以避免副作用。
> --
> 2.52.0
>
next prev parent reply other threads:[~2025-12-01 6:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 13:34 [PATCH v3 0/8] Add Chinese translation for USB subsystem Kefan Bai
2025-11-24 13:34 ` [PATCH v3 1/8] docs/zh_CN: Add index.rst translation Kefan Bai
2025-11-24 13:34 ` [PATCH v3 2/8] docs/zh_CN: Add acm.rst translation Kefan Bai
2025-12-01 6:44 ` Yanteng Si
2025-11-24 13:34 ` [PATCH v3 3/8] docs/zh_CN: Add authorization.rst translation Kefan Bai
2025-12-01 6:54 ` Yanteng Si [this message]
2025-12-02 8:11 ` BaiKefan
2025-12-02 8:36 ` [RESEND] " BaiKefan
2025-11-24 13:34 ` [PATCH v3 4/8] docs/zh_CN: Add chipidea.rst translation Kefan Bai
2025-11-24 13:34 ` [PATCH v3 5/8] docs/zh_CN: Add dwc3.rst translation Kefan Bai
2025-11-24 13:34 ` [PATCH v3 6/8] docs/zh_CN: Add ehci.rst translation Kefan Bai
2025-11-24 13:34 ` [PATCH v3 7/8] docs/zh_CN: Add usbmon.rst translation Kefan Bai
2025-11-24 13:34 ` [PATCH v3 8/8] docs/zh_CN: Add CREDITS translation Kefan Bai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=343e5b82-e78a-483b-a8db-57bef4f447eb@linux.dev \
--to=si.yanteng@linux.dev \
--cc=alexs@kernel.org \
--cc=baikefan@leap-io-kernel.com \
--cc=corbet@lwn.net \
--cc=doubled@leap-io-kernel.com \
--cc=dzm91@hust.edu.cn \
--cc=linux-doc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).