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

ebpf_program_load_bytes() always calls srand before generating random program name #3443

Open
mikeagun opened this issue Apr 12, 2024 · 0 comments · May be fixed by #3493
Open

ebpf_program_load_bytes() always calls srand before generating random program name #3443

mikeagun opened this issue Apr 12, 2024 · 0 comments · May be fixed by #3493
Assignees
Labels
bug Something isn't working triaged Discussed in a triage meeting
Milestone

Comments

@mikeagun
Copy link
Collaborator

Describe the bug

Programs loaded from bytes get a random name assigned if program_name is passed as null, but srand(time(nullptr)) is called before rand() in each call, so two programs loaded in the same second will get the same name.

OS information

No response

Steps taken to reproduce bug

  1. Load two ebpf programs from bytes in the same clock second with program_name null

Expected behavior

The generated unique_name should be unique, or at least more random.

Actual outcome

The generated name is the same because rand gets the same seed.

Additional details

No response

@mikeagun mikeagun added the bug Something isn't working label Apr 12, 2024
@dahavey dahavey added the triaged Discussed in a triage meeting label Apr 15, 2024
@dahavey dahavey added this to the 2404 milestone Apr 15, 2024
mikeagun pushed a commit to mikeagun/ebpf-for-windows that referenced this issue Apr 24, 2024
ebpf_program_load_bytes now hashes the instructions and uses that for the name
instead of generating a random number.

Closes microsoft#3443
@mikeagun mikeagun linked a pull request Apr 24, 2024 that will close this issue
@shankarseal shankarseal modified the milestones: 2404, 2405 May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Discussed in a triage meeting
Projects
None yet
3 participants