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

Backports for 1.6-beta #38795

Merged
merged 57 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e5b8e5d
Bump CSL version (#38776)
staticfloat Dec 9, 2020
5c5c7a3
[automated] Bump the Tar stdlib from 0ba9683 to ac4d442 (#38786)
DilumAluthgeBot Dec 9, 2020
9f73f05
[LibCURL]: Reconcile BB and from-source configuration of LibCURL. (#3…
staticfloat Dec 9, 2020
29a1fdf
Simple test for filter for IdDicts (#38807)
kshyatt Dec 10, 2020
d045b77
[automated] Bump the NetworkOptions stdlib from 3d8a45c to a251de1 (#…
DilumAluthgeBot Dec 10, 2020
441e600
[automated] Bump the Downloads stdlib from 02e77ae to a6e4926 (#38816)
DilumAluthgeBot Dec 10, 2020
2684803
Do not return disconnected IdDict from Docs.meta (#38821)
timholy Dec 10, 2020
a15d4c8
Converge JLL APIs a bit more (#38797)
staticfloat Dec 11, 2020
c9c8ffd
Bump Documenter to 0.26.0 (#38826)
mortenpi Dec 11, 2020
fbd4fc3
Add isdefined check `count_const_size`
Keno Dec 9, 2020
40af668
Don't accidentally skip over pointers in count_const_size
Keno Dec 9, 2020
d5088f7
Avoid allocation in ldiv! with QR (#38389)
dlfivefifty Dec 9, 2020
1e377ca
Fix duplicated ldiv! method in qr.jl (#38801)
Keno Dec 9, 2020
f8349fa
[LLVM] add patch for miscompilation with setjmp on PPC
vchuravy Dec 9, 2020
624409d
[LLVM] add patch for #38773
vchuravy Dec 10, 2020
d47689a
Fix bugs in the checksum generator
staticfloat Dec 12, 2020
bb7938d
Update libLLVM, LLVM, and Clang
vchuravy Dec 11, 2020
6e2c9bc
Merge pull request #38851 from JuliaLang/vc/ppc_bp
vchuravy Dec 12, 2020
63f99af
Commit checksums for libosxunwind
ararslan Dec 12, 2020
10cbdde
Permit Bidiagonal represents empty matrix (#38392)
KlausC Dec 9, 2020
f3b6ccf
Fixed #38346: Eigen decomposition of Symmetric Matrix containing NaNs…
kc611 Dec 9, 2020
ce0a7ba
Resize credential buffer in winprompt in case of failure (#38828)
musm Dec 11, 2020
f543e26
improve inferrabilities within TOML module (#38831)
aviatesk Dec 12, 2020
10f699e
Use DEPOT_PATH instead of HOME in cmdlineargs test (#38855)
vchuravy Dec 13, 2020
fd94b4e
Adjust calling convention of LAPACK functions (#38836)
vchuravy Dec 13, 2020
b3f56c2
Use https links in a doc link (#38866)
musm Dec 13, 2020
8e71a81
[Mmap] Skip ReadOnlyMemoryError test on PowerPC
vchuravy Dec 13, 2020
e910291
[OpenBLAS_jll] use normalized ppc arch (#38874)
vchuravy Dec 14, 2020
e9c954f
Remove fastmath tests that are defined to be undef/poison
vchuravy Dec 12, 2020
3ba80c6
[Artifacts] Test c_simple on ppc
vchuravy Dec 14, 2020
3b18f1a
Don't clobber rax in x86_64 trampoline (#38882)
Keno Dec 15, 2020
22fa5a1
Don't override target passed on command-line with target from sysimg
vchuravy Dec 15, 2020
96d177f
LibGit2: improve error when CA root cert can't be set (#38827)
StefanKarpinski Dec 15, 2020
40a10ec
fix #38837, inference regression in tuple `map` (#38887)
JeffBezanson Dec 15, 2020
64838d2
measure compile time only when using time macros (fix #38877) (#38885)
IanButterworth Dec 15, 2020
f69cd74
fix #38897, docstring for .op= (#38898)
mbauman Dec 15, 2020
6e76513
update to utf8proc 2.6.1 (#38900)
stevengj Dec 16, 2020
ba0a0f5
Add section regarding Pkg mode to REPL docs (#38842)
musm Dec 16, 2020
ca49517
Correct pcre2-cet-flags.patch whitespace. (#38913)
Sacha0 Dec 17, 2020
8b99676
fix #34170, assertion failure with obvious_subtype (#38904)
JeffBezanson Dec 16, 2020
3210ac8
fix #38423, another stack overflow in method definition (#38810)
JeffBezanson Dec 14, 2020
0fb64a2
win: skip bad paths in dllist
vtjnash Dec 11, 2020
1f7d1bc
win: fix memory leak in dllist
vtjnash Dec 11, 2020
73f557d
Execute `backtrace` once before testing formatting (#38886)
vchuravy Dec 17, 2020
7784c2a
Restore the version information for libjulia.dylib (#38829)
fingolfin Dec 17, 2020
6f780f3
Update non-BB dsfmt build to match with the BB one. (#38917)
ViralBShah Dec 17, 2020
5b317d5
Add precompiles to reduce time to first Revise.revise()
timholy Dec 16, 2020
2d4f1db
Internalize Revise precompiles into Base
timholy Dec 16, 2020
f90e2f3
Document the need for disabling BB if building without network access…
ViralBShah Dec 17, 2020
7eb2d30
Improve position of MKL.jl mention in build documentation (#38923)
carstenbauer Dec 17, 2020
c687321
Remove useless nghttp2_jll import from LibGit2_jll (#38935)
staticfloat Dec 17, 2020
9687355
Mark ccall to git_libgit2_opts as variadic
vchuravy Dec 12, 2020
54c27e4
Remove stale WinRPM, Vagrant, Appveyor CI files and update build inst…
musm Dec 18, 2020
241efd8
improve performance of fieldname by moving out error paths in separat…
KristofferC Dec 18, 2020
5221f88
bump to latest Pkg release-1.6
KristofferC Dec 18, 2020
25ee100
[LLVM] Add patches for PPC knownbits and AArch64 globalisel
vchuravy Dec 15, 2020
4db29fe
bump LLVM BB
vchuravy Dec 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
LibGit2: improve error when CA root cert can't be set (#38827)
This also fixes an insecure behavior: even if `set_ssl_cert_locations`
failed, `REFCOUNT` was still incremented, which meant that subsequent
calls to `ensure_initialized` didn't call `initialize` and so there was
never a successful call to `set_ssl_cert_locations`. Without this
libgit2 defaults to not verifying host identities and that is insecure.
To prevent this, this patch locks on `ensure_initialized` and decrements
`REFCOUNT` if initialize throws an error, ensuring that `initialize`
succeeds at least once, including the call to `set_ssl_cert_locations`.

(cherry picked from commit 4dede6d)
  • Loading branch information
StefanKarpinski authored and KristofferC committed Dec 17, 2020
commit 96d177f62672de4636b3c6da7fe90c2c6366154a
52 changes: 37 additions & 15 deletions stdlib/LibGit2/src/LibGit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -961,13 +961,19 @@ end

## lazy libgit2 initialization

const ENSURE_INITIALIZED_LOCK = ReentrantLock()

function ensure_initialized()
x = Threads.atomic_cas!(REFCOUNT, 0, 1)
if x < 0
negative_refcount_error(x)::Union{}
end
if x == 0
initialize()
lock(ENSURE_INITIALIZED_LOCK) do
x = Threads.atomic_cas!(REFCOUNT, 0, 1)
x > 0 && return
x < 0 && negative_refcount_error(x)::Union{}
try initialize()
catch
Threads.atomic_sub!(REFCOUNT, 1)
@assert REFCOUNT[] == 0
rethrow()
end
end
return nothing
end
Expand All @@ -979,24 +985,40 @@ end
@noinline function initialize()
@check ccall((:git_libgit2_init, :libgit2), Cint, ())

cert_loc = NetworkOptions.ca_roots()
cert_loc !== nothing && set_ssl_cert_locations(cert_loc)

atexit() do
# refcount zero, no objects to be finalized
if Threads.atomic_sub!(REFCOUNT, 1) == 1
ccall((:git_libgit2_shutdown, :libgit2), Cint, ())
end
end

cert_loc = NetworkOptions.ca_roots()
cert_loc !== nothing && set_ssl_cert_locations(cert_loc)
end

function set_ssl_cert_locations(cert_loc)
cert_file = isfile(cert_loc) ? cert_loc : Cstring(C_NULL)
cert_dir = isdir(cert_loc) ? cert_loc : Cstring(C_NULL)
cert_file == C_NULL && cert_dir == C_NULL && return
@check ccall((:git_libgit2_opts, :libgit2), Cint,
(Cint, Cstring...),
Cint(Consts.SET_SSL_CERT_LOCATIONS), cert_file, cert_dir)
cert_file = cert_dir = Cstring(C_NULL)
if isdir(cert_loc) # directories
cert_dir = cert_loc
else # files, /dev/null, non-existent paths, etc.
cert_file = cert_loc
end
ret = ccall((:git_libgit2_opts, :libgit2), Cint, (Cint, Cstring...),
Cint(Consts.SET_SSL_CERT_LOCATIONS), cert_file, cert_dir)
ret >= 0 && return ret
err = Error.GitError(ret)
err.class == Error.SSL &&
err.msg == "TLS backend doesn't support certificate locations" ||
throw(err)
var = nothing
for v in NetworkOptions.CA_ROOTS_VARS
haskey(ENV, v) && (var = v)
end
@assert var !== nothing # otherwise we shouldn't be here
msg = """
Your Julia is built with a SSL/TLS engine that libgit2 doesn't know how to configure to use a file or directory of certificate authority roots, but your environment specifies one via the $var variable. If you believe your system's root certificates are safe to use, you can `export JULIA_SSL_CA_ROOTS_PATH=""` in your environment to use those instead.
"""
throw(Error.GitError(err.class, err.code, chomp(msg)))
end

end # module
53 changes: 53 additions & 0 deletions stdlib/LibGit2/test/bad_ca_roots.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module Test_LibGit2_https

using Test, LibGit2, NetworkOptions

# we currently use system SSL/TLS on macOS and Windows platforms
# and libgit2 cannot set the CA roots path on those systems
# if that changes, this may need to be adjusted
const CAN_SET_CA_ROOTS_PATH = !Sys.isapple() && !Sys.iswindows()

@testset "empty CA roots file" begin
# these fail for different reasons on different platforms:
# - on Apple & Windows you cannot set the CA roots path location
# - on Linux & FreeBSD you you can but these are invalid files
ENV["JULIA_SSL_CA_ROOTS_PATH"] = "/dev/null"
@test_throws LibGit2.GitError LibGit2.ensure_initialized()
ENV["JULIA_SSL_CA_ROOTS_PATH"] = tempname()
@test_throws LibGit2.GitError LibGit2.ensure_initialized()
# test that it still fails if called a second time
@test_throws LibGit2.GitError LibGit2.ensure_initialized()
if !CAN_SET_CA_ROOTS_PATH
# test that this doesn't work on macOS & Windows
ENV["JULIA_SSL_CA_ROOTS_PATH"] = NetworkOptions.bundled_ca_roots()
@test_throws LibGit2.GitError LibGit2.ensure_initialized()
delete!(ENV, "JULIA_SSL_CA_ROOTS_PATH")
@test LibGit2.ensure_initialized() === nothing
end
end

if CAN_SET_CA_ROOTS_PATH
@testset "non-empty but bad CA roots file" begin
# should still be possible to initialize
ENV["JULIA_SSL_CA_ROOTS_PATH"] = joinpath(@__DIR__, "bad_ca_roots.pem")
@test LibGit2.ensure_initialized() === nothing
end
mktempdir() do dir
repo_url = "https://github.com/JuliaLang/Example.jl"
@testset "HTTPS clone with bad CA roots fails" begin
repo_path = joinpath(dir, "Example.HTTPS")
c = LibGit2.CredentialPayload(allow_prompt=false, allow_git_helpers=false)
redirect_stderr(devnull)
err = try LibGit2.clone(repo_url, repo_path, credentials=c)
catch err
err
end
@test err isa LibGit2.GitError
@test err.msg == "user rejected certificate for github.com"
end
end
end

end # module
22 changes: 22 additions & 0 deletions stdlib/LibGit2/test/bad_ca_roots.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtDCCApwCCQDeWk9ywtjrpTANBgkqhkiG9w0BAQsFADCBmzELMAkGA1UEBhMC
VVMxETAPBgNVBAgMCE5ldyBZb3JrMREwDwYDVQQHDAhOZXcgWW9yazEnMCUGA1UE
CgweVGhlIEp1bGlhIFByb2dyYW1taW5nIExhbmd1YWdlMRYwFAYDVQQDDA1qdWxp
YWxhbmcub3JnMSUwIwYJKoZIhvcNAQkBFhZzZWN1cml0eUBqdWxpYWxhbmcub3Jn
MB4XDTIwMTIxMTE3NTgxN1oXDTI1MTIxMDE3NTgxN1owgZsxCzAJBgNVBAYTAlVT
MREwDwYDVQQIDAhOZXcgWW9yazERMA8GA1UEBwwITmV3IFlvcmsxJzAlBgNVBAoM
HlRoZSBKdWxpYSBQcm9ncmFtbWluZyBMYW5ndWFnZTEWMBQGA1UEAwwNanVsaWFs
YW5nLm9yZzElMCMGCSqGSIb3DQEJARYWc2VjdXJpdHlAanVsaWFsYW5nLm9yZzCC
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANCFgRMFlNGIgmZtMzR+Xx+t
cPXpYnw9sZXlGy4y+P+UVW5rnFtf+OL4WkcJykmL3n/iLBKpdrndhzL7zuc6lGVv
G6u+Gvwg5uCZ4RqiFSPP9xK7tl7H+CwrtWL/2vF1wlYC228A+NMpPyQw4XtX1L8G
xAvJbFz8JrJ+WH1wCmVpkxA6pnpK+DZ/QKPVwa/qhB80ur3bYwlHXWwDBf8bq98f
7wDBpJoEc3IG3GYopP6ie5KTENKxbDZjr306ZuxTLjXKrAE/OJkAiGKJ7gPlwT/E
kFI/x/No9Y/fPWFRGiFo2L4fhP2Mohcph3PQswFKfnQlMQzztetDKWCZveB5HisC
AwEAATANBgkqhkiG9w0BAQsFAAOCAQEAqAaFA93Q3VWWKAZBqORT+6N2iHDiOxMu
Ol8Jjqp3Spj552NbyPPpfF2a2Q/Bh2ZAmncCoGTpuXdnowSHyXuxPey6BIvEbq0L
FizTNuIzaA95fO/ce9LNujxliDHhKMJBZtCqBJYJ4dgd9sA4/LeAG/P3ltIY6K8P
22AAx2bzWbeRJSqxeBodm19rOb9Yz2SOaZIam42E+xia+hsUFdGf6Zkfpa02azDm
93EjS+DwapqxAKgkps6JuKqpRFdZd8QsVmgAcapnIt77w8sfBu9eyITF/Tm+MA8k
IRieSypM7TK0jQ6QrNV7FKSI6eEPaqWBMwkLg3S5H6KQMntVRlcc0A==
-----END CERTIFICATE-----
8 changes: 8 additions & 0 deletions stdlib/LibGit2/test/online.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,12 @@ mktempdir() do dir
end
end

# needs to be run in separate process so it can re-initialize libgit2
# with a useless self-signed certificate authority root certificate
file = joinpath(@__DIR__, "bad_ca_roots.jl")
cmd = `$(Base.julia_cmd()) --depwarn=no --startup-file=no $file`
if !success(pipeline(cmd; stdout=stdout, stderr=stderr))
error("bad CA roots tests failed, cmd : $cmd")
end

end # module