Skip to content

Commit

Permalink
get the right iov field
Browse files Browse the repository at this point in the history
  • Loading branch information
mmat11 committed Oct 2, 2023
1 parent fe80cd3 commit 4fa55b9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ testing/testrunner/testrunner
testing/test_bins/bin/*
testing/init/bin/*
testing/kernels
testing/kernel_builder/kernels
testing/virtme

*.swp
33 changes: 29 additions & 4 deletions GPL/Events/Process/Probe.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,24 @@ static int output_tty_event(struct ebpf_tty_dev *slave, const void *base, size_t
return ret;
}

struct iov_iter____new {
union {
struct iovec __ubuf_iovec;
struct {
union {
const struct iovec *__iov;
const struct kvec *kvec;
const struct bio_vec *bvec;
struct xarray *xarray;
void *ubuf;
};
size_t count;
};
};
} __attribute__((preserve_access_index));

static int tty_write__enter(struct kiocb *iocb, struct iov_iter *from)
{

if (is_consumer()) {
goto out;
}
Expand Down Expand Up @@ -369,9 +384,19 @@ static int tty_write__enter(struct kiocb *iocb, struct iov_iter *from)
goto out;
}

u64 nr_segs = BPF_CORE_READ(from, nr_segs);
nr_segs = nr_segs > MAX_NR_SEGS ? MAX_NR_SEGS : nr_segs;
const struct iovec *iov = BPF_CORE_READ(from, iov);
u64 nr_segs = BPF_CORE_READ(from, nr_segs);
nr_segs = nr_segs > MAX_NR_SEGS ? MAX_NR_SEGS : nr_segs;

const struct iovec *iov;
if (bpf_core_field_exists(struct iov_iter____new, __iov)) {
u64 iov_off = offsetof(struct iov_iter____new, __iov);
bpf_core_read(&iov, bpf_core_type_size(struct iov_iter), (void *)from + iov_off);
} else if (bpf_core_field_exists(from->iov)) {
iov = BPF_CORE_READ(from, iov);
} else {
bpf_printk("tty_write__enter: error reading iov\n");
goto out;
}

if (nr_segs == 0) {
u64 count = BPF_CORE_READ(from, count);
Expand Down
15 changes: 10 additions & 5 deletions testing/kernel_builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,26 @@ readonly BUILD_ARCHES=(
readonly BUILD_VERSIONS=(
"5.10.16" # Oldest we support
"5.10.50"
"5.10.100"
"5.10.120"
"5.10.130"
"5.11"
"5.12"
"5.13"
"5.14"
"5.15"
"5.15.10"
"5.15.40"
"5.15.60"
"5.15.50"
"5.15.133"
"5.16"
"5.17"
"5.18"
"5.19"
"6.0"
"6.1"
"6.1.55"
"6.2"
"6.3"
"6.4"
"6.4.16"
"6.5"
)

exit_error() {
Expand Down

0 comments on commit 4fa55b9

Please sign in to comment.