Skip to content

eBPF-based security platform

compiler: add noinline_for_stack

Daniel Borkmann8eff75546c91
diff --git a/builtin-status.c b/builtin-status.c
index 1bac8e9a..0e593979 100644
--- a/builtin-status.c
+++ b/builtin-status.c
@@ -67,7 +67,7 @@ static int notdot(const struct dirent *e)
return strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0;
}
-static int count_eventlog(long *entries, long *bytes)
+static noinline_for_stack int count_eventlog(long *entries, long *bytes)
{
char buf[65536];
struct stat st;
diff --git a/include/shirudo/compiler.h b/include/shirudo/compiler.h
index 8d465d75..089ea92d 100644
--- a/include/shirudo/compiler.h
+++ b/include/shirudo/compiler.h
@@ -12,6 +12,9 @@
#define __must_check __attribute__((warn_unused_result))
#define __noreturn __attribute__((noreturn))
#define __cleanup(func) __attribute__((cleanup(func)))
+#define noinline __attribute__((noinline))
+/* A function with a large frame that inlining would add to its caller's. */
+#define noinline_for_stack noinline
/*
* An empty asm that may read memory through ptr, so that a store to that
diff --git a/util/upatch_maps_otel.c b/util/upatch_maps_otel.c
index 417f31c1..9e4f780c 100644
--- a/util/upatch_maps_otel.c
+++ b/util/upatch_maps_otel.c
@@ -1498,7 +1498,8 @@ static void retry_wait(__u32 retry, __u64 retry_after,
;
}
-static int otel_post(struct otel_state *st, const char *json, size_t json_len)
+static noinline_for_stack int otel_post(struct otel_state *st,
+ const char *json, size_t json_len)
{
__u8 *compressed = NULL;
const void *body = json;
@@ -2307,10 +2308,10 @@ static bool retryable_s3_http(long status)
retryable_http(status);
}
-static int s3_put(struct otel_s3_state *st,
- const struct map_view *v,
- struct s3_snapshot *snapshot, const char *url,
- bool *already_present)
+static noinline_for_stack int s3_put(struct otel_s3_state *st,
+ const struct map_view *v,
+ struct s3_snapshot *snapshot,
+ const char *url, bool *already_present)
{
struct curl_slist *headers = NULL;
char sigv4[128];