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

build fails on 32 bit targets #205

Closed
jvvv opened this issue Oct 23, 2022 · 2 comments
Closed

build fails on 32 bit targets #205

jvvv opened this issue Oct 23, 2022 · 2 comments

Comments

@jvvv
Copy link
Contributor

jvvv commented Oct 23, 2022

So far I have tested building nsjail on x86 and armv7 targets. Both fail do to type mismatch between uint64_t and uintptr_t (which is 32bit on 32 bit arches):

util::StrAppend(&res, "|%#tx", flags & ~(knownFlagMask));

nsjail/mnt.cc

Line 107 in 2e62649

util::StrAppend(&res, "|%#tx", flags & ~(knownFlagMask));

Changing the flag type to uint64_t or the knownFlagMask to an unsigned type that will match (unsigned long?).

I am a bit dubious about using uintptr_t in cases like this and in other places in nsjail's code, where unsigned long makes just as much sense. I real question seems to be what is actual size of the clone flags; my understanding is that they are a long, so arch dependent and knownFlagMask should match flags type.

I have tested changing the flag argument to uint64_t in one trial, and changing the knownFlagMask to unsigned long in another. Both cases built and ran fine in QEMU vm's (armv7 and x86). I have not submitted a pr at this point, but doing so is trivial, so I will if it is desired.

@robertswiecki
Copy link
Collaborator

Hi,

I've changed the subproc code to use uint64_t`` and mnt to use unsigned long```

I guess we try to work around the Linux kernel API here (fro clone). The clone flags as of introduction of clone3 are practically u64, but some interfaces (clone clone2) still expect int.

Commit: 285ea15

@jvvv
Copy link
Contributor Author

jvvv commented Oct 24, 2022

Thanks for swift action on this!

I left a comment for 285ea15 about probable need to change cloneProc declaration in subproc.h to match definition in subproc.cc.

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