Skip to content

Commit

Permalink
fix: failed byte off relocation (iov_iter.iov)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmat11 committed Oct 10, 2023
1 parent f2581d8 commit e67c716
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion GPL/Events/Process/Probe.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Varlen.h"

/* tty_write */
DECL_FIELD_OFFSET(iov_iter, iov);
DECL_FIELD_OFFSET(iov_iter, __iov);

// Limits on large things we send up as variable length parameters.
Expand Down Expand Up @@ -374,8 +375,10 @@ static int tty_write__enter(struct kiocb *iocb, struct iov_iter *from)
const struct iovec *iov;
if (FIELD_OFFSET(iov_iter, __iov)) {
iov = (const struct iovec *)((char *)from + FIELD_OFFSET(iov_iter, __iov));
} else if (FIELD_OFFSET(iov_iter, iov)) {
iov = (const struct iovec *)((char *)from + FIELD_OFFSET(iov_iter, iov));
} else {
iov = BPF_CORE_READ(from, iov);
goto out;
}

u64 nr_segs = BPF_CORE_READ(from, nr_segs);
Expand Down
5 changes: 4 additions & 1 deletion non-GPL/Events/Lib/EbpfEvents.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,11 @@ static int probe_fill_relos(struct btf *btf, struct EventProbe_bpf *obj)
}
err = err ?: FILL_FUNC_RET_IDX(obj, btf, vfs_rename);

if (BTF_FIELD_EXISTS(btf, iov_iter, __iov))
if (BTF_FIELD_EXISTS(btf, iov_iter, __iov)) {
err = err ?: FILL_FIELD_OFFSET(obj, btf, iov_iter, __iov);
} else {
err = err ?: FILL_FIELD_OFFSET(obj, btf, iov_iter, iov);
}

return err;
}
Expand Down

0 comments on commit e67c716

Please sign in to comment.