Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only set type to pointer if the width is correct #581

Merged
merged 3 commits into from
Feb 11, 2024

Conversation

dthaler
Copy link
Contributor

@dthaler dthaler commented Jan 29, 2024

  • If the width is not what is expected, then it can't be a regular pointer. The Linux kernel verifier checks this but PREVAIL wasn't checking this case, which could cause a machine crash.
  • do_load_ctx() is special since it uses 32-bit offsets for packet data, data_end, and meta. In an actual program these are 64-bit pointers, but at verification time we just use the offset values as a proxy, like we use map_fd's as a proxy for maps which at runtime are actually 64-bit memory pointers.
  • Add YAML tests for such cases.
  • Added comment explaining why PTR_MAX isn't int64_t max for now.
  • Half the places (asm_parse.cpp line 55, split_dbm.cpp line 1055) used "map_fd_program" and half (asm_ostream.cpp lines 24 and 106, asm_parse.cpp line 284), used "map_fd_programs" for the string name of that type. Use the latter everywhere for consistency.

Addresses issue #560

@coveralls
Copy link

coveralls commented Jan 29, 2024

Coverage Status

coverage: 89.79% (+0.04%) from 89.754%
when pulling df1f98f on dthaler:validate-ctx-ptr
into f3964ef on vbpf:main.

@dthaler dthaler marked this pull request as draft January 29, 2024 16:29
Fix and test move operations

Signed-off-by: Dave Thaler <[email protected]>
@dthaler dthaler changed the title Only set type to packet if the width is correct Only set type to pointer if the width is correct Jan 30, 2024
Signed-off-by: Dave Thaler <[email protected]>
@dthaler dthaler marked this pull request as ready for review January 30, 2024 02:04
@elazarg elazarg merged commit b62f8f1 into vbpf:main Feb 11, 2024
13 checks passed
@dthaler dthaler deleted the validate-ctx-ptr branch February 11, 2024 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants