Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions driver/bpf/fillers.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,11 @@ static __always_inline int bpf_parse_readv_writev_bufs(struct filler_data *data,

#ifdef BPF_FORBIDS_ZERO_ACCESS
if (to_read)
if (bpf_probe_read(&data->buf[off & SCRATCH_SIZE_HALF],
if (bpf_probe_read(&data->buf[off & SCRATCH_SIZE_HALF - 1],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parentheses? Is this expression (off & SCRATCH_SIZE_HALF) - 1 or off & (SCRATCH_SIZE_HALF - 1)?

Copy link
Contributor Author

@fntlnz fntlnz Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- has precedence over & and I confirm that the generated bpf bytecode is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on what you wrote above, is it possible that the intent of the code is (off & SCRATCH_SIZE_HALF) - 1?

((to_read - 1) & SCRATCH_SIZE_HALF) + 1,
iov[j].iov_base))
#else
if (bpf_probe_read(&data->buf[off & SCRATCH_SIZE_HALF],
if (bpf_probe_read(&data->buf[off & SCRATCH_SIZE_HALF - 1],
to_read & SCRATCH_SIZE_HALF,
iov[j].iov_base))
#endif
Expand Down