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

Fix syscall definitions for x86_64-unknown-linux-gnux32. #66

Merged
merged 1 commit into from
Feb 8, 2021

Conversation

hvdijk
Copy link
Contributor

@hvdijk hvdijk commented Feb 6, 2021

The x32 ABI uses the 0x40000000 bit in syscall numbers. Additionally, the x32 ABI keeps syscall numbers as type long, but its type long is i32 rather than i64.

@lucab
Copy link
Owner

lucab commented Feb 7, 2021

Thanks for the PR, happy to merge this.
However it would be helpful to have in the commit message some URL references to kernel code for those x32 details, so that it's easy to review and follow through history in the future.

libc::syscall takes a c_long as in x86_64-unknown-linux-gnu [1], but
c_long is i32 rather than i64 [2].

The syscall numbers include 0x40000000 as an indicator of the ABI [2].

[1]: rust-lang/libc:src/unix/linux_like/linux/mod.rs
[2]: rust-lang/libc:src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs
@hvdijk
Copy link
Contributor Author

hvdijk commented Feb 7, 2021

Sure, more elaborate descriptions are good. I think, but may be mistaken, that the syscall taking i32 may be a userland decision more than a kernel decision, so have included references to rust-lang/libc instead, I hope that is okay too.

I noticed rust-lang/libc already exposes SYS_capget and SYS_capset, so an alternative fix could be to just use those directly.

@lucab lucab merged commit f6178d0 into lucab:master Feb 8, 2021
@lucab
Copy link
Owner

lucab commented Feb 8, 2021

I noticed rust-lang/libc already exposes SYS_capget and SYS_capset, so an alternative fix could be to just use those directly.

Yes, it is probably a good idea to do that too anyway. I don't remember why I didn't go that route initially, perhaps libc was not exposing those constants when I started this crate (or I plainly missed that).

@nabijaczleweli
Copy link

nabijaczleweli commented Feb 13, 2021

This PR is the only one standing before getting x32 support into libc now, would you mind publishing a new version, please?

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