|
23 | 23 | #include <memory>
|
24 | 24 | #include <optional>
|
25 | 25 | #include <string>
|
26 |
| -#include <type_traits> |
27 | 26 | #include <utility>
|
28 | 27 | #include <vector>
|
29 | 28 |
|
@@ -55,16 +54,6 @@ class SeccompSpeculation;
|
55 | 54 | class TraceAllSyscalls;
|
56 | 55 | class UnrestrictedNetworking;
|
57 | 56 |
|
58 |
| -namespace builder_internal { |
59 |
| - |
60 |
| -template <typename, typename = void> |
61 |
| -constexpr bool is_type_complete_v = false; |
62 |
| - |
63 |
| -template <typename T> |
64 |
| -constexpr bool is_type_complete_v<T, std::void_t<decltype(sizeof(T))>> = true; |
65 |
| - |
66 |
| -} // namespace builder_internal |
67 |
| - |
68 | 57 | // PolicyBuilder is a helper class to simplify creation of policies. The builder
|
69 | 58 | // uses fluent interface for convenience and increased readability of policies.
|
70 | 59 | //
|
@@ -336,18 +325,19 @@ class PolicyBuilder final {
|
336 | 325 | // Appends code to unconditionally allow mmap. Specifically this allows mmap
|
337 | 326 | // and mmap2 syscall on architectures where these syscalls exist.
|
338 | 327 | //
|
339 |
| - // This function requires that targets :map_exec library to be linked |
340 |
| - // against. Otherwise, the PolicyBuilder will fail to build the policy. |
341 |
| - // |
342 | 328 | // Prefer using `AllowMmapWithoutExec()` as allowing mapping executable pages
|
343 | 329 | // makes exploitation easier.
|
344 |
| - std::enable_if_t<builder_internal::is_type_complete_v<MapExec>, |
345 |
| - PolicyBuilder&> |
346 |
| - AllowMmap(); |
| 330 | + PolicyBuilder& AllowMmap(MapExec); |
| 331 | + |
| 332 | + ABSL_DEPRECATED("Use AllowMmap(MapExec) or AllowMmapWithoutExec() instead.") |
| 333 | + PolicyBuilder& AllowMmap(); |
347 | 334 |
|
348 | 335 | // Appends code to allow mmap calls that don't specify PROT_EXEC.
|
349 | 336 | PolicyBuilder& AllowMmapWithoutExec();
|
350 | 337 |
|
| 338 | + // Appends code to allow mprotect (also with PROT_EXEC). |
| 339 | + PolicyBuilder& AllowMprotect(MapExec); |
| 340 | + |
351 | 341 | // Appends code to allow mprotect calls that don't specify PROT_EXEC.
|
352 | 342 | PolicyBuilder& AllowMprotectWithoutExec();
|
353 | 343 |
|
@@ -708,9 +698,10 @@ class PolicyBuilder final {
|
708 | 698 | //
|
709 | 699 | // In addition to syscalls allowed by `AllowStaticStartup`, also allow
|
710 | 700 | // reading, seeking, mmap()-ing and closing files.
|
711 |
| - std::enable_if_t<builder_internal::is_type_complete_v<MapExec>, |
712 |
| - PolicyBuilder&> |
713 |
| - AllowDynamicStartup(); |
| 701 | + PolicyBuilder& AllowDynamicStartup(MapExec); |
| 702 | + |
| 703 | + ABSL_DEPRECATED("Use AllowDynamicStartup(MapExec) instead.") |
| 704 | + PolicyBuilder& AllowDynamicStartup(); |
714 | 705 |
|
715 | 706 | // Appends a policy, which will be run on the specified syscall.
|
716 | 707 | //
|
|
0 commit comments