docker - Docker seccomp 适用于 alpine/busybox 但不适用于 ubuntu
问题描述
我有这个 seccomp 个人资料:
{
"defaultAction": "SCMP_ACT_ALLOW",
"architectures": [
"SCMP_ARCH_X86_64",
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
],
"syscalls": [
{
"name": "chmod",
"action": "SCMP_ACT_ERRNO",
"args": []
},
{
"name": "chown",
"action": "SCMP_ACT_ERRNO",
"args": []
},
{
"name": "chown32",
"action": "SCMP_ACT_ERRNO",
"args": []
} }
当使用它来过滤 alpine 或 busybox 容器上的系统调用时,它可以工作
docker run -it --security-opt seccomp=profile.json busybox /bin/sh
// chmod 777 /etc/hosts
// Error: operation not permitted
但是对 ubuntu:18.04 没有影响
docker run -it --security-opt seccomp=profile.json ubuntu:18.04 /bin/sh
// chmod 777 /etc/hosts
// Success
Docker 版本是 19.03.8
有没有人遇到过这个问题?
解决方案
从docker-lab看来,您还缺少两个属性以使其正常与 Linux 一起工作
default-no-chmod.json 配置文件是对 default.json 配置文件> 的修改,其中
chmod()
、fchmod()
和chmodat()
syscall 从其白名单中删除。
{
"defaultAction": "SCMP_ACT_ALLOW",
"architectures": [
"SCMP_ARCH_X86_64",
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
],
"syscalls": [
{
"name": "chmod",
"action": "SCMP_ACT_ERRNO",
"args": []
},
{
"name": "fchmod",
"action": "SCMP_ACT_ERRNO",
"args": [
]
},
{
"name": "fchmodat",
"action": "SCMP_ACT_ERRNO",
"args": [
]
},
{
"name": "chown",
"action": "SCMP_ACT_ERRNO",
"args": []
},
{
"name": "chown32",
"action": "SCMP_ACT_ERRNO",
"args": []
}]
}
现在,如果您从 ubuntu 尝试过,您将得到预期的结果
docker run -it --security-opt seccomp=profile.json ubuntu:18.04 /bin/sh -c " chmod +x /etc/hosts"
chmod: changing permissions of '/etc/hosts': Operation not permitted
此外,busybox 的结果相同
docker run -it --security-opt seccomp=profile.json busybox /bin/sh -c " chmod +x /etc/host"
chmod: /etc/host: No such file or directory
推荐阅读
- android - getApplicationDocumentsDirectory 在颤振桌面(Windows)上不起作用
- java - 为什么在这个数组的线性搜索的 while 循环条件中需要 !found 而不是 found ?
- c# - 如何制作 Roblox FPS 解锁器?
- string - 在另一个字符串中重新加载一个变量字符串
- c# - 单击其子项时不会触发 UserControl 的 MouseClickEvent
- algorithm - 在具有 n*2^n 个元素的平衡二叉搜索树中搜索元素的最坏情况运行时间是多少?
- java - 如何在简单规则中使用变量?
- css - 在 Vue JS 中使用 SVG Sprite 作为 CSS 背景图片
- ffmpeg - Nginx RTMP 拉取 HLS 流
- javascript - 使用 $.getJSON() 后如何在控制台中访问 json 数据