Skip to content

Preserve errno for pread64 failures - #1691

Open
carlosqwqqwq wants to merge 1 commit into
qilingframework:devfrom
carlosqwqqwq:fix-pread64-errno
Open

carlosqwqqwq wants to merge 1 commit into
qilingframework:devfrom
carlosqwqqwq:fix-pread64-errno

Conversation

@carlosqwqqwq

Copy link
Copy Markdown

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

Summary

ql_syscall_pread64 currently turns host OSErrors into -1, losing the errno. For an O_WRONLY descriptor this makes an RV64 Linux guest observe EPERM instead of EBADF. Return the negative host errno when available and keep the existing -1 fallback when no errno is set.

This follows the Linux pread(2) error contract. Fixes #1686.

Validation

  • python -m unittest test_syscall_pread64_errno -v from tests/: 2 tests pass.
  • Static RV64 guest reproducer from [Linux/RISC-V64] pread64 on an O_WRONLY descriptor returns EPERM instead of EBADF #1686: the write-only call reports EBADF without changing the buffer; the read-only control reads one byte.
  • python test_posix.py Pread64ErrnoTests -v: 2 tests pass.
  • The full python test_posix.py aggregate was attempted; its guest-fixture cases error because prebuilt binaries under examples/rootfs are absent from this checkout.

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