eBPF-based security platform
treewide: declare locals at the start of their block
Daniel Borkmannf6208dcb8c2f
diff --git a/builtin-bpm.c b/builtin-bpm.cindex 74cba7f1..27caa664 100644--- a/builtin-bpm.c+++ b/builtin-bpm.c@@ -433,9 +433,10 @@ static int extract_archive(const char *archive, const char *dest)return rc;}for (;;) {+ char name[PATH_MAX], rel[PATH_MAX], path[PATH_MAX], *slash;int n = gzread(gz, h, sizeof(h));uint64_t size, remain, pad;- char name[PATH_MAX], rel[PATH_MAX], path[PATH_MAX], *slash;+ bool zero = true;int type;if (n == 0)@@ -444,8 +445,6 @@ static int extract_archive(const char *archive, const char *dest)rc = -EINVAL;break;}- bool zero = true;-for (size_t i = 0; i < sizeof(h); i++) {if (h[i]) {zero = false;diff --git a/testing/helper/test-exec-churn.c b/testing/helper/test-exec-churn.cindex b3cf6d42..b4f1bd57 100644--- a/testing/helper/test-exec-churn.c+++ b/testing/helper/test-exec-churn.c@@ -75,11 +75,11 @@ static int worker(uint64_t deadline, int fd)int main(int argc, char **argv){+ uint64_t start, deadline, elapsed, completed = 0;unsigned long duration_sec = 0, workers = 0;- uint64_t start, deadline, completed = 0;+ int exit_status = 0;int result_fd[2];pid_t *children;- int exit_status = 0;for (int i = 1; i < argc; i++) {if (!strcmp(argv[i], "--duration") && i + 1 < argc) {@@ -135,8 +135,7 @@ int main(int argc, char **argv)free(children);if (exit_status)return 1;-- uint64_t elapsed = monotonic_ns() - start;+ elapsed = monotonic_ns() - start;printf("execs=%" PRIu64 " elapsed_ns=%" PRIu64" execs_per_sec=%.3f workers=%lu\n", completed, elapsed,elapsed ? (double)completed * 1e9 / (double)elapsed : 0.0,diff --git a/tools/shirudo-build/package.c b/tools/shirudo-build/package.cindex ebb15d55..a28e6567 100644--- a/tools/shirudo-build/package.c+++ b/tools/shirudo-build/package.c@@ -1072,24 +1072,24 @@ static int finalize_object(struct bpf_object *obj, const char *out_path,const char *pkey_path, const char *cert_path){LIBBPF_OPTS(gen_loader_opts, opts);- struct shirudo_sign_io sio = {};+ uint32_t loader_off, sig_off, data_off, data_len, meta_off;+ uint32_t write_meta_len = meta_len, attach_meta_len = 0;+ uint32_t decoder_blob_len = 0, signed_data_len = 0;+ uint32_t nr_maps = 0, nr_progs = 0;struct shirudo_upatch_header hdr;struct decoder_set decoders = {};- struct bpf_map *m;- struct bpf_program *p;- void *sig_buf = NULL;- void *attach_meta = NULL;- void *decoder_blob = NULL;- void *signed_data_buf = NULL;+ struct shirudo_sign_io sio = {};const void *signed_data = NULL;const void *write_meta = meta;- uint32_t write_meta_len = meta_len, attach_meta_len = 0;- uint32_t decoder_blob_len = 0, signed_data_len = 0;- int fd = -1;- int err = 0;- uint32_t loader_off, sig_off;- uint32_t nr_maps = 0, nr_progs = 0;+ void *signed_data_buf = NULL;+ void *decoder_blob = NULL;uint32_t nr_decoders = 0;+ void *attach_meta = NULL;+ struct bpf_program *p;+ void *sig_buf = NULL;+ struct bpf_map *m;+ int err = 0;+ int fd = -1;/** The loader writes map_fd/prog_fd back into descriptor arrays@@ -1171,9 +1171,9 @@ static int finalize_object(struct bpf_object *obj, const char *out_path,loader_off = (uint32_t)sizeof(hdr);sig_off = loader_off + opts.insns_sz;- uint32_t data_off = sig_off + (uint32_t)sio.signature_sz;- uint32_t data_len = signed_data_len;- uint32_t meta_off = data_off + data_len;+ data_off = sig_off + (uint32_t)sio.signature_sz;+ data_len = signed_data_len;+ meta_off = data_off + data_len;pack_header(&hdr, upatch_name, SHIRUDO_UPATCH_TYPE_BPF, flags,sio.payload_sha256,diff --git a/upatches/kernel-cve/sources/cve-2026-64036-cgroup-rstat-validate-cpu-css-rstat-cpu-access/observability/cve-2026-64036-caller-predicate.bpf.c b/upatches/kernel-cve/sources/cve-2026-64036-cgroup-rstat-validate-cpu-css-rstat-cpu-access/observability/cve-2026-64036-caller-predicate.bpf.cindex 5ebf660a..84a763d4 100644--- a/upatches/kernel-cve/sources/cve-2026-64036-cgroup-rstat-validate-cpu-css-rstat-cpu-access/observability/cve-2026-64036-caller-predicate.bpf.c+++ b/upatches/kernel-cve/sources/cve-2026-64036-cgroup-rstat-validate-cpu-css-rstat-cpu-access/observability/cve-2026-64036-caller-predicate.bpf.c@@ -44,11 +44,10 @@ SEC("kprobe/__css_rstat_updated")int BPF_KPROBE(cve_2026_64036_rstat,struct cgroup_subsys_state *css, int cpu){+ extern const volatile int nr_cpu_ids __ksym;int possible;count_event(&activity);- extern const volatile int nr_cpu_ids __ksym;-if (bpf_probe_read_kernel(&possible, sizeof(possible),(const void *)&nr_cpu_ids))return 0;diff --git a/util/upatch_maps_otel.c b/util/upatch_maps_otel.cindex 83aeb34e..2c4f77e9 100644--- a/util/upatch_maps_otel.c+++ b/util/upatch_maps_otel.c@@ -1326,11 +1326,12 @@ static int percent_decode(char *s)while (*src) {if (*src == '%') {+ int hi, lo;+if (!src[1] || !src[2])return -EINVAL;- int hi = shirudo_hex_nibble(src[1]);- int lo = shirudo_hex_nibble(src[2]);-+ hi = shirudo_hex_nibble(src[1]);+ lo = shirudo_hex_nibble(src[2]);if (hi < 0 || lo < 0)return -EINVAL;*dst++ = (char)((hi << 4) | lo);