-
Notifications
You must be signed in to change notification settings - Fork 18k
crypto/internal/boring/syso: boringssl builds on musl broken due to fopen64
calls
#64698
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
Comments
fopen64
callsfopen64
calls
cc @golang/security |
That appears to be a problem with boringssl upstream https://github.com/google/boringssl/blob/master/crypto/bio/file.c#L57-L72. #if defined(__linux) || defined(__sun) || defined(__hpux)
// Following definition aliases fopen to fopen64 on above mentioned
// platforms. This makes it possible to open and sequentially access
// files larger than 2GB from 32-bit application. It does not allow to
// traverse them beyond 2GB with fseek/ftell, but on the other hand *no*
// 32-bit platform permits that, not with fseek/ftell. Not to mention
// that breaking 2GB limit for seeking would require surgery to *our*
// API. But sequential access suffices for practical cases when you
// can run into large files, such as fingerprinting, so we can let API
// alone. For reference, the list of 32-bit platforms which allow for
// sequential access of large files without extra "magic" comprise *BSD,
// Darwin, IRIX...
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#endif From what I understood, all system calls in musl are 64bit, so there is no need to use the 64 variants of the system calls. I'm not sure how to detect this tho. Maybe always compile the syso with the 32 bit versions? I'm not sure what are the downsides of this for glibc. Boring being a GOEXPERIMENT I don't know if it is even supposed to work on musl. |
That #define only does whatever the libc headers decides to do with it. If musl does not provide suffixed symbols, one can assume its headers will not swap over to them. It sounds like you may have built BoringSSL against one libc's headers and then linked it against a different libc. That cannot work. You need to build against the headers for the library you're linking against. |
So the problem, in summary, is:
It is not clear to me a path to resolution that does not involve either us recompiling the syso files using only the normal variants or musl providing some kind of solution to this, but since they already removed the 64bit shims I think they expect us to fix it somehow. |
We build the FIPS module against glibc and then check in the object file, so that's effectively what's happening, although it's not clear to me why the BoringCrypto module would call |
Ah. I don't think anything in BCM itself calls it, but since BCM is an internal chunk of libcrypto, I assume you're building all of libcrypto and picking it up by way of the file BIO. I assume musl does not promise to have the same ABI as glibc (given they removed a symbol glibc provides...), even if it probably accidentally matches for simple stuff. So I think that means a musl and glibc build would want to be different, or this mode should just only support glibc. |
I'm sorry but BoringCrypto is not supported for use outside Google. We share the code with the world in case anyone wants it, but when it breaks in different environments, we don't support it. Musl is a source of many problems generally so it's unsurprising it would be a problem here too, but we're not going to take on the complexity of making musl work and keeping it working. |
Go version
1.21.5
What operating system and processor architecture are you using (
go env
)?What did you do?
I attempted to build a go program using cgo and boringssl in a Alpine 3.19 dockerfile:
Changing the base image from Alpine 3.19 to 3.18 causes compilation to succeed, so this is due to a recent change in musl where symbols like
fopen64
were removed (see here). However, the following libraries still make calls to the removedfopen64
symbol:What did you expect to see?
Compilation should succeed
What did you see instead?
The above quoted dockerfile failed with the following error message:
The text was updated successfully, but these errors were encountered: