-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: options missing from cgo whitelists #23749
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
#23737 reports that flags generated by |
The linker whitelist should accept |
Comments on #23672 list these compiler options:
and these linker options:
|
#23742 suggests adding the compiler option |
#23743 suggests adding the linker option |
#23744 suggests adding these compiler options:
|
There are many compiler and linker options that may be used with either a single dash or a double dash. We should be similarly lax in the whitelists. |
For orthogonality: I forget if the option to add a directory to |
Also is |
@andlabs It's fine to write
In any case, the topic for this issue should be whether options are safe to use from |
When using:
compilation fails with the following message:
Looking over the code (for go 1.9.4) it appears there aren't any enviroment variables that can be used to whiteslist pkg-config arguments. |
@rgburke pkg-config output goes through the same However, it appears that |
We link a large number of C libraries statically in a closed-source project. Up until now we have been doing the following:
This is of course disallowed now. A workaround:
However some of these directories contain dynamic libraries too, which confuses the linker. Another option is to add '/' to the list of allowed "names" in https://go-review.googlesource.com/c/go/+/92855 In particular change on line 91 is:
the latter option fixes our issue but I can't speak to its impact on security. |
@mirtchovski there's a patch for that (the issue is that |
.a is now whitelisted (after that patch) so 'libsomething.a' will work, but '/path/to/libsomething.a' will not work. |
@ianlancetaylor @rgburke I actually ran into the very same problem with go/src/cmd/go/internal/work/exec.go Lines 939 to 940 in 104445e
Our quick fix internally was to point PKG_CONFIG to a script which simply executed |
@jeddenlea - Thank you very much! I was trying to find a workaround but didn't think of that. |
We hit this with |
I hit this issue with "${SRCDIR}/file.o" in cgo LDFLAGS.
I'd like to argue that we should allow plain filenames that is linker input
files in LDFLAGS
(at least *.a, *.o and *.so).
Unlike .a and .so which in theory could be handled with "-L${SRCDIR}
-lname", adding
extra object files to linker command cannot be fixed that way.
A workaround is to set CGO_LDFLAGS_ALLOW, but that's very cumbersome.
Another
alternative is to rename my file.o into file.syso, however, for my specific
case, I can't use
this option because I only include that file.o when a specific build tag is
included (the
build tag applies to file that contains the #cgo LDFLAGS preamble) and
there is no way
to set arbitrary build tag in syso filenames.
If we ignore previous deployed Go versions, we might be able to include a
new
"#cgo LDLIBS" that is designed specifically for adding more files to linker
command line.
Then we can have a stricter rule for LDLIBS (filenames only, and no dash
allowed in prefix.)
|
We've hit this with |
@PassKit Did you solve this problem? |
@zcm211 If you're talking about https://github.com/miekg/pkcs11 they removed the |
darwin 64-bit, go1.10.2, I thought
due to the cgo preamble in https://github.com/go-interpreter/chezgo/blob/master/embed.go#L10
|
@glycerine According to https://go-review.googlesource.com/c/go/+/94676 they are. Maybe try a full path instead of a relative one? |
Good catch @AlexRouSg, the accept regex is buggy as you point out;
src/cmd/go/internal/work/security.go#121 should allow After all, I can't predict the users' GOPATH, or how nested the location of that file will become, so setting an absolute path isn't practical. |
Is the .o file in the source directory? If so, referring to the source directory is what |
@andlabs Even if there are klunky workarounds, relative paths should be linkable, and that is clearly a bug. |
It is, except IIRC there is no guarantee that the link would be relative TO the source directory (it could very well be in |
gtk4 uses -mfpmath=sse |
@ianlancetaylor Instead of having separate whitelists for cflags and ldflags, should there just be one list? gcc/llvm doesn't seem to care that you mix ldflags into cflags and vice versa. And it seems sometimes C devs do that causing issues like #25493 or #23749 (comment) |
Ah, I see we have a ticket already, so let me mention "-D_THREAD_SAFE" from protobuf as documented in #25493 |
Change https://golang.org/cl/115415 mentions this issue: |
Change https://golang.org/cl/115435 mentions this issue: |
Change https://golang.org/cl/115436 mentions this issue: |
Fixes #23749 Fixes #24703 Fixes #24858 Change-Id: Ib32d8efee294004c70fdd602087df2da0867f099 Reviewed-on: https://go-review.googlesource.com/115415 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit 886d5601a63bef0271e705cfa6b6ac6f5134ee60) Reviewed-on: https://go-review.googlesource.com/115435 Reviewed-by: Andrew Bonventre <andybons@golang.org>
Fixes #23749 Fixes #24703 Fixes #24858 Change-Id: Ib32d8efee294004c70fdd602087df2da0867f099 Reviewed-on: https://go-review.googlesource.com/115415 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit cc6e568) Reviewed-on: https://go-review.googlesource.com/115436 Reviewed-by: Andrew Bonventre <andybons@golang.org>
Hey Guys,
Any advise? EDIT: |
I believe this whitelist is responsible for the following: alexflint/gallium#63 |
@alexflint This issue is closed, please create a new one |
The recent security patches for cmd/go (#23672) added a whitelist of options permitted for use with cgo. Several different people have reported packages that fail to build by default because they use options that are not on the whitelists. This issue is intended to collect a list of all the missing options, so that we can add them in a single CL.
The text was updated successfully, but these errors were encountered: