Skip to content

Commit

Permalink
attempt to fix garbage memory access in packet_t struct
Browse files Browse the repository at this point in the history
  • Loading branch information
pouriyajamshidi committed May 3, 2024
1 parent c6f34ae commit 9f12e84
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bpf/flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdlib.h>

#include <linux/string.h>
#include <linux/bpf.h>
#include <linux/bpf_common.h>

Expand Down Expand Up @@ -149,6 +150,10 @@ int flat(struct __sk_buff* skb) {
return TC_ACT_OK;
}

// Zero-initialize the memory region of pkt
// so that we do not access garbage
memset(pkt, 0, sizeof(struct packet_t));

uint32_t offset = 0;

if (handle_ip_packet(head, tail, &offset, pkt) == TC_ACT_OK) {
Expand Down
Binary file modified internal/probe/probe_bpfeb.o
Binary file not shown.
Binary file modified internal/probe/probe_bpfel.o
Binary file not shown.

0 comments on commit 9f12e84

Please sign in to comment.