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

on ppc64le credentials are wrongly parsed/obtained #88

Open
judovana opened this issue Sep 26, 2020 · 3 comments
Open

on ppc64le credentials are wrongly parsed/obtained #88

judovana opened this issue Sep 26, 2020 · 3 comments

Comments

@judovana
Copy link

Hello!

When running on ppc64le, the test

assertEquals("Current PID should match client credentials",
fails correctly, expecting pid, but getting 1.
If the test would continue, it would fail anyway, as all three pid, uid and gid are parsed wrongly during credential initialisation

linux x linux
myPid: 42170 # three real values
myUid: 1001
myGid: 1001

cc uid: 16383 # wrong client credentials
cc pid: 1
cc gid: -2070423904
sc uid: 16383 # samely wrong server credentials
sc pid: 1
sc gid: -2070421584

The values above are exemplar. They differs, canbe positive, but error is obvious.

I had debugged it into:

static Credentials getCredentials(int fd) {

Which leads to jnr-ffi 's : https://github.com/jnr/jnr-ffi/blob/05cbacc8528e85b1dbff30be5b88cde4c6a9c6a7/src/main/java/jnr/ffi/Struct.java#L865 wehre it leaves my current knowlege a bit.

Suspicion is going to endians or basic size type. Will continue digging.

Note, I had run all jnr-* tests on this ppc64le machine and no other projects (including ffi) had any issues. Only this one unixsocket's CredentialsFunctionalTest

@judovana
Copy link
Author

judovana commented Sep 26, 2020

Hmm, the aliases in ffi
are weird:

uid/gid:
uint32
uint
6

but pid:
sint32
sint
5

As read in: https://github.com/jnr/jnr-ffi/blob/05cbacc8528e85b1dbff30be5b88cde4c6a9c6a7/src/main/java/jnr/ffi/Struct.java#L882

... and are correct as by https://stackoverflow.com/a/1922775/3048996

From time to time I can see on that machine also: pid of 65735 > 2^16 but afaik it have no meaning as __s32 can be much bigger (?)

@headius
Copy link
Member

headius commented Sep 29, 2020

I would also suspect we are not handling endianness correctly.

I do not currently have a way to test on ppc64le but I will try to help as best I can!

@judovana
Copy link
Author

The only trace on ppc x endians I found was: https://github.com/jnr/jnr-ffi/blob/05cbacc8528e85b1dbff30be5b88cde4c6a9c6a7/src/main/java/jnr/ffi/Platform.java#L221
However if that would be wrong, the jff would be dead, isnt it? Or maybe this is not followed just unix-socket?

Tahnx!

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

No branches or pull requests

2 participants