Skip to content

eBPF-based security platform

bpf: move errno and seal xattr defines into bpf/lib headers

Daniel Borkmannba45cb328f54
diff --git a/bpf/lib/errno.h b/bpf/lib/errno.h
new file mode 100644
index 00000000..0856e6b3
--- /dev/null
+++ b/bpf/lib/errno.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
+/* Copyright (c) 2026 Authors of shirudo */
+
+#ifndef SHIRUDO_BPF_ERRNO_H
+#define SHIRUDO_BPF_ERRNO_H
+
+#ifndef EPERM
+#define EPERM 1
+#endif
+#ifndef ENOMEM
+#define ENOMEM 12
+#endif
+#ifndef EACCES
+#define EACCES 13
+#endif
+#ifndef ENOSYS
+#define ENOSYS 38
+#endif
+#ifndef ENODATA
+#define ENODATA 61
+#endif
+#ifndef EOPNOTSUPP
+#define EOPNOTSUPP 95
+#endif
+
+#endif /* SHIRUDO_BPF_ERRNO_H */
diff --git a/bpf/lib/lsm.h b/bpf/lib/lsm.h
index 0f6f2327..a2b7f1a5 100644
--- a/bpf/lib/lsm.h
+++ b/bpf/lib/lsm.h
@@ -9,18 +9,8 @@
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
-#ifndef EPERM
-#define EPERM 1
-#endif
-#ifndef EACCES
-#define EACCES 13
-#endif
-#ifndef ENOMEM
-#define ENOMEM 12
-#endif
-#ifndef ENOSYS
-#define ENOSYS 38
-#endif
+#include "errno.h"
+
#ifndef FMODE_WRITE
#define FMODE_WRITE 0x2
#endif
diff --git a/bpf/lib/xattr.h b/bpf/lib/xattr.h
new file mode 100644
index 00000000..30281f32
--- /dev/null
+++ b/bpf/lib/xattr.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
+/* Copyright (c) 2026 Authors of shirudo */
+
+#ifndef SHIRUDO_BPF_XATTR_H
+#define SHIRUDO_BPF_XATTR_H
+
+#define XATTR "security.bpf.shirudo"
+/* The label is a SHA-256 hex string (util/seal.h) -- always 64 bytes. */
+#define LABEL_LEN 64
+
+#endif /* SHIRUDO_BPF_XATTR_H */
diff --git a/bpf/seal.c b/bpf/seal.c
index a75654b5..9d098c53 100644
--- a/bpf/seal.c
+++ b/bpf/seal.c
@@ -3,29 +3,7 @@
/* Shirudo retains the writable-state label seal and trusts runtime execs. */
#include "verity_policy.h"
-
-#ifndef ENOMEM
-#define ENOMEM 12
-#endif
-#ifndef EPERM
-#define EPERM 1
-#endif
-#ifndef EACCES
-#define EACCES 13
-#endif
-#ifndef ENODATA
-#define ENODATA 61
-#endif
-#ifndef EOPNOTSUPP
-#define EOPNOTSUPP 95
-#endif
-#ifndef FMODE_WRITE
-#define FMODE_WRITE 0x2
-#endif
-
-#define XATTR "security.bpf.shirudo"
-/* The label is a SHA-256 hex string (util/seal.h) -- always 64 bytes. */
-#define LABEL_LEN 64
+#include "xattr.h"
/*
* Xattr kfuncs may sleep and need dynptr-backed map memory. Task storage keeps