feat: add device passthru mode#1651
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for device passthrough in the container runtime. It updates the API schema and CLI to support a new "passthru" device option, which triggers a bind-mount of the host's /dev and /run/udev directories into the container. The review feedback suggests security hardening for the /dev bind-mount by adding nosuid and nodev options to mitigate risks, as well as minor performance optimizations in loops that check for the passthrough configuration.
| if (devPassthru) { | ||
| devMount = { | ||
| Mount{ .destination = "/dev", | ||
| .options = string_list{ "rbind" }, |
There was a problem hiding this comment.
For security hardening, it's recommended to add nosuid and nodev to the mount options when bind-mounting the host's /dev directory. This helps mitigate potential security risks associated with device passthrough by preventing SUID binaries from being executed and character/block devices from being created within the container's /dev mount.
.options = string_list{ "rbind", "nosuid", "nodev" },Add --device-mode option to allow containers to share the host's /dev directory. Signed-off-by: reddevillg <reddevillg@gmail.com>
deepin pr auto reviewGit Diff 代码审查报告我已仔细审查了这段代码,该代码主要实现了设备透传(device passthrough)功能,允许容器直接访问主机设备。以下是我的详细审查意见: 1. 语法和逻辑审查1.1 语法正确性
1.2 逻辑问题
2. 代码质量审查2.1 命名规范
2.2 代码结构
2.3 可维护性
3. 代码性能审查
4. 代码安全审查4.1 安全风险
4.2 安全建议
5. 其他建议
总结这段代码实现了设备透传功能,整体设计合理,语法正确。主要改进点在于:
这些改进将有助于提高代码的安全性、可靠性和可维护性。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengbo11, reddevillg The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Add --device-mode option to allow containers to share the host's /dev directory.