我正在 Ubuntu 机器上开发 eBPF 程序:
$ uname -a
Linux ubuntu-bionic 4.18.0-16-generic #17~18.04.1-Ubuntu SMP Tue Feb 12 13:35:51 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
为此,我需要bpf.h许多定义以及bpf_helpers.h辅助函数定义。我安装了一个带有标题的新内核:
apt-get update -y
apt-get install -y linux-image-4.18.0-16-generic linux-headers-4.18.0-16-generic
Run Code Online (Sandbox Code Playgroud)
标头包括bpf.h:
$ find /usr/src/linux-headers-4.18.0-16 -name bpf.h
/usr/src/linux-headers-4.18.0-16/include/uapi/linux/bpf.h
/usr/src/linux-headers-4.18.0-16/include/linux/bpf.h
Run Code Online (Sandbox Code Playgroud)
但不是bpf_helpers.h:
$ find /usr/src/linux-headers-4.18.0-16 -name bpf_helpers.h
Run Code Online (Sandbox Code Playgroud)
如何为我的内核获取此文件?为什么它不包含在分发标头中?
我可以签出特定版本的 Linux 内核或从master获取文件,但发行版可能会对上游进行更改,这让我这样做感到不舒服。
我正在阅读'UNIX网络编程:套接字网络API',在示例代码中,它们具有错误处理功能,其中包含以下行:
fflush(stdout); /* in case stdout and stderr are the same */
fputs(buf, stderr);
fflush(stderr);
Run Code Online (Sandbox Code Playgroud)
其中buf包含错误描述.我不明白为什么在第一行的stdout上使用fflush以及注释解释其使用原因的原因.
我正在尝试将我的GKE集群配置为从同一项目中的私有GCR仓库中提取.我没有使用OAuth范围,但已将最小特权服务帐户与默认节点池关联,并为其提供了roles/storage.objectViewer权限.
但是,在尝试访问此图像时,我仍然收到以下信息:
Failed to pull image "eu.gcr.io/<project>/<image>": rpc error: code = Unknown desc = Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
我是否还需要配置imagePullSecrets或roles/storage.objectViewer权限是否足够?
PodSecurityPolicy 文档中的第二个示例策略包含以下 PodSecurityPolicy 片段
...
spec:
privileged: false
# Required to prevent escalations to root.
allowPrivilegeEscalation: false
# This is redundant with non-root + disallow privilege escalation,
# but we can provide it for defense in depth.
requiredDropCapabilities:
- ALL
...
Run Code Online (Sandbox Code Playgroud)
为什么删除非 root 用户的所有功能是多余的 + 禁止权限提升?您可以拥有一个没有权限提升的容器进程,它是非 root 但具有有效功能,对吗?
Docker 似乎无法做到这一点:
$ docker run --cap-add SYS_ADMIN --user 1000 ubuntu grep Cap /proc/self/status
CapInh: 00000000a82425fb
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 00000000a82425fb
CapAmb: 0000000000000000
Run Code Online (Sandbox Code Playgroud)
即使在尝试明确添加它们时,所有有效功能也已被删除。但是其他容器运行时可以实现它,所以这个评论只是 Docker 特定的吗?
我编写了以下 eBPF 程序来对数据包进行计数:
#include <linux/version.h>
#include <uapi/linux/bpf.h>
#include "include/bpf_map.h"
#include "include/bpf_helpers.h"
struct bpf_map_def SEC("maps/count") count_map = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(__u64),
.max_entries = 1024,
};
SEC("cgroup/skb")
int count_packets(struct __sk_buff *skb) {
char debug[] = "count_packets\n";
bpf_trace_printk(debug, sizeof(debug));
int packets_key = 0;
__u64 *packets = 0;
packets = bpf_map_lookup_elem(&count_map, &packets_key);
if (packets == 0)
return 0;
*packets += 1;
// allow access
return 1;
}
char _license[] SEC("license") = "GPL";
u32 _version SEC("version") = LINUX_VERSION_CODE;
Run Code Online (Sandbox Code Playgroud)
我还有一个用户空间组件,它将程序加载为 …
如上所述这里,Knative的激活接收和缓冲的要求不活跃修订。
这个路由是如何实现的?我在应用程序的命名空间中看到的只是一个 VirtualService 路由对修订版的请求,所以我看不到进入网格的流量是如何重定向到 Activator 的。
Knative 服务版本:0.9.0
我正在尝试编写一个 eBPF 程序来记录来自系统上运行的容器的特定系统调用的每次调用。我正在使用bcc并且可以使用bpf_get_current_pid_tgid().
从用户空间我可以检查 proc 文件系统以确定进程的命名空间是否与根命名空间不同,以猜测它是否是一个容器进程,但我不知道你如何从内核空间做到这一点?
bpf ×3
ebpf ×3
kubernetes ×3
linux-kernel ×3
c ×2
docker ×2
linux ×2
bcc-bpf ×1
containers ×1
envoyproxy ×1
fflush ×1
header-files ×1
istio ×1
knative ×1
stderr ×1
stdout ×1
unix ×1