Skip to content

Handle zero-length getrandom requests - #1705

Open
carlosqwqqwq wants to merge 2 commits into
qilingframework:devfrom
carlosqwqqwq:issue-1689-getrandom-zero-length
Open

carlosqwqqwq wants to merge 2 commits into
qilingframework:devfrom
carlosqwqqwq:issue-1689-getrandom-zero-length

Conversation

@carlosqwqqwq

@carlosqwqqwq carlosqwqqwq commented Nov 25, 2026 •

Copy link
Copy Markdown

Fixes #1689.

Return zero for a zero-length getrandom request after validating the flags and before checking or accessing guest memory. This avoids passing a zero-sized range to the memory mapping helper while preserving EINVAL for unknown flag bits and the incompatible GRND_RANDOM | GRND_INSECURE combination. The regression covers the zero-length path, invalid flags for zero-length and nonzero requests, and a positive-length control. The validation order follows Linux v6.6.

Validation:

  • python -m unittest tests.test_syscall_random (3 tests)
  • python -m py_compile qiling/os/posix/syscall/random.py tests/test_syscall_random.py

Checklist

Which kind of PR do you create?

  • This PR only contains minor fixes.
  • This PR contains major feature update.
  • This PR introduces a new function/api for Qiling Framework.

Coding convention?

  • The new code conforms to Qiling Framework naming convention.
  • The imports are arranged properly.
  • Essential comments are added.
  • The reference of the new code is pointed out.

Extra tests?

  • No extra tests are needed for this PR.
  • I have added enough tests for this PR.
  • Tests will be added after some discussion and review.

Changelog?

  • This PR doesn't need to update Changelog.
  • Changelog will be updated after some proper review.
  • Changelog has been updated in my PR.

Target branch?

  • The target branch is dev branch.

One last thing

  • I have read the contribution guide.

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.

1 participant