Skip to content

Commit 015f2d2

Browse files
tetragon/windows: Add Multiple program attach types
Windows Loader had the process attach type hardcoded in the attach routine. This prevents us from loading other program types supported on Windows like cgroup/connect4 etc. This PR adds some more attach types. Signed-off-by: Anadi Anadi<[email protected]>
1 parent 792590e commit 015f2d2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pkg/sensors/program/loader_windows.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ import (
1717
)
1818

1919
var (
20-
attachTypeProcessGUID = makeGUID(0x66e20687, 0x9805, 0x4458, [8]byte{0xa0, 0xdb, 0x38, 0xe2, 0x20, 0xd3, 0x16, 0x85})
20+
attachTypeProcessGUID = makeGUID(0x66e20687, 0x9805, 0x4458, [8]byte{0xa0, 0xdb, 0x38, 0xe2, 0x20, 0xd3, 0x16, 0x85})
21+
attachTypeCgroupInet4ConnectGUID = makeGUID(0xa82e37b1, 0xaee7, 0x11ec, [8]byte{0x9a, 0x30, 0x18, 0x60, 0x24, 0x89, 0xbe, 0xee})
22+
attachTypeCgroupInet6ConnectGUID = makeGUID(0xa82e37b2, 0xaee7, 0x11ec, [8]byte{0x9a, 0x30, 0x18, 0x60, 0x24, 0x89, 0xbe, 0xee})
23+
attachTypeCgroupInet4RecvAcceptGUID = makeGUID(0xa82e37b3, 0xaee7, 0x11ec, [8]byte{0x9a, 0x30, 0x18, 0x60, 0x24, 0x89, 0xbe, 0xee})
24+
attachTypeCgroupInet6RecvAcceptGUID = makeGUID(0xa82e37b4, 0xaee7, 0x11ec, [8]byte{0x9a, 0x30, 0x18, 0x60, 0x24, 0x89, 0xbe, 0xee})
2125
)
2226

2327
func makeGUID(data1 uint32, data2 uint16, data3 uint16, data4 [8]byte) windows.GUID {
@@ -34,6 +38,27 @@ func RawAttachWithFlags(_ int, _ uint32) AttachFunc {
3438
return winAttachStub
3539
}
3640

41+
func getAttachTypeForAttachTarget(attachTarget string) (ebpf.AttachType, error) {
42+
var attachTypeGuid string
43+
switch attachTarget {
44+
case "process":
45+
attachTypeGuid = attachTypeProcessGUID.String()
46+
case "cgroup/connect4":
47+
attachTypeGuid = attachTypeCgroupInet4ConnectGUID.String()
48+
case "cgroup/connect6":
49+
attachTypeGuid = attachTypeCgroupInet6ConnectGUID.String()
50+
case "cgroup/recv_accept4":
51+
attachTypeGuid = attachTypeCgroupInet4RecvAcceptGUID.String()
52+
case "cgroup/recv_accept6":
53+
attachTypeGuid = attachTypeCgroupInet6RecvAcceptGUID.String()
54+
55+
default:
56+
return ebpf.AttachNone, nil
57+
}
58+
59+
return ebpf.WindowsAttachTypeForGUID(attachTypeGuid)
60+
}
61+
3762
func windowsAttach(_ *Program, prog *ebpf.Program, _ *ebpf.ProgramSpec,
3863
_ string, _ string, _ ...string) (unloader.Unloader, error) {
3964

0 commit comments

Comments
 (0)