eBPF-based security platform
treewide: drop the unused-parameter annotations again
Daniel Borkmann1afc74be1dab
diff --git a/bpf/seal.c b/bpf/seal.cindex d3415262..0b5e6a21 100644--- a/bpf/seal.c+++ b/bpf/seal.c@@ -474,11 +474,8 @@ int BPF_PROG(shirudo_seal_inode_removexattr, struct mnt_idmap *idmap,char _license[] SEC("license") = "Dual BSD/GPL";SEC("lsm/socket_post_create")-int BPF_PROG(shirudo_seal_socket_post_create, struct socket *sock,- int family __attribute__((__unused__)),- int type __attribute__((__unused__)),- int protocol __attribute__((__unused__)),- int kern __attribute__((__unused__)), int ret)+int BPF_PROG(shirudo_seal_socket_post_create, struct socket *sock, int family,+ int type, int protocol, int kern, int ret){struct task_struct *task = bpf_get_current_task_btf();struct shirudo_task_policy *policy;@@ -516,8 +513,8 @@ static __always_inline bool shirudo_task_has_seccomp(struct task_struct *task)}SEC("lsm.s/bprm_creds_for_exec")-int BPF_PROG(shirudo_seal_bprm_creds_for_exec,- struct linux_binprm *bprm __attribute__((__unused__)), int ret)+int BPF_PROG(shirudo_seal_bprm_creds_for_exec, struct linux_binprm *bprm,+ int ret){struct task_struct *task = bpf_get_current_task_btf();struct shirudo_task_policy *policy;diff --git a/bpf/unload.c b/bpf/unload.cindex 9dc6282f..82e7f80f 100644--- a/bpf/unload.c+++ b/bpf/unload.c@@ -25,7 +25,7 @@ volatile const struct unload_params shirudo_unload_params = {char _license[] SEC("license") = "Dual BSD/GPL";SEC("syscall")-int shirudo_unload(void *ctx __attribute__((__unused__)))+int shirudo_unload(void *ctx){/** TODO: look up /run/shirudo/bpffs/upatches/<name>/linkdiff --git a/builtin-bpm.c b/builtin-bpm.cindex 783cb2e6..4a55aad6 100644--- a/builtin-bpm.c+++ b/builtin-bpm.c@@ -1148,8 +1148,7 @@ static void sort_old_pairs(char (*unloads)[PATH_MAX], char (*loads)[PATH_MAX],#define INSTALL_PATHS_MAX 128static int package_install(const struct bpm_source *s, const struct bpm_index_entry *entry,- const char *old_path,- const char *old_version __attribute__((__unused__)))+ const char *old_path, const char *old_version){struct bpm_oci_client c __cleanup(bpm_oci_client_clear) = {};struct bpm_descriptor layers[8];@@ -2283,9 +2282,8 @@ static void bpm_tree_usage(void)"`shirudo bpm tree append --help` where the operator package is installed.\n");}-static int remove_tree_entry(const char *path,- const struct stat *st __attribute__((__unused__)),- int type, struct FTW *ftw __attribute__((__unused__)))+static int remove_tree_entry(const char *path, const struct stat *st,+ int type, struct FTW *ftw){if (type == FTW_DP || type == FTW_D)return rmdir(path) ? -1 : 0;diff --git a/builtin-init.c b/builtin-init.cindex c2f748f7..d2ef25c7 100644--- a/builtin-init.c+++ b/builtin-init.c@@ -476,8 +476,7 @@ struct anchor_keys {};static void collect_asymmetric(key_serial_t serial, const char *type,- const char *description __attribute__((__unused__)),- void *ud)+ const char *description, void *ud){struct anchor_keys *k = ud;diff --git a/builtin-status.c b/builtin-status.cindex aca4e2e2..2eb54a6c 100644--- a/builtin-status.c+++ b/builtin-status.c@@ -329,8 +329,7 @@ static void print_system_human(const struct sysinfo *si)printf(" %-16s %s\n", "Boot ID:", si->boot_id);}-static void print_kernel_config_entry(void *ctx __attribute__((__unused__)),- const char *key,+static void print_kernel_config_entry(void *ctx, const char *key,const char *value){printf(" %s=%s\n", key, value);diff --git a/testing/fixtures/policy-labels/policy-labels.bpf.c b/testing/fixtures/policy-labels/policy-labels.bpf.cindex 01293f39..a707369e 100644--- a/testing/fixtures/policy-labels/policy-labels.bpf.c+++ b/testing/fixtures/policy-labels/policy-labels.bpf.c@@ -13,8 +13,7 @@ int BPF_PROG(shirudo_test_policy_labels)}SEC("lsm.s/bprm_check_security")-int BPF_PROG(shirudo_test_policy_verdict,- struct linux_binprm *bprm __attribute__((__unused__)), int ret)+int BPF_PROG(shirudo_test_policy_verdict, struct linux_binprm *bprm, int ret){struct shirudo_task_policy *policy;@@ -26,11 +25,8 @@ int BPF_PROG(shirudo_test_policy_verdict,}SEC("lsm.s/socket_connect")-int BPF_PROG(shirudo_test_socket_policy_verdict,- struct socket *sock,- struct sockaddr *address __attribute__((__unused__)),- int addrlen __attribute__((__unused__)),- int ret)+int BPF_PROG(shirudo_test_socket_policy_verdict, struct socket *sock,+ struct sockaddr *address, int addrlen, int ret){struct shirudo_task_policy *policy;struct sock *sk;diff --git a/testing/helper/test-config-attest.c b/testing/helper/test-config-attest.cindex 13237a68..81b3ab45 100644--- a/testing/helper/test-config-attest.c+++ b/testing/helper/test-config-attest.c@@ -20,8 +20,7 @@#include "util/malloc.h"#include "util/tpm.h"-static int boot_identity(void *ctx __attribute__((__unused__)),- __u32 *reset, __u32 *restart)+static int boot_identity(void *ctx, __u32 *reset, __u32 *restart){struct tpm *tpm = NULL;int ret;@@ -33,8 +32,7 @@ static int boot_identity(void *ctx __attribute__((__unused__)),return ret;}-static int pcr_read(void *ctx __attribute__((__unused__)),- __u32 pcr, __u8 out[32])+static int pcr_read(void *ctx, __u32 pcr, __u8 out[32]){struct tpm *tpm = NULL;int ret;@@ -46,22 +44,18 @@ static int pcr_read(void *ctx __attribute__((__unused__)),return ret;}-static int no_extend(void *ctx __attribute__((__unused__)),- __u32 pcr __attribute__((__unused__)),- const __u8 event[32] __attribute__((__unused__)))+static int no_extend(void *ctx, __u32 pcr, const __u8 event[32]){return -EPERM;}-static int no_activate(void *ctx __attribute__((__unused__)),- const struct config_update_target *target- __attribute__((__unused__)))+static int no_activate(void *ctx,+ const struct config_update_target *target){return -EPERM;}-static int no_seal(void *ctx __attribute__((__unused__)),- int fd __attribute__((__unused__)))+static int no_seal(void *ctx, int fd){return 0;}diff --git a/testing/helper/test-config-update.c b/testing/helper/test-config-update.cindex 229c2fb5..76b814e4 100644--- a/testing/helper/test-config-update.c+++ b/testing/helper/test-config-update.c@@ -193,13 +193,12 @@ static int test_activate(void *opaque,return simulator_save(ctx);}-static int test_seal(void *opaque __attribute__((__unused__)),- int fd __attribute__((__unused__)))+static int test_seal(void *opaque, int fd){return getenv("SHIRUDO_TEST_CONFIG_SEAL_FAIL") ? -EPERM : 0;}-static int test_checkpoint(void *opaque __attribute__((__unused__)),+static int test_checkpoint(void *opaque,enum config_update_checkpoint checkpoint){const char *crash = getenv("SHIRUDO_TEST_CONFIG_CRASH");diff --git a/testing/helper/test-eventlog.c b/testing/helper/test-eventlog.cindex e0de89cd..a61b1d26 100644--- a/testing/helper/test-eventlog.c+++ b/testing/helper/test-eventlog.c@@ -64,8 +64,7 @@ static int append_init(const char *path, const char *bound_in,return eventlog_append_to(path, buf);}-static int count_lines(const char *line __attribute__((__unused__)),- size_t len __attribute__((__unused__)), void *ctx)+static int count_lines(const char *line, size_t len, void *ctx){__u32 *n = ctx;diff --git a/testing/helper/test-image-cli.c b/testing/helper/test-image-cli.cindex aff5b355..d1bc3de1 100644--- a/testing/helper/test-image-cli.c+++ b/testing/helper/test-image-cli.c@@ -4,29 +4,19 @@#include "../../builtin-bpm.c"#include "util/config.h"-int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client- __attribute__((__unused__)),- const char *repository- __attribute__((__unused__)),- const char *reference- __attribute__((__unused__)),+int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client,+ const char *repository,+ const char *reference,const char *certificate,- struct tree_publication *pub- __attribute__((__unused__)),- char *digest __attribute__((__unused__)),- size_t capacity __attribute__((__unused__)));+ struct tree_publication *pub,+ char *digest, size_t capacity);-int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client- __attribute__((__unused__)),- const char *repository- __attribute__((__unused__)),- const char *reference- __attribute__((__unused__)),+int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client,+ const char *repository,+ const char *reference,const char *certificate,- struct tree_publication *pub- __attribute__((__unused__)),- char *digest __attribute__((__unused__)),- size_t capacity __attribute__((__unused__)))+ struct tree_publication *pub,+ char *digest, size_t capacity){puts(certificate);return 0;diff --git a/testing/helper/test-image-keys.c b/testing/helper/test-image-keys.cindex e5440ba6..2a761567 100644--- a/testing/helper/test-image-keys.c+++ b/testing/helper/test-image-keys.c@@ -35,8 +35,7 @@ key_serial_t keyring_bpf_serial(void)return 42;}-int keyring_holds_cert(key_serial_t ring __attribute__((__unused__)),- const __u8 *der,+int keyring_holds_cert(key_serial_t ring, const __u8 *der,size_t size){int i;@@ -57,24 +56,20 @@ int keyring_holds_cert(key_serial_t ring __attribute__((__unused__)),return 0;}-int keys_revoke_image(const __u8 *der __attribute__((__unused__)),- size_t size __attribute__((__unused__)),- bool boot __attribute__((__unused__)))+int keys_revoke_image(const __u8 *der, size_t size, bool boot){mutations++;return -EPERM;}-static int boot_count(void *opaque __attribute__((__unused__)),- __u32 *reset, __u32 *restart)+static int boot_count(void *opaque, __u32 *reset, __u32 *restart){*reset = 1;*restart = 1;return 0;}-static int pcr_read(void *opaque, __u32 pcr __attribute__((__unused__)),- __u8 out[32])+static int pcr_read(void *opaque, __u32 pcr, __u8 out[32]){struct test_context *ctx = opaque;@@ -82,8 +77,7 @@ static int pcr_read(void *opaque, __u32 pcr __attribute__((__unused__)),return 0;}-static int pcr_extend(void *opaque, __u32 pcr __attribute__((__unused__)),- const __u8 event[32])+static int pcr_extend(void *opaque, __u32 pcr, const __u8 event[32]){struct test_context *ctx = opaque;@@ -92,8 +86,7 @@ static int pcr_extend(void *opaque, __u32 pcr __attribute__((__unused__)),}static int prepare(void *opaque,- const struct config_update_target *target- __attribute__((__unused__)))+ const struct config_update_target *target){struct test_context *ctx = opaque;@@ -101,8 +94,7 @@ static int prepare(void *opaque,}static int activate(void *opaque,- const struct config_update_target *target- __attribute__((__unused__)))+ const struct config_update_target *target){struct test_context *ctx = opaque;@@ -114,8 +106,7 @@ static int activate(void *opaque,return 0;}-static int seal(void *opaque __attribute__((__unused__)),- int fd __attribute__((__unused__)))+static int seal(void *opaque, int fd){return 0;}diff --git a/testing/helper/test-upatch-decode.c b/testing/helper/test-upatch-decode.cindex 97110945..0efd801f 100644--- a/testing/helper/test-upatch-decode.c+++ b/testing/helper/test-upatch-decode.c@@ -11,8 +11,7 @@#include "util/upatch_decode.h"#include "util/upatch_maps.h"-static int dump_chunk(lua_State * __attribute__((__unused__)) L,- const void *p, size_t sz, void *ud)+static int dump_chunk(lua_State *L, const void *p, size_t sz, void *ud){return fwrite(p, 1, sz, ud) == sz ? 0 : 1;}diff --git a/upatches/kernel-obs/kernel-obs.bpf.c b/upatches/kernel-obs/kernel-obs.bpf.cindex 7fb8d0fb..f41b826e 100644--- a/upatches/kernel-obs/kernel-obs.bpf.c+++ b/upatches/kernel-obs/kernel-obs.bpf.c@@ -105,7 +105,7 @@ int track_dns_response(struct __sk_buff *skb)/* Runs once right after attachment and sizes every table in the arena. */SEC("syscall")-int shirudo_test__kernel_obs(void *ctx __attribute__((__unused__)))+int shirudo_test__kernel_obs(void *ctx){__u64 now = obs_now();int ret;diff --git a/upatches/kernel-obs/obs_exec.bpf.c b/upatches/kernel-obs/obs_exec.bpf.cindex 52716ace..4f1c768d 100644--- a/upatches/kernel-obs/obs_exec.bpf.c+++ b/upatches/kernel-obs/obs_exec.bpf.c@@ -147,8 +147,7 @@ int BPF_PROG(obs_exec, struct linux_binprm *bprm)}SEC("lsm/task_alloc")-int BPF_PROG(obs_task_alloc, struct task_struct *child,- __u64 clone_flags __attribute__((__unused__)))+int BPF_PROG(obs_task_alloc, struct task_struct *child, __u64 clone_flags){struct task_struct *parent = bpf_get_current_task_btf();struct obs_task_meta *meta, *inherited;diff --git a/upatches/kernel-obs/obs_net.bpf.c b/upatches/kernel-obs/obs_net.bpf.cindex 6fdfba0e..21228ed6 100644--- a/upatches/kernel-obs/obs_net.bpf.c+++ b/upatches/kernel-obs/obs_net.bpf.c@@ -619,8 +619,7 @@ int BPF_PROG(obs_socket_create, struct socket *sock, int family, int type,}SEC("lsm/sock_graft")-int BPF_PROG(obs_sock_graft, struct sock *sk,- struct socket *parent __attribute__((__unused__)))+int BPF_PROG(obs_sock_graft, struct sock *sk, struct socket *parent){struct obs_sock_meta *meta;struct net_key key = {};@@ -794,8 +793,7 @@ int BPF_PROG(obs_socket_bind, struct socket *sock, struct sockaddr *address,}SEC("lsm/socket_accept")-int BPF_PROG(obs_socket_accept, struct socket *sock,- struct socket *newsock __attribute__((__unused__)))+int BPF_PROG(obs_socket_accept, struct socket *sock, struct socket *newsock){__u64 now = obs_now();struct sock *sk;@@ -812,9 +810,8 @@ int BPF_PROG(obs_socket_accept, struct socket *sock,}SEC("lsm/socket_recvmsg")-int BPF_PROG(obs_socket_recvmsg, struct socket *sock,- struct msghdr *msg __attribute__((__unused__)), int size,- int flags __attribute__((__unused__)))+int BPF_PROG(obs_socket_recvmsg, struct socket *sock, struct msghdr *msg,+ int size, int flags){__u64 now = obs_now();struct sock *sk;@@ -849,8 +846,7 @@ int BPF_PROG(obs_socket_setsockopt, struct socket *sock, int level,}SEC("lsm/socket_shutdown")-int BPF_PROG(obs_socket_shutdown, struct socket *sock,- int how __attribute__((__unused__)))+int BPF_PROG(obs_socket_shutdown, struct socket *sock, int how){__u64 now = obs_now();struct sock *sk;@@ -868,7 +864,7 @@ int BPF_PROG(obs_socket_shutdown, struct socket *sock,SEC("lsm/socket_socketpair")int BPF_PROG(obs_socket_socketpair, struct socket *socka,- struct socket *sockb __attribute__((__unused__)))+ struct socket *sockb){__u64 now = obs_now();struct sock *sk;diff --git a/upatches/kernel-obs/obs_priv.bpf.c b/upatches/kernel-obs/obs_priv.bpf.cindex 93615d10..56a18429 100644--- a/upatches/kernel-obs/obs_priv.bpf.c+++ b/upatches/kernel-obs/obs_priv.bpf.c@@ -239,10 +239,8 @@ int BPF_PROG(obs_ptrace, struct task_struct *child, unsigned int mode)}SEC("lsm.s/sb_mount")-int BPF_PROG(obs_mount,- const char *dev_name __attribute__((__unused__)),- const struct path *path, const char *type, unsigned long flags,- void *data __attribute__((__unused__)))+int BPF_PROG(obs_mount, const char *dev_name, const struct path *path,+ const char *type, unsigned long flags, void *data){struct priv_entry __arena *e;struct obs_ident ident;@@ -271,8 +269,7 @@ int BPF_PROG(obs_mount,SEC("lsm.s/kernel_read_file")int BPF_PROG(obs_kernel_read_file, struct file *filp,- enum kernel_read_file_id id,- bool contents __attribute__((__unused__)))+ enum kernel_read_file_id id, bool contents){struct priv_entry __arena *e;struct obs_ident ident;@@ -295,8 +292,7 @@ int BPF_PROG(obs_kernel_read_file, struct file *filp,}SEC("lsm/kernel_load_data")-int BPF_PROG(obs_kernel_load_data, enum kernel_load_data_id id,- bool contents __attribute__((__unused__)))+int BPF_PROG(obs_kernel_load_data, enum kernel_load_data_id id, bool contents){struct obs_ident ident;__u64 now = obs_now();@@ -329,8 +325,7 @@ int BPF_PROG(obs_module_request, char *kmod_name)}SEC("lsm/mmap_file")-int BPF_PROG(obs_mmap_file, struct file *filp,- unsigned long reqprot __attribute__((__unused__)),+int BPF_PROG(obs_mmap_file, struct file *filp, unsigned long reqprot,unsigned long prot, unsigned long flags){struct priv_entry __arena *e;@@ -355,8 +350,7 @@ int BPF_PROG(obs_mmap_file, struct file *filp,SEC("lsm/file_mprotect")int BPF_PROG(obs_file_mprotect, struct vm_area_struct *vma,- unsigned long reqprot __attribute__((__unused__)),- unsigned long prot)+ unsigned long reqprot, unsigned long prot){struct priv_entry __arena *e;struct obs_ident ident = {};@@ -430,9 +424,8 @@ static __always_inline bool obs_bpf_cmd_readonly(int cmd)}SEC("lsm/bpf")-int BPF_PROG(obs_bpf, int cmd,- union bpf_attr *attr __attribute__((__unused__)),- unsigned int size __attribute__((__unused__)), bool kernel)+int BPF_PROG(obs_bpf, int cmd, union bpf_attr *attr, unsigned int size,+ bool kernel){struct obs_ident ident;__u64 now = obs_now();diff --git a/util/eventlog.c b/util/eventlog.cindex da1574bf..335f53e3 100644--- a/util/eventlog.c+++ b/util/eventlog.c@@ -238,8 +238,7 @@ struct adopt_ctx {bool found;};-static int adopt_seen(const char *line, size_t len,- bool is_init __attribute__((__unused__)), void *ctx)+static int adopt_seen(const char *line, size_t len, bool is_init, void *ctx){struct adopt_ctx *a = ctx;diff --git a/util/image_runtime.c b/util/image_runtime.cindex 6207f90c..432bfb24 100644--- a/util/image_runtime.c+++ b/util/image_runtime.c@@ -390,7 +390,7 @@ int image_runtime_mount(void)return mount_runtime(false);}-static int seal_fd(void *ctx __attribute__((__unused__)), int fd)+static int seal_fd(void *ctx, int fd){return fsetxattr(fd, XATTR_NAME, SEAL_LABEL,strlen(SEAL_LABEL), 0) ?@@ -626,15 +626,13 @@ static int prepare_update(void *ctx,}static int activate_update(void *ctx,- const struct config_update_target *target- __attribute__((__unused__)))+ const struct config_update_target *target){return activate_config(ctx, false);}static int activate_boot(void *ctx,- const struct config_update_target *target- __attribute__((__unused__)))+ const struct config_update_target *target){return activate_config(ctx, true);}diff --git a/util/seal.c b/util/seal.cindex fdf5484b..c1182a8f 100644--- a/util/seal.c+++ b/util/seal.c@@ -52,8 +52,7 @@ static ssize_t seal_lget(const char *path, char label[SEAL_LABEL_LEN]);* left alone, never labelled, followed or read as shirudo's own.*/static int seal_label_cb(const char *path, const struct stat *sb,- int typeflag __attribute__((__unused__)),- struct FTW *ftwbuf __attribute__((__unused__)))+ int typeflag, struct FTW *ftwbuf){char label[SEAL_LABEL_LEN];int ret;diff --git a/util/tls_openssl.c b/util/tls_openssl.cindex 90f448d2..b0603e57 100644--- a/util/tls_openssl.c+++ b/util/tls_openssl.c@@ -95,8 +95,7 @@ out:return allowed;}-static void tls_info_callback(const SSL *ssl, int where, int ret- __attribute__((__unused__)))+static void tls_info_callback(const SSL *ssl, int where, int ret){const char *group, *host;int group_id;diff --git a/util/upatch_decode.c b/util/upatch_decode.cindex ed0b6dd8..388680e6 100644--- a/util/upatch_decode.c+++ b/util/upatch_decode.c@@ -23,7 +23,7 @@ int upatch_decode_map_json(const struct map_view *v,}int upatch_decode_map_json_limit(const struct map_view *v,- size_t max_bytes __attribute__((__unused__)),+ size_t max_bytes,char **out, size_t *out_len){return upatch_decode_map_json(v, out, out_len);@@ -35,26 +35,22 @@ int upatch_decode_map_otel(const struct map_view *v,return upatch_decode_map_json(v, out, out_len);}-int upatch_decode_map_file_json(const char *path- __attribute__((__unused__)),+int upatch_decode_map_file_json(const char *path,const struct map_view *v,char **out, size_t *out_len){return upatch_decode_map_json(v, out, out_len);}-int upatch_decode_map_file_json_limit(const char *path- __attribute__((__unused__)),+int upatch_decode_map_file_json_limit(const char *path,const struct map_view *v,- size_t max_bytes __attribute__((__unused__)),- char **out,+ size_t max_bytes, char **out,size_t *out_len){return upatch_decode_map_json(v, out, out_len);}-int upatch_decode_map_file_otel(const char *path- __attribute__((__unused__)),+int upatch_decode_map_file_otel(const char *path,const struct map_view *v,char **out, size_t *out_len){@@ -1018,8 +1014,7 @@ static void lua_disable_globals(lua_State *L)}}-static void lua_budget_hook(lua_State *L,- lua_Debug * __attribute__((__unused__)) ar)+static void lua_budget_hook(lua_State *L, lua_Debug *ar){struct lua_budget *budget;diff --git a/util/upatch_maps.c b/util/upatch_maps.cindex 903fc50b..ff30bafe 100644--- a/util/upatch_maps.c+++ b/util/upatch_maps.c@@ -685,7 +685,7 @@ static char *format_value(const void *value, __u32 value_size,char *upatch_map_format_percpu_sum(const struct map_view *v,const void *values_per_cpu,- const char *btf_type __attribute__((__unused__)))+ const char *btf_type){if (v->value_size == 1 || v->value_size == 2 ||v->value_size == 4 || v->value_size == 8) {