8000 mmap: fd should be -1 when creating anonymous mappings by svenski123 · Pull Request #508 · solana-labs/rbpf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

mmap: fd should be -1 when creating anonymous mappings #508

Merged
merged 1 commit into from
Sep 3, 2023

Conversation

svenski123
Copy link

Allocating anonymous with mmap() should have fd set to -1 in conforming code (as 0 is a valid value for a file descriptor).
Linux is forgiving about this however other OS's (FreeBSD) less so.
This trivial change fixes BPF programs on Solana/FreeBSD which are currently broken by this.
I have copied an extract from the linux 2 mmap page for reference below.

MAP_ANONYMOUS
The mapping is not backed by any file; its contents are initialized to zero.  The fd argument is ignored; however, some implementations
require fd to be -1 if MAP_ANONYMOUS (or MAP_ANON) is specified, and portable applications should ensure  this.   The  offset  argument
should be zero.  The use of MAP_ANONYMOUS in conjunction with MAP_SHARED is supported on Linux only since kernel 2.4.

@codecov-commenter
Copy link

Codecov Report

Merging #508 (5fe3c71) into main (1bd6034) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #508      +/-   ##
==========================================
- Coverage   89.62%   89.62%   -0.01%     
==========================================
  Files          23       23              
  Lines       10297    10294       -3     
==========================================
- Hits         9229     9226       -3     
  Misses       1068     1068              
Files Changed Coverage Δ
src/memory_management.rs 94.00% <ø> (ø)

... and 2 files with indirect coverage changes

@alessandrod alessandrod merged commit 02e68a6 into solana-labs:main Sep 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0