gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/sentry/kernel/BUILD (about) 1 load("//pkg/sync/locking:locking.bzl", "declare_mutex", "declare_rwmutex") 2 load("//tools:defs.bzl", "go_library", "go_test", "proto_library") 3 load("//tools/go_generics:defs.bzl", "go_template_instance") 4 5 package( 6 default_applicable_licenses = ["//:license"], 7 licenses = ["notice"], 8 ) 9 10 go_template_instance( 11 name = "atomicptr_bucket_slice", 12 out = "atomicptr_bucket_slice_unsafe.go", 13 package = "kernel", 14 prefix = "descriptorBucketSlice", 15 template = "//pkg/sync/atomicptr:generic_atomicptr", 16 types = { 17 "Value": "descriptorBucketSlice", 18 }, 19 ) 20 21 go_template_instance( 22 name = "atomicptr_bucket", 23 out = "atomicptr_bucket_unsafe.go", 24 package = "kernel", 25 prefix = "descriptorBucket", 26 template = "//pkg/sync/atomicptr:generic_atomicptr", 27 types = { 28 "Value": "descriptorBucket", 29 }, 30 ) 31 32 go_template_instance( 33 name = "atomicptr_descriptor", 34 out = "atomicptr_descriptor_unsafe.go", 35 package = "kernel", 36 prefix = "descriptor", 37 template = "//pkg/sync/atomicptr:generic_atomicptr", 38 types = { 39 "Value": "descriptor", 40 }, 41 ) 42 43 declare_mutex( 44 name = "cpu_clock_mutex", 45 out = "cpu_clock_mutex.go", 46 package = "kernel", 47 prefix = "cpuClock", 48 ) 49 50 declare_mutex( 51 name = "user_counters_mutex", 52 out = "user_counters_mutex.go", 53 package = "kernel", 54 prefix = "userCounters", 55 ) 56 57 declare_rwmutex( 58 name = "taskset_mutex", 59 out = "taskset_mutex.go", 60 package = "kernel", 61 prefix = "taskSet", 62 ) 63 64 declare_mutex( 65 name = "task_mutex", 66 out = "task_mutex.go", 67 nested_lock_names = ["child"], 68 package = "kernel", 69 prefix = "task", 70 ) 71 72 declare_mutex( 73 name = "task_work_mutex", 74 out = "task_work_mutex.go", 75 package = "kernel", 76 prefix = "taskWork", 77 ) 78 79 declare_mutex( 80 name = "cgroup_mutex", 81 out = "cgroup_mutex.go", 82 package = "kernel", 83 prefix = "cgroup", 84 ) 85 86 declare_mutex( 87 name = "fd_table_mutex", 88 out = "fd_table_mutex.go", 89 package = "kernel", 90 prefix = "fdTable", 91 ) 92 93 declare_mutex( 94 name = "running_tasks_mutex", 95 out = "running_tasks_mutex.go", 96 package = "kernel", 97 prefix = "runningTasks", 98 ) 99 100 declare_mutex( 101 name = "signal_handlers_mutex", 102 out = "signal_handlers_mutex.go", 103 nested_lock_names = ["tg"], 104 package = "kernel", 105 prefix = "signalHandlers", 106 ) 107 108 declare_mutex( 109 name = "thread_group_timer_mutex", 110 out = "thread_group_timer_mutex.go", 111 package = "kernel", 112 prefix = "threadGroupTimer", 113 ) 114 115 declare_mutex( 116 name = "cgroup_mounts_mutex", 117 out = "cgroup_mounts_mutex.go", 118 package = "kernel", 119 prefix = "cgroupMounts", 120 ) 121 122 go_template_instance( 123 name = "pending_signals_list", 124 out = "pending_signals_list.go", 125 package = "kernel", 126 prefix = "pendingSignal", 127 template = "//pkg/ilist:generic_list", 128 types = { 129 "Element": "*pendingSignal", 130 "Linker": "*pendingSignal", 131 }, 132 ) 133 134 go_template_instance( 135 name = "process_group_list", 136 out = "process_group_list.go", 137 package = "kernel", 138 prefix = "processGroup", 139 template = "//pkg/ilist:generic_list", 140 types = { 141 "Element": "*ProcessGroup", 142 "Linker": "*ProcessGroup", 143 }, 144 ) 145 146 go_template_instance( 147 name = "seqatomic_taskgoroutineschedinfo", 148 out = "seqatomic_taskgoroutineschedinfo_unsafe.go", 149 package = "kernel", 150 suffix = "TaskGoroutineSchedInfo", 151 template = "//pkg/sync/seqatomic:generic_seqatomic", 152 types = { 153 "Value": "TaskGoroutineSchedInfo", 154 }, 155 ) 156 157 go_template_instance( 158 name = "session_list", 159 out = "session_list.go", 160 package = "kernel", 161 prefix = "session", 162 template = "//pkg/ilist:generic_list", 163 types = { 164 "Element": "*Session", 165 "Linker": "*Session", 166 }, 167 ) 168 169 go_template_instance( 170 name = "task_list", 171 out = "task_list.go", 172 package = "kernel", 173 prefix = "task", 174 template = "//pkg/ilist:generic_list", 175 types = { 176 "Element": "*Task", 177 "Linker": "*Task", 178 }, 179 ) 180 181 go_template_instance( 182 name = "fd_table_refs", 183 out = "fd_table_refs.go", 184 package = "kernel", 185 prefix = "FDTable", 186 template = "//pkg/refs:refs_template", 187 types = { 188 "T": "FDTable", 189 }, 190 ) 191 192 go_template_instance( 193 name = "fs_context_refs", 194 out = "fs_context_refs.go", 195 package = "kernel", 196 prefix = "FSContext", 197 template = "//pkg/refs:refs_template", 198 types = { 199 "T": "FSContext", 200 }, 201 ) 202 203 go_template_instance( 204 name = "process_group_refs", 205 out = "process_group_refs.go", 206 package = "kernel", 207 prefix = "ProcessGroup", 208 template = "//pkg/refs:refs_template", 209 types = { 210 "T": "ProcessGroup", 211 }, 212 ) 213 214 go_template_instance( 215 name = "session_refs", 216 out = "session_refs.go", 217 package = "kernel", 218 prefix = "Session", 219 template = "//pkg/refs:refs_template", 220 types = { 221 "T": "Session", 222 }, 223 ) 224 225 proto_library( 226 name = "uncaught_signal", 227 srcs = ["uncaught_signal.proto"], 228 visibility = ["//visibility:public"], 229 deps = ["//pkg/sentry/arch:registers_proto"], 230 ) 231 232 go_library( 233 name = "kernel", 234 srcs = [ 235 "aio.go", 236 "atomicptr_bucket_slice_unsafe.go", 237 "atomicptr_bucket_unsafe.go", 238 "atomicptr_descriptor_unsafe.go", 239 "cgroup.go", 240 "cgroup_mounts_mutex.go", 241 "cgroup_mutex.go", 242 "context.go", 243 "cpu_clock_mutex.go", 244 "fd_table.go", 245 "fd_table_mutex.go", 246 "fd_table_refs.go", 247 "fd_table_unsafe.go", 248 "fs_context.go", 249 "fs_context_refs.go", 250 "ipc_namespace.go", 251 "kcov.go", 252 "kcov_unsafe.go", 253 "kernel.go", 254 "kernel_opts.go", 255 "kernel_state.go", 256 "pending_signals.go", 257 "pending_signals_list.go", 258 "pending_signals_state.go", 259 "posixtimer.go", 260 "process_group_list.go", 261 "process_group_refs.go", 262 "ptrace.go", 263 "ptrace_amd64.go", 264 "ptrace_arm64.go", 265 "rseq.go", 266 "running_tasks_mutex.go", 267 "seccheck.go", 268 "seccomp.go", 269 "seqatomic_taskgoroutineschedinfo_unsafe.go", 270 "session_list.go", 271 "session_refs.go", 272 "sessions.go", 273 "signal.go", 274 "signal_handlers.go", 275 "signal_handlers_mutex.go", 276 "syscalls.go", 277 "syscalls_state.go", 278 "syslog.go", 279 "task.go", 280 "task_acct.go", 281 "task_block.go", 282 "task_cgroup.go", 283 "task_clone.go", 284 "task_context.go", 285 "task_exec.go", 286 "task_exit.go", 287 "task_futex.go", 288 "task_identity.go", 289 "task_image.go", 290 "task_key.go", 291 "task_list.go", 292 "task_log.go", 293 "task_mutex.go", 294 "task_net.go", 295 "task_run.go", 296 "task_sched.go", 297 "task_signals.go", 298 "task_start.go", 299 "task_stop.go", 300 "task_syscall.go", 301 "task_usermem.go", 302 "task_work.go", 303 "task_work_mutex.go", 304 "taskset_mutex.go", 305 "thread_group.go", 306 "thread_group_timer_mutex.go", 307 "threads.go", 308 "threads_impl.go", 309 "timekeeper.go", 310 "timekeeper_state.go", 311 "tty.go", 312 "user_counters_mutex.go", 313 "uts_namespace.go", 314 "vdso.go", 315 "version.go", 316 ], 317 imports = [ 318 "gvisor.dev/gvisor/pkg/bpf", 319 "gvisor.dev/gvisor/pkg/tcpip", 320 ], 321 marshal = True, 322 visibility = ["//:sandbox"], 323 deps = [ 324 ":uncaught_signal_go_proto", 325 "//pkg/abi", 326 "//pkg/abi/linux", 327 "//pkg/abi/linux/errno", 328 "//pkg/abi/sentry", 329 "//pkg/atomicbitops", 330 "//pkg/bitmap", 331 "//pkg/bits", 332 "//pkg/bpf", 333 "//pkg/cleanup", 334 "//pkg/context", 335 "//pkg/coverage", 336 "//pkg/cpuid", 337 "//pkg/devutil", 338 "//pkg/errors", 339 "//pkg/errors/linuxerr", 340 "//pkg/eventchannel", 341 "//pkg/fd", 342 "//pkg/fspath", 343 "//pkg/goid", 344 "//pkg/hostarch", 345 "//pkg/log", 346 "//pkg/marshal", 347 "//pkg/marshal/primitive", 348 "//pkg/metric", 349 "//pkg/refs", 350 "//pkg/safemem", 351 "//pkg/secio", 352 "//pkg/sentry/arch", 353 "//pkg/sentry/fsimpl/kernfs", 354 "//pkg/sentry/fsimpl/lock", 355 "//pkg/sentry/fsimpl/mqfs", 356 "//pkg/sentry/fsimpl/nsfs", 357 "//pkg/sentry/fsimpl/pipefs", 358 "//pkg/sentry/fsimpl/sockfs", 359 "//pkg/sentry/fsimpl/timerfd", 360 "//pkg/sentry/fsimpl/tmpfs", 361 "//pkg/sentry/hostcpu", 362 "//pkg/sentry/inet", 363 "//pkg/sentry/kernel/auth", 364 "//pkg/sentry/kernel/futex", 365 "//pkg/sentry/kernel/ipc", 366 "//pkg/sentry/kernel/mq", 367 "//pkg/sentry/kernel/msgqueue", 368 "//pkg/sentry/kernel/sched", 369 "//pkg/sentry/kernel/semaphore", 370 "//pkg/sentry/kernel/shm", 371 "//pkg/sentry/kernel/time", 372 "//pkg/sentry/limits", 373 "//pkg/sentry/loader", 374 "//pkg/sentry/memmap", 375 "//pkg/sentry/mm", 376 "//pkg/sentry/pgalloc", 377 "//pkg/sentry/platform", 378 "//pkg/sentry/seccheck", 379 "//pkg/sentry/seccheck/points:points_go_proto", 380 "//pkg/sentry/socket/netlink/port", 381 "//pkg/sentry/socket/unix/transport", 382 "//pkg/sentry/time", 383 "//pkg/sentry/unimpl", 384 "//pkg/sentry/unimpl:unimplemented_syscall_go_proto", 385 "//pkg/sentry/uniqueid", 386 "//pkg/sentry/usage", 387 "//pkg/sentry/vfs", 388 "//pkg/state", 389 "//pkg/state/statefile", 390 "//pkg/state/wire", 391 "//pkg/sync", 392 "//pkg/sync/locking", 393 "//pkg/syserr", 394 "//pkg/tcpip", 395 "//pkg/tcpip/stack", 396 "//pkg/usermem", 397 "//pkg/waiter", 398 "@org_golang_google_protobuf//proto:go_default_library", 399 "@org_golang_x_sys//unix:go_default_library", 400 ], 401 ) 402 403 go_test( 404 name = "kernel_test", 405 size = "small", 406 srcs = [ 407 "fd_table_test.go", 408 "table_test.go", 409 "task_test.go", 410 "timekeeper_test.go", 411 ], 412 library = ":kernel", 413 deps = [ 414 "//pkg/abi", 415 "//pkg/context", 416 "//pkg/errors/linuxerr", 417 "//pkg/hostarch", 418 "//pkg/sentry/arch", 419 "//pkg/sentry/contexttest", 420 "//pkg/sentry/kernel/sched", 421 "//pkg/sentry/limits", 422 "//pkg/sentry/pgalloc", 423 "//pkg/sentry/time", 424 "//pkg/sentry/usage", 425 "//pkg/sentry/vfs", 426 "//pkg/sync", 427 ], 428 )