From 008432c2ad17404db3872832636501bc91098b2d Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 9 Jan 2022 15:28:27 -0500 Subject: [PATCH 01/34] `base/version_git.sh`: fix the default value for `Base.GIT_VERSION_INFO` (for e.g. when Git is not available) (#43717) * `base/version_git.sh`: fix the default value for `Base.GIT_VERSION_INFO` (for e.g. when Git is not available) * Use single-quotes to avoid the need to backslash-escape the double quotes (cherry picked from commit 709bc5c4d4774eaefd36f4e2a99d5042aa37e206) --- base/version_git.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/version_git.sh b/base/version_git.sh index b4560609968e5..957626508d67e 100644 --- a/base/version_git.sh +++ b/base/version_git.sh @@ -24,7 +24,7 @@ cd $1 if [ "$#" = "2" -a "$2" = "NO_GIT" ]; then # this comment is used in base/Makefile to distinguish boilerplate echo "# Default output if git is not available." - echo "const GIT_VERSION_INFO = GitVersionInfo(\"\" ,\"\" ,\"\" ,0 ,\"\" ,true ,0 ,0.)" + echo 'const GIT_VERSION_INFO = GitVersionInfo("", "", "", 0, "", true, 0, 0.0, "", "")' exit 0 fi # Collect temporary variables @@ -101,7 +101,7 @@ echo " $build_number," echo " \"$date_string\"," echo " $tagged_commit," echo " $fork_master_distance," -echo " $fork_master_timestamp.," +echo " $fork_master_timestamp.0," echo " \"$build_system_commit\"," echo " \"$build_system_commit_short\"," echo ")" From 16944c36ee672aac5f22c99111ab34d2959dde28 Mon Sep 17 00:00:00 2001 From: Denis Barucic Date: Mon, 21 Mar 2022 13:06:29 +0100 Subject: [PATCH 02/34] MPFR: Fix `round(Integer, big(Inf))` (#44676) It also fixes `round(Integer, big(NaN))`. Solves #44662 (cherry picked from commit ecf3558c94898ddd4272b319d3405cf7256c6db7) --- base/mpfr.jl | 9 ++++++++- test/mpfr.jl | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/base/mpfr.jl b/base/mpfr.jl index c85531856f5c9..cd8c8092e0720 100644 --- a/base/mpfr.jl +++ b/base/mpfr.jl @@ -294,7 +294,14 @@ function round(::Type{T}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode}) end return unsafe_trunc(T, res) end -round(::Type{BigInt}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode}) = _unchecked_cast(BigInt, x, r) + +function round(::Type{BigInt}, x::BigFloat, r::Union{RoundingMode, MPFRRoundingMode}) + clear_flags() + res = _unchecked_cast(BigInt, x, r) + had_range_exception() && throw(InexactError(:round, BigInt, x)) + return res +end + round(::Type{T}, x::BigFloat, r::RoundingMode) where T<:Union{Signed, Unsigned} = invoke(round, Tuple{Type{<:Union{Signed, Unsigned}}, BigFloat, Union{RoundingMode, MPFRRoundingMode}}, T, x, r) round(::Type{BigInt}, x::BigFloat, r::RoundingMode) = diff --git a/test/mpfr.jl b/test/mpfr.jl index 86c7d345f49fd..54ec018327459 100644 --- a/test/mpfr.jl +++ b/test/mpfr.jl @@ -667,6 +667,10 @@ end @test typeof(round(Int64, x)) == Int64 && round(Int64, x) == 42 @test typeof(round(Int, x)) == Int && round(Int, x) == 42 @test typeof(round(UInt, x)) == UInt && round(UInt, x) == 0x2a + + # Issue #44662 + @test_throws InexactError round(Integer, big(Inf)) + @test_throws InexactError round(Integer, big(NaN)) end @testset "string representation" begin str = "1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012" From c908046a5c64a697f40a24fcfcbbe18e1df751f6 Mon Sep 17 00:00:00 2001 From: Simeon Schaub Date: Mon, 28 Mar 2022 15:35:10 -0400 Subject: [PATCH 03/34] errors: fix handling of `.op` in lowering (#44770) Discovered while running the syntax tests with lines 25-28 of `jlfrontend.scm` commented out. Turned out we didn't handle `.op` correctly in neither `check-dotop` nor in `deparse`. This meant we just got `error: malformed expression` instead of an actually useful error message. (cherry picked from commit 9112135140efe9ebd39727054e904bd881d46289) --- src/ast.scm | 18 ++++++++++-------- test/syntax.jl | 7 ++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/ast.scm b/src/ast.scm index 2fc4d90fe0e75..0c4fdcbc9c450 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -73,13 +73,15 @@ ((char? e) (string "'" e "'")) ((atom? e) (string e)) ((eq? (car e) '|.|) - (string (deparse (cadr e)) '|.| - (cond ((and (pair? (caddr e)) (memq (caaddr e) '(quote inert))) - (deparse-colon-dot (cadr (caddr e)))) - ((and (pair? (caddr e)) (eq? (caaddr e) 'copyast)) - (deparse-colon-dot (cadr (cadr (caddr e))))) - (else - (string #\( (deparse (caddr e)) #\)))))) + (if (length= e 2) + (string "(." (deparse (cadr e)) ")") + (string (deparse (cadr e)) '|.| + (cond ((and (pair? (caddr e)) (memq (caaddr e) '(quote inert))) + (deparse-colon-dot (cadr (caddr e)))) + ((and (pair? (caddr e)) (eq? (caaddr e) 'copyast)) + (deparse-colon-dot (cadr (cadr (caddr e))))) + (else + (string #\( (deparse (caddr e)) #\))))))) ((memq (car e) '(... |'|)) (string (deparse (cadr e)) (car e))) ((or (syntactic-op? (car e)) (eq? (car e) '|<:|) (eq? (car e) '|>:|) (eq? (car e) '-->)) @@ -419,7 +421,7 @@ (if (dotop-named? e) (error (string "invalid function name \"" (deparse e) "\"")) (if (pair? e) - (if (eq? (car e) '|.|) + (if (and (eq? (car e) '|.|) (length= e 3)) (check-dotop (caddr e)) (if (quoted? e) (check-dotop (cadr e)))))) diff --git a/test/syntax.jl b/test/syntax.jl index f6ba616167f9b..0bc6c5f8a538d 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1889,7 +1889,12 @@ f31404(a, b; kws...) = (a, b, kws.data) # issue #28992 macro id28992(x) x end @test @id28992(1 .+ 2) == 3 -@test Meta.isexpr(Meta.lower(@__MODULE__, :(@id28992((.+)(a,b) = 0))), :error) +@test Meta.@lower(.+(a,b) = 0) == Expr(:error, "invalid function name \".+\"") +@test Meta.@lower((.+)(a,b) = 0) == Expr(:error, "invalid function name \"(.+)\"") +let m = @__MODULE__ + @test Meta.lower(m, :($m.@id28992(.+(a,b) = 0))) == Expr(:error, "invalid function name \"$(nameof(m)).:.+\"") + @test Meta.lower(m, :($m.@id28992((.+)(a,b) = 0))) == Expr(:error, "invalid function name \"(.$(nameof(m)).+)\"") +end @test @id28992([1] .< [2] .< [3]) == [true] @test @id28992(2 ^ -2) == 0.25 @test @id28992(2 .^ -2) == 0.25 From 89b3c22586147738c2e332414a04c30a344285fc Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 7 Apr 2022 13:48:04 -0400 Subject: [PATCH 04/34] fix missing field type initialization vars (#44797) We were accidentally passing the start of the list instead of the end of the list, resulting in some values passing through uninitialized. Fix #42297 regression (cherry picked from commit 5f2abf6cfaa49220f08900d6a7a4422b94e32187) --- src/jltypes.c | 4 ++-- test/core.jl | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/jltypes.c b/src/jltypes.c index 26288f83edd96..8227c7d629092 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -1806,7 +1806,7 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw! for (i = 0; i < n; i++) env[i].val = jl_svecref(ndt->parameters, i); - ndt->super = (jl_datatype_t*)inst_type_w_((jl_value_t*)t->super, env, &top, 1); + ndt->super = (jl_datatype_t*)inst_type_w_((jl_value_t*)t->super, &env[n - 1], &top, 1); jl_gc_wb(ndt, ndt->super); } @@ -1816,7 +1816,7 @@ void jl_reinstantiate_inner_types(jl_datatype_t *t) // can throw! for (i = 0; i < n; i++) env[i].val = jl_svecref(ndt->parameters, i); assert(ndt->types == NULL); - ndt->types = inst_ftypes(t->types, env, &top); + ndt->types = inst_ftypes(t->types, &env[n - 1], &top); jl_gc_wb(ndt, ndt->types); if (ndt->isconcretetype) { // cacheable jl_compute_field_offsets(ndt); diff --git a/test/core.jl b/test/core.jl index 3424cdbdb418c..4d5590d7642dc 100644 --- a/test/core.jl +++ b/test/core.jl @@ -239,6 +239,15 @@ end #struct S22624{A,B,C} <: Ref{S22624{Int64,A}}; end @test_broken @isdefined S22624 +# issue #42297 +mutable struct Node42297{T, V} + value::V + next::Union{Node42297{T, T}, Node42297{T, Val{T}}, Nothing} + Node42297{T}(value) where {T} = new{T, typeof(value)}(value, nothing) +end +@test fieldtype(Node42297{Int,Val{Int}}, 1) === Val{Int} +@test fieldtype(Node42297{Int,Int}, 1) === Int + # issue #3890 mutable struct A3890{T1} x::Matrix{Complex{T1}} From 159ce706b0f6fcfcdd0fda9f35d92d6830f863e5 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 14 Apr 2022 04:19:56 -0400 Subject: [PATCH 05/34] [REPL] Fix a REPL test failure by removing an erroneous space in test (#44972) * [REPL] remove erroneous space in test Introduced by https://github.com/JuliaLang/julia/pull/33805 (74f2de13727373b44da76a65ceb5297889d3e482). * Revert "Temporarily move the `REPL` test suite to node 1, to buy us time until we fix the underlying bugs (#44961)" This reverts commit 322fd706a1739daf4776fd050df756e6670ba958. (cherry picked from commit fbec395fd049948618442569aa3a7708ceed2013) --- stdlib/REPL/test/repl.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/REPL/test/repl.jl b/stdlib/REPL/test/repl.jl index 7d3c8117405dd..17917d2423a2f 100644 --- a/stdlib/REPL/test/repl.jl +++ b/stdlib/REPL/test/repl.jl @@ -264,7 +264,7 @@ fake_repl(options = REPL.Options(confirm_exit=false,hascolor=true)) do stdin_wri write(stdin_write, ";") readuntil(stdout_read, "shell> ") Base.print_shell_escaped(stdin_write, Base.julia_cmd().exec..., special=Base.shell_special) - write(stdin_write, """ -e "println(\\"HI\\")\" """) + write(stdin_write, """ -e "println(\\"HI\\")\"""") readuntil(stdout_read, ")\"") proc_stdout_read, proc_stdout = redirect_stdout() get_stdout = @async read(proc_stdout_read, String) From 294b14228a6c4de1c5d2cf38e3b83430e73ad8e6 Mon Sep 17 00:00:00 2001 From: Bart Janssens Date: Fri, 15 Apr 2022 00:47:21 +0200 Subject: [PATCH 06/34] Fix embedding with MSVC (#44976) (cherry picked from commit c589e0d59541b1240f5bf77c7ce8c22594179e1b) --- src/support/dtypes.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/support/dtypes.h b/src/support/dtypes.h index 46780e8e64d4a..3e2fa18b0a67b 100644 --- a/src/support/dtypes.h +++ b/src/support/dtypes.h @@ -29,6 +29,16 @@ #include #include +#if defined(_COMPILER_MICROSOFT_) && !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) + +/* See https://github.com/JuliaLang/julia/pull/44587 */ +typedef intptr_t ssize_t; +#define SSIZE_MAX INTPTR_MAX +#define _SSIZE_T_ +#define _SSIZE_T_DEFINED + +#endif /* defined(_COMPILER_MICROSOFT_) && !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) */ + #if !defined(_COMPILER_GCC_) #define strtoull _strtoui64 From 80ffc2ee402971632defba680cf10ef6d542f595 Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Tue, 19 Apr 2022 04:40:13 -0400 Subject: [PATCH 07/34] Update Example header in admonition to render PDF better, see #44866. (#45026) (cherry picked from commit d29d2d622ae416c3e5ba82cb55ef0535a75fe8e8) --- base/floatfuncs.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/base/floatfuncs.jl b/base/floatfuncs.jl index 2bca2989bab0b..2552c5f1c66e7 100644 --- a/base/floatfuncs.jl +++ b/base/floatfuncs.jl @@ -97,9 +97,8 @@ julia> round(357.913; sigdigits=4, base=2) Rounding to specified digits in bases other than 2 can be inexact when operating on binary floating point numbers. For example, the [`Float64`](@ref) value represented by `1.15` is actually *less* than 1.15, yet will be - rounded to 1.2. + rounded to 1.2. For example: - # Examples ```jldoctest; setup = :(using Printf) julia> x = 1.15 1.15 From 9e9879b952d9565ba6efc775b3abf2f4630c7e1e Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 20 Apr 2022 11:51:32 -0400 Subject: [PATCH 08/34] gc-ext: only sweep unmarked objects (#45035) This prior conditional was a fixed constant branch, so this seems more like the intent. (cherry picked from commit ac51add4a610668835bb12db4913af1c2c16aaf8) --- src/gc.c | 13 +++++++------ test/gcext/gcext.c | 6 ++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gc.c b/src/gc.c index df06d7e5a6e7f..a9f8f952795bc 100644 --- a/src/gc.c +++ b/src/gc.c @@ -548,20 +548,21 @@ JL_DLLEXPORT void jl_finalize_th(jl_ptls_t ptls, jl_value_t *o) arraylist_free(&copied_list); } +// explicitly scheduled objects for the sweepfunc callback static void gc_sweep_foreign_objs_in_list(arraylist_t *objs) { size_t p = 0; for (size_t i = 0; i < objs->len; i++) { - jl_value_t *v = (jl_value_t *)(objs->items[i]); - jl_datatype_t *t = (jl_datatype_t *)(jl_typeof(v)); + jl_value_t *v = (jl_value_t*)(objs->items[i]); + jl_datatype_t *t = (jl_datatype_t*)(jl_typeof(v)); const jl_datatype_layout_t *layout = t->layout; jl_fielddescdyn_t *desc = (jl_fielddescdyn_t*)jl_dt_layout_fields(layout); - if (!gc_ptr_tag(v, 1)) { + + int bits = jl_astaggedvalue(v)->bits.gc; + if (!gc_marked(bits)) desc->sweepfunc(v); - } - else { + else objs->items[p++] = v; - } } objs->len = p; } diff --git a/test/gcext/gcext.c b/test/gcext/gcext.c index 2b380c43feccb..b66f21bb660ee 100644 --- a/test/gcext/gcext.c +++ b/test/gcext/gcext.c @@ -561,8 +561,10 @@ void sweep_stack_data(jl_value_t *p) { obj_sweeps++; dynstack_t *stk = (dynstack_t *)p; - if (stk->size > stk->capacity) - jl_error("internal error during sweeping"); + if (stk->size > stk->capacity) { + assert(0 && "internal error during sweeping"); + abort(); + } } // Safely execute Julia code From ea8455b704791eac7651a814c871b0d55c059d70 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Mon, 2 May 2022 12:11:21 +0400 Subject: [PATCH 09/34] Create a copy while evaluating eigvals(::Diagonal) (#45048) (cherry picked from commit b9d82808b8a3bd383b01d85ba3038b56e18c74e0) --- stdlib/LinearAlgebra/src/diagonal.jl | 2 +- stdlib/LinearAlgebra/test/diagonal.jl | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/diagonal.jl b/stdlib/LinearAlgebra/src/diagonal.jl index 7885bd62c2b1f..476d4e8990d81 100644 --- a/stdlib/LinearAlgebra/src/diagonal.jl +++ b/stdlib/LinearAlgebra/src/diagonal.jl @@ -659,7 +659,7 @@ function pinv(D::Diagonal{T}, tol::Real) where T end #Eigensystem -eigvals(D::Diagonal{<:Number}; permute::Bool=true, scale::Bool=true) = D.diag +eigvals(D::Diagonal{<:Number}; permute::Bool=true, scale::Bool=true) = copy(D.diag) eigvals(D::Diagonal; permute::Bool=true, scale::Bool=true) = [eigvals(x) for x in D.diag] #For block matrices, etc. eigvecs(D::Diagonal) = Matrix{eltype(D)}(I, size(D)) diff --git a/stdlib/LinearAlgebra/test/diagonal.jl b/stdlib/LinearAlgebra/test/diagonal.jl index 192641c748cc4..706706d30bd1a 100644 --- a/stdlib/LinearAlgebra/test/diagonal.jl +++ b/stdlib/LinearAlgebra/test/diagonal.jl @@ -403,6 +403,13 @@ end @test sort([eigvals(D)...;], by=LinearAlgebra.eigsortby) ≈ eigvals([D.diag[1] zeros(3,2); zeros(2,3) D.diag[2]]) end +@testset "eigvals should return a copy of the diagonal" begin + D = Diagonal([1, 2, 3]) + lam = eigvals(D) + D[3,3] = 4 # should not affect lam + @test lam == [1, 2, 3] +end + @testset "eigmin (#27847)" begin for _ in 1:100 d = randn(rand(1:10)) From 364d483a57b4ab64321355dddda91e74b735f4ee Mon Sep 17 00:00:00 2001 From: Simon Byrne Date: Sat, 7 May 2022 22:02:20 -0700 Subject: [PATCH 10/34] Avoid race condition in cleaning up cache files (#45214) If multiple processes attempt to clean up cache files at the same time, a race condition can result, e.g. https://buildkite.com/clima/climaatmos-ci/builds/812#6a961e99-e2a1-488b-a116-2a45dee26d38/102-104 (cherry picked from commit d4acead9130f97f0135bee604d94e1f67dabc70f) --- base/loading.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/loading.jl b/base/loading.jl index ce01a969f2fb2..1bd502479ac9c 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1368,7 +1368,7 @@ function compilecache(pkg::PkgId, path::String, internal_stderr::IO = stderr, in cachefiles = filter!(x -> startswith(x, entryfile * "_"), readdir(cachepath)) if length(cachefiles) >= MAX_NUM_PRECOMPILE_FILES[] idx = findmin(mtime.(joinpath.(cachepath, cachefiles)))[2] - rm(joinpath(cachepath, cachefiles[idx])) + rm(joinpath(cachepath, cachefiles[idx]); force=true) end end From 1054327770bafcbadccec86f5f8dd7897e020fdc Mon Sep 17 00:00:00 2001 From: Thomas van Doornmalen <60822431+Taaitaaiger@users.noreply.github.com> Date: Mon, 16 May 2022 14:05:25 +0200 Subject: [PATCH 11/34] Restore export of jl_options (#45308) Co-authored-by: Jeff Bezanson --- cli/loader.h | 4 ++ cli/loader_lib.c | 4 ++ src/Makefile | 2 +- src/jl_exported_data.inc | 3 +- src/jl_exported_funcs.inc | 1 + src/jloptions.c | 101 ++++++++++++++++++++----------------- src/jloptions.h | 55 ++++++++++++++++++++ src/julia.h | 54 ++------------------ test/embedding/embedding.c | 9 ++++ 9 files changed, 136 insertions(+), 97 deletions(-) create mode 100644 src/jloptions.h diff --git a/cli/loader.h b/cli/loader.h index 5b1c10abc9998..f044e63e9e382 100644 --- a/cli/loader.h +++ b/cli/loader.h @@ -21,6 +21,8 @@ #define realloc loader_realloc #endif +#include + #ifdef _OS_WINDOWS_ #define WIN32_LEAN_AND_MEAN #include @@ -105,3 +107,5 @@ int wchar_to_utf8(const wchar_t * wstr, char *str, size_t maxlen); int utf8_to_wchar(const char * str, wchar_t *wstr, size_t maxlen); void setup_stdio(void); #endif + +#include "../src/jloptions.h" diff --git a/cli/loader_lib.c b/cli/loader_lib.c index 414400c6d26dd..014fc36a34dbe 100644 --- a/cli/loader_lib.c +++ b/cli/loader_lib.c @@ -177,6 +177,10 @@ __attribute__((constructor)) void jl_load_libjulia_internal(void) { for (unsigned int symbol_idx=0; jl_exported_func_names[symbol_idx] != NULL; ++symbol_idx) { (*jl_exported_func_addrs[symbol_idx]) = lookup_symbol(libjulia_internal, jl_exported_func_names[symbol_idx]); } + + // jl_options must be initialized very early, in case an embedder sets some + // values there before calling jl_init + ((void (*)(void))jl_init_options_addr)(); } // Load libjulia and run the REPL with the given arguments (in UTF-8 format) diff --git a/src/Makefile b/src/Makefile index 503366a86fabd..abc512ce005d8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -88,7 +88,7 @@ SRCS += $(RUNTIME_SRCS) # headers are used for dependency tracking, while public headers will be part of the dist UV_HEADERS := HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,julia.h julia_assert.h julia_threads.h tls.h locks.h atomics.h julia_internal.h options.h timing.h) -PUBLIC_HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,julia.h julia_assert.h julia_threads.h tls.h locks.h atomics.h julia_gcext.h) +PUBLIC_HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,julia.h julia_assert.h julia_threads.h tls.h locks.h atomics.h julia_gcext.h jloptions.h) ifeq ($(USE_SYSTEM_LIBUV),0) UV_HEADERS += uv.h UV_HEADERS += uv/*.h diff --git a/src/jl_exported_data.inc b/src/jl_exported_data.inc index 3526896ab1c75..3fe6474c50f1a 100644 --- a/src/jl_exported_data.inc +++ b/src/jl_exported_data.inc @@ -121,4 +121,5 @@ // Data symbols that are defined inside the public libjulia #define JL_EXPORTED_DATA_SYMBOLS(XX) \ - XX(jl_n_threads, int) + XX(jl_n_threads, int) \ + XX(jl_options, jl_options_t) diff --git a/src/jl_exported_funcs.inc b/src/jl_exported_funcs.inc index c80d4139f058e..560d1e7491538 100644 --- a/src/jl_exported_funcs.inc +++ b/src/jl_exported_funcs.inc @@ -380,6 +380,7 @@ XX(jl_init_restored_modules) \ XX(jl_init__threading) \ XX(jl_init_with_image__threading) \ + XX(jl_init_options) \ XX(jl_install_sigint_handler) \ XX(jl_instantiate_type_in_env) \ XX(jl_instantiate_unionall) \ diff --git a/src/jloptions.c b/src/jloptions.c index 1beea6f30f5c3..f341094d7745c 100644 --- a/src/jloptions.c +++ b/src/jloptions.c @@ -28,55 +28,64 @@ JL_DLLEXPORT const char *jl_get_default_sysimg_path(void) } -jl_options_t jl_options = { 0, // quiet - -1, // banner - NULL, // julia_bindir - NULL, // julia_bin - NULL, // cmds - NULL, // image_file (will be filled in below) - NULL, // cpu_target ("native", "core2", etc...) - 0, // nthreads - 0, // nprocs - NULL, // machine_file - NULL, // project - 0, // isinteractive - 0, // color - JL_OPTIONS_HISTORYFILE_ON, // history file - 0, // startup file - JL_OPTIONS_COMPILE_DEFAULT, // compile_enabled - 0, // code_coverage - 0, // malloc_log - 2, // opt_level +static int jl_options_initialized = 0; + +JL_DLLEXPORT void jl_init_options(void) +{ + if (jl_options_initialized) + return; + jl_options = + (jl_options_t){ 0, // quiet + -1, // banner + NULL, // julia_bindir + NULL, // julia_bin + NULL, // cmds + NULL, // image_file (will be filled in below) + NULL, // cpu_target ("native", "core2", etc...) + 0, // nthreads + 0, // nprocs + NULL, // machine_file + NULL, // project + 0, // isinteractive + 0, // color + JL_OPTIONS_HISTORYFILE_ON, // history file + 0, // startup file + JL_OPTIONS_COMPILE_DEFAULT, // compile_enabled + 0, // code_coverage + 0, // malloc_log + 2, // opt_level #ifdef JL_DEBUG_BUILD - 2, // debug_level [debug build] + 2, // debug_level [debug build] #else - 1, // debug_level [release build] + 1, // debug_level [release build] #endif - JL_OPTIONS_CHECK_BOUNDS_DEFAULT, // check_bounds - JL_OPTIONS_DEPWARN_OFF, // deprecation warning - 0, // method overwrite warning - 1, // can_inline - JL_OPTIONS_POLLY_ON, // polly - NULL, // trace_compile - JL_OPTIONS_FAST_MATH_DEFAULT, - 0, // worker - NULL, // cookie - JL_OPTIONS_HANDLE_SIGNALS_ON, - JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES, - JL_OPTIONS_USE_COMPILED_MODULES_YES, - NULL, // bind-to - NULL, // output-bc - NULL, // output-unopt-bc - NULL, // output-o - NULL, // output-asm - NULL, // output-ji - NULL, // output-code_coverage - 0, // incremental - 0, // image_file_specified - JL_OPTIONS_WARN_SCOPE_ON, // ambiguous scope warning - 0, // image-codegen - 0, // rr-detach -}; + JL_OPTIONS_CHECK_BOUNDS_DEFAULT, // check_bounds + JL_OPTIONS_DEPWARN_OFF, // deprecation warning + 0, // method overwrite warning + 1, // can_inline + JL_OPTIONS_POLLY_ON, // polly + NULL, // trace_compile + JL_OPTIONS_FAST_MATH_DEFAULT, + 0, // worker + NULL, // cookie + JL_OPTIONS_HANDLE_SIGNALS_ON, + JL_OPTIONS_USE_SYSIMAGE_NATIVE_CODE_YES, + JL_OPTIONS_USE_COMPILED_MODULES_YES, + NULL, // bind-to + NULL, // output-bc + NULL, // output-unopt-bc + NULL, // output-o + NULL, // output-asm + NULL, // output-ji + NULL, // output-code_coverage + 0, // incremental + 0, // image_file_specified + JL_OPTIONS_WARN_SCOPE_ON, // ambiguous scope warning + 0, // image-codegen + 0, // rr-detach + }; + jl_options_initialized = 1; +} static const char usage[] = "julia [switches] -- [programfile] [args...]\n"; static const char opts[] = diff --git a/src/jloptions.h b/src/jloptions.h new file mode 100644 index 0000000000000..b1efa4908088c --- /dev/null +++ b/src/jloptions.h @@ -0,0 +1,55 @@ +// This file is a part of Julia. License is MIT: https://julialang.org/license + +#ifndef JL_JLOPTIONS_H +#define JL_JLOPTIONS_H + +// NOTE: This struct needs to be kept in sync with JLOptions type in base/options.jl + +typedef struct { + int8_t quiet; + int8_t banner; + const char *julia_bindir; + const char *julia_bin; + const char **cmds; + const char *image_file; + const char *cpu_target; + int32_t nthreads; + int32_t nprocs; + const char *machine_file; + const char *project; + int8_t isinteractive; + int8_t color; + int8_t historyfile; + int8_t startupfile; + int8_t compile_enabled; + int8_t code_coverage; + int8_t malloc_log; + int8_t opt_level; + int8_t debug_level; + int8_t check_bounds; + int8_t depwarn; + int8_t warn_overwrite; + int8_t can_inline; + int8_t polly; + const char *trace_compile; + int8_t fast_math; + int8_t worker; + const char *cookie; + int8_t handle_signals; + int8_t use_sysimage_native_code; + int8_t use_compiled_modules; + const char *bindto; + const char *outputbc; + const char *outputunoptbc; + const char *outputo; + const char *outputasm; + const char *outputji; + const char *output_code_coverage; + int8_t incremental; + int8_t image_file_specified; + int8_t warn_scope; + int8_t image_codegen; + int8_t rr_detach; +} jl_options_t; + +#endif diff --git a/src/julia.h b/src/julia.h index 9bd41f639a20c..c368e8a5a9d26 100644 --- a/src/julia.h +++ b/src/julia.h @@ -1899,55 +1899,11 @@ JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT; JL_DLLEXPORT void jl_(void *jl_value) JL_NOTSAFEPOINT; // julia options ----------------------------------------------------------- -// NOTE: This struct needs to be kept in sync with JLOptions type in base/options.jl -typedef struct { - int8_t quiet; - int8_t banner; - const char *julia_bindir; - const char *julia_bin; - const char **cmds; - const char *image_file; - const char *cpu_target; - int32_t nthreads; - int32_t nprocs; - const char *machine_file; - const char *project; - int8_t isinteractive; - int8_t color; - int8_t historyfile; - int8_t startupfile; - int8_t compile_enabled; - int8_t code_coverage; - int8_t malloc_log; - int8_t opt_level; - int8_t debug_level; - int8_t check_bounds; - int8_t depwarn; - int8_t warn_overwrite; - int8_t can_inline; - int8_t polly; - const char *trace_compile; - int8_t fast_math; - int8_t worker; - const char *cookie; - int8_t handle_signals; - int8_t use_sysimage_native_code; - int8_t use_compiled_modules; - const char *bindto; - const char *outputbc; - const char *outputunoptbc; - const char *outputo; - const char *outputasm; - const char *outputji; - const char *output_code_coverage; - int8_t incremental; - int8_t image_file_specified; - int8_t warn_scope; - int8_t image_codegen; - int8_t rr_detach; -} jl_options_t; - -extern JL_DLLEXPORT jl_options_t jl_options; + +#include "jloptions.h" + +extern JL_DLLIMPORT jl_options_t jl_options; + JL_DLLEXPORT ssize_t jl_sizeof_jl_options(void); // Parse an argc/argv pair to extract general julia options, passing back out diff --git a/test/embedding/embedding.c b/test/embedding/embedding.c index 205b8a7450211..43463b75c1c3c 100644 --- a/test/embedding/embedding.c +++ b/test/embedding/embedding.c @@ -32,6 +32,9 @@ jl_value_t *checked_eval_string(const char* code) int main() { + // check that setting options works + jl_options.opt_level = 1; + jl_init(); { @@ -40,6 +43,12 @@ int main() checked_eval_string("println(sqrt(2.0))"); } + if (jl_options.opt_level != 1) { + jl_printf(jl_stderr_stream(), "setting jl_options didn't work\n"); + jl_atexit_hook(1); + exit(1); + } + { // Accessing the return value From 427daf13c1a48026a1ec65c008277da90ef1936c Mon Sep 17 00:00:00 2001 From: N5N3 <2642243996@qq.com> Date: Mon, 16 May 2022 20:07:03 +0800 Subject: [PATCH 12/34] Use `CartesianIndices(Rsrc)` as the shared iterator. (#45289) There's no performance change, if the `indices`s of `Rdest` and `Rsrc` are all `NTuple{N,<:AbstractUnitRange}`. (cherry picked from commit a91be39b671638b8c48215931eb4ccd948ce33a3) --- base/multidimensional.jl | 12 +++++++----- test/copy.jl | 13 ++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index b3ac26ff4fbb3..02c9b04927f5c 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -1076,16 +1076,18 @@ function copyto!(dest::AbstractArray{T1,N}, Rdest::CartesianIndices{N}, checkbounds(src, first(Rsrc)) checkbounds(src, last(Rsrc)) src′ = unalias(dest, src) - ΔI = first(Rdest) - first(Rsrc) + CRdest = CartesianIndices(Rdest) + CRsrc = CartesianIndices(Rsrc) + ΔI = first(CRdest) - first(CRsrc) if @generated quote - @nloops $N i (n->Rsrc.indices[n]) begin - @inbounds @nref($N,dest,n->i_n+ΔI[n]) = @nref($N,src′,i) + @nloops $N i (n->CRsrc.indices[n]) begin + @inbounds @nref($N,dest,n->Rdest.indices[n][i_n+ΔI[n]]) = @nref($N,src,n->Rsrc.indices[n][i_n]) end end else - for I in Rsrc - @inbounds dest[I + ΔI] = src′[I] + for I in CRsrc + @inbounds dest[Rdest[I + ΔI]] = src′[Rsrc[I]] end end dest diff --git a/test/copy.jl b/test/copy.jl index 34d1c20c5f4fa..eba575836e12f 100644 --- a/test/copy.jl +++ b/test/copy.jl @@ -58,11 +58,14 @@ end @test B == A end let A = reshape(1:6, 3, 2), B = zeros(8,8) - RA = CartesianIndices(axes(A)) - copyto!(B, CartesianIndices((5:7,2:3)), A, RA) - @test B[5:7,2:3] == A - B[5:7,2:3] .= 0 - @test all(x->x==0, B) + RBs = Any[(5:7,2:3), (3:2:7,1:2:3), (6:-1:4,2:-1:1)] + RAs = Any[axes(A), reverse.(axes(A))] + for RB in RBs, RA in RAs + copyto!(B, CartesianIndices(RB), A, CartesianIndices(RA)) + @test B[RB...] == A[RA...] + B[RB...] .= 0 + @test all(iszero, B) + end end end From 42f7a991944fe14a93830c58875d987a5047f5c1 Mon Sep 17 00:00:00 2001 From: N5N3 <2642243996@qq.com> Date: Tue, 17 May 2022 18:54:03 +0800 Subject: [PATCH 13/34] Typo fix. (#45333) (cherry picked from commit eed2dba73d5c781055c23120d357a17c875e685b) --- base/multidimensional.jl | 2 +- test/copy.jl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 02c9b04927f5c..1c63addc77f03 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -1082,7 +1082,7 @@ function copyto!(dest::AbstractArray{T1,N}, Rdest::CartesianIndices{N}, if @generated quote @nloops $N i (n->CRsrc.indices[n]) begin - @inbounds @nref($N,dest,n->Rdest.indices[n][i_n+ΔI[n]]) = @nref($N,src,n->Rsrc.indices[n][i_n]) + @inbounds @nref($N,dest,n->Rdest.indices[n][i_n+ΔI[n]]) = @nref($N,src′,n->Rsrc.indices[n][i_n]) end end else diff --git a/test/copy.jl b/test/copy.jl index eba575836e12f..991f6db1c56b6 100644 --- a/test/copy.jl +++ b/test/copy.jl @@ -67,6 +67,10 @@ end @test all(iszero, B) end end + let A = [reshape(1:6, 3, 2);;] + copyto!(A, CartesianIndices((2:3,2)), A, CartesianIndices((2,2))) + @test A[2:3,:] == [1 4;2 5] + end end @testset "shallow and deep copying" begin From 87a22e4ac3f1b3562fb741bbd63fd9c74367b2ee Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Sat, 21 May 2022 03:09:47 +0000 Subject: [PATCH 14/34] Use root module when determining UUID in @artifact_str (#45392) Otherwise, overrides do not trigger when using `artifact"..."` inside a submodule. (cherry picked from commit 9b106adcdff120cdfc1fb0c0d6c50b68a787ce95) --- stdlib/Artifacts/src/Artifacts.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/Artifacts/src/Artifacts.jl b/stdlib/Artifacts/src/Artifacts.jl index fd65494782d92..d4e2f7369f9de 100644 --- a/stdlib/Artifacts/src/Artifacts.jl +++ b/stdlib/Artifacts/src/Artifacts.jl @@ -524,9 +524,10 @@ function jointail(dir, tail) end function _artifact_str(__module__, artifacts_toml, name, path_tail, artifact_dict, hash, platform, @nospecialize(lazyartifacts)) - if haskey(Base.module_keys, __module__) + moduleroot = Base.moduleroot(__module__) + if haskey(Base.module_keys, moduleroot) # Process overrides for this UUID, if we know what it is - process_overrides(artifact_dict, Base.module_keys[__module__].uuid) + process_overrides(artifact_dict, Base.module_keys[moduleroot].uuid) end # If the artifact exists, we're in the happy path and we can immediately From 29559e0c68d911cbe0b6e8f63d4b2cdf8cb3af6d Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Fri, 20 May 2022 12:00:29 -0400 Subject: [PATCH 15/34] Apply patch for GMP CVE-2021-43618 (#45375) * Apply patch for GMP CVE-2021-43618 * Update checksums (cherry picked from commit dea980590f41bab820be4c42b42f29639ac8a56c) --- deps/Versions.make | 2 +- deps/checksums/gmp | 120 +++++++++++++------------- deps/gmp.mk | 1 + deps/patches/gmp-CVE-2021-43618.patch | 24 ++++++ stdlib/GMP_jll/Project.toml | 2 +- stdlib/GMP_jll/test/runtests.jl | 2 +- 6 files changed, 88 insertions(+), 63 deletions(-) create mode 100644 deps/patches/gmp-CVE-2021-43618.patch diff --git a/deps/Versions.make b/deps/Versions.make index 57a655fc72f78..835f95fafc58e 100644 --- a/deps/Versions.make +++ b/deps/Versions.make @@ -22,7 +22,7 @@ DSFMT_VER := 2.2.4 DSFMT_JLL_NAME := dSFMT # GMP -GMP_VER := 6.2.0 +GMP_VER := 6.2.1 GMP_JLL_NAME := GMP # LibCURL diff --git a/deps/checksums/gmp b/deps/checksums/gmp index ef25514213951..0c45aa6a00ca9 100644 --- a/deps/checksums/gmp +++ b/deps/checksums/gmp @@ -1,60 +1,60 @@ -GMP.v6.2.0+5.aarch64-apple-darwin.tar.gz/md5/5f75eae2bc2bfe01900fc079443bc713 -GMP.v6.2.0+5.aarch64-apple-darwin.tar.gz/sha512/4beb187fc6999ef59b0f76fbf0a106f828580f34627585b090237c227b3bde71ea7e6b7e9f47efc4d0778663ea8f44e8a49a87e16967bc08a6d9df8c975a517e -GMP.v6.2.0+5.aarch64-linux-gnu-cxx03.tar.gz/md5/0df64b64219c8670fcccb5029d352617 -GMP.v6.2.0+5.aarch64-linux-gnu-cxx03.tar.gz/sha512/3cb845af24efae59a458b27c03873ad08efbef8a844fc3f4a19843e62f42b86777c86b156485a40dd8e1dda2d93891b98a473b82ab1273c8ec0bfd43fd9b83f7 -GMP.v6.2.0+5.aarch64-linux-gnu-cxx11.tar.gz/md5/9290a852a885516e2418a19146ae105a -GMP.v6.2.0+5.aarch64-linux-gnu-cxx11.tar.gz/sha512/b5078656ad0ca03556bb87bd077934553caa12d11df6641a172688a58f6e54955f72b198af1bded9caaea7defb76f884077109fc66a4eefd98d3d1240c6c8bc9 -GMP.v6.2.0+5.aarch64-linux-musl-cxx03.tar.gz/md5/085072bd7713a747e66cc20428691fe7 -GMP.v6.2.0+5.aarch64-linux-musl-cxx03.tar.gz/sha512/611025f6287cc19d882414a17ab2a0888dfe65bf4715513456349cb4fc89ef218194449c3c49019a8773ea1a9c5e753214c5457aff338491aed7d3b6c61c3113 -GMP.v6.2.0+5.aarch64-linux-musl-cxx11.tar.gz/md5/e0a580e0d4ca4981d7113c87c6a72ed2 -GMP.v6.2.0+5.aarch64-linux-musl-cxx11.tar.gz/sha512/1167143852e40071fbb9895d868555f85a15a22b85a74360c96e2c3397108adc211a54615bfa4fd464b5c34ccd33254371432d1fdd7dfae19088d0b6b77f9d6a -GMP.v6.2.0+5.armv6l-linux-gnueabihf-cxx03.tar.gz/md5/6b564f8a10a9499c32286216ba2ef64e -GMP.v6.2.0+5.armv6l-linux-gnueabihf-cxx03.tar.gz/sha512/4bccef0f8580dffee7b3fb9b950d7bc22dc7a898ad38f1b3e180b8f4f3e8a6420f39f537f8fd7c9bd08257f22a20dd342b1e1ad2d09333af81d7d02a1f8a3a9f -GMP.v6.2.0+5.armv6l-linux-gnueabihf-cxx11.tar.gz/md5/cec6daeca638ffb03a412cc0e44848ef -GMP.v6.2.0+5.armv6l-linux-gnueabihf-cxx11.tar.gz/sha512/4cbef04ec7d1449a6d1d689db281935a4c7c61aa3ce26b1bed23e08e5950fef56bcc0b98b2636068a7b5adb3554a054d3c0024cb9d87ebea94e24ff3e0f19614 -GMP.v6.2.0+5.armv6l-linux-musleabihf-cxx03.tar.gz/md5/6f197412d758a1afc9327fc7f1a1ce53 -GMP.v6.2.0+5.armv6l-linux-musleabihf-cxx03.tar.gz/sha512/d242f4d1ac713bd5994d46280a55b0f4298b4ae82536570903a55fb15db56f97b1b4872799f9b52116942d6dc5865a2f14c087e352b6b444d3697c8917f14cbc -GMP.v6.2.0+5.armv6l-linux-musleabihf-cxx11.tar.gz/md5/7d9f00a3f319c2bfe45b6ac6a686d35e -GMP.v6.2.0+5.armv6l-linux-musleabihf-cxx11.tar.gz/sha512/8cc82095b3db04da2c3ee8003d328d96475a7ebe138852be91500dabcc2501c9cc8936d6a0b2f99b666f7934a738f62cbc6af8915f1cafd42c9353ecb9dceed0 -GMP.v6.2.0+5.armv7l-linux-gnueabihf-cxx03.tar.gz/md5/f7c3a1915bc8ddd73bfe33899f06bcbd -GMP.v6.2.0+5.armv7l-linux-gnueabihf-cxx03.tar.gz/sha512/f9a72432fdc578165df066ee46eaeef0b6d44018cc041ed7c4cac8cb82d5069fcde12733bdefce318e48970e45b11fd78f6c2ebc36dd8e8324467c19214c5197 -GMP.v6.2.0+5.armv7l-linux-gnueabihf-cxx11.tar.gz/md5/9644266ed5c8f0f5ef87f07ee8d758a9 -GMP.v6.2.0+5.armv7l-linux-gnueabihf-cxx11.tar.gz/sha512/fb8586e87bba6c3950095f1273b1c0a70a5ad52c34379fce0c886669334f61cb24fc55224e0bfdf80070888e7bd1696f154a6409cecbe3dc9968a20277598935 -GMP.v6.2.0+5.armv7l-linux-musleabihf-cxx03.tar.gz/md5/1444f907bd9ea868b056d63a4ae92558 -GMP.v6.2.0+5.armv7l-linux-musleabihf-cxx03.tar.gz/sha512/02799c2e0fbc2adcc5da16765946bc6972024f8b46ed51c341add754c4873d38437e09b61a75658b0042b2ae18c32abbf10f87021a661254be717534ce17a37c -GMP.v6.2.0+5.armv7l-linux-musleabihf-cxx11.tar.gz/md5/c0d5ea9800c7a488a609979e3a0880ea -GMP.v6.2.0+5.armv7l-linux-musleabihf-cxx11.tar.gz/sha512/b8307100b9c9fb9fc112bea4347b804842aa144c03e739cbee74718ecc27e9af5df60c81a7768f23ddee5dd27b85053289962777e62dc19b9960e3c0265c0e88 -GMP.v6.2.0+5.i686-linux-gnu-cxx03.tar.gz/md5/88c7c248c87298fcce367f4795a7926c -GMP.v6.2.0+5.i686-linux-gnu-cxx03.tar.gz/sha512/4832aa5064fdfb1c347048f3c26942689e56e38139fc404d8d7624a0fe03c1a303b94a4bbd2f52d72c712f8e62f656be529def1a6fefc3fe78c634710ba70ed2 -GMP.v6.2.0+5.i686-linux-gnu-cxx11.tar.gz/md5/d1ed99747cc28883d0d9c5d86977d46f -GMP.v6.2.0+5.i686-linux-gnu-cxx11.tar.gz/sha512/6b9307fe61e79f7ad59e5d78b7ca2f2bf8546e7e2badd9862bf2ec95ea86bedec7d4b5563bb08dd00adfd2fe4777976170eba99a0932173e50ce72b0d59c971d -GMP.v6.2.0+5.i686-linux-musl-cxx03.tar.gz/md5/fa901a508f5d1d1ba951a1b9e038a2db -GMP.v6.2.0+5.i686-linux-musl-cxx03.tar.gz/sha512/477c8f46d81500bbc45392b448e7a054913d0d9d7e28b153c70891eb001f6860b79ab76c8131a596be3bb4983bbf555f584666094a8a573c3574f32e808fac57 -GMP.v6.2.0+5.i686-linux-musl-cxx11.tar.gz/md5/f72fb32460189553204e4bc1c0f957d3 -GMP.v6.2.0+5.i686-linux-musl-cxx11.tar.gz/sha512/ca4c57f147b6795087cc706572f2c61041ea74b463eec436ec4f8695e06df66b844d1fd2ffcd7ef777987f397e594a6f267ba19f3d2c5973dce9d55fcfa5f47a -GMP.v6.2.0+5.i686-w64-mingw32-cxx03.tar.gz/md5/04e6de93662ebda2a8c4604f5066b8e1 -GMP.v6.2.0+5.i686-w64-mingw32-cxx03.tar.gz/sha512/d131360b19fe1d8e45091f60c8056e71ec14a551b7d6192625c9777ba5daac327326c1d3211bc5459b5f0f2d466f9fb112bb5f6e7ab0e71d560068911eb0b6d9 -GMP.v6.2.0+5.i686-w64-mingw32-cxx11.tar.gz/md5/7cc18e6f73476c58bc13e9bf2cf7daf8 -GMP.v6.2.0+5.i686-w64-mingw32-cxx11.tar.gz/sha512/312e96cf2e7b45fc8994998b0aa616d72a4bf9f5a7055416c484bd7dcc3df81365b15465f6cd24c0e2529cd4bee67c07f49fe9ceb2b067770db0965d880cb9c0 -GMP.v6.2.0+5.powerpc64le-linux-gnu-cxx03.tar.gz/md5/27192e9ffab4fd8449a33cbed329a27a -GMP.v6.2.0+5.powerpc64le-linux-gnu-cxx03.tar.gz/sha512/f826bfa5a29c443bc902930810f032877f623341f403dd4c532f7105acf647c983570a555c74c3273b4887a5dce3ae97cf4fe88d0f139411d632c3d24451fbc7 -GMP.v6.2.0+5.powerpc64le-linux-gnu-cxx11.tar.gz/md5/85050f4b290dea72629cc14935523981 -GMP.v6.2.0+5.powerpc64le-linux-gnu-cxx11.tar.gz/sha512/b272fd8ca4802860ecda1727ffc07479a9bb9afa35850bddb624644fff0641607070b5ecfb9ff8e05efd59d5739fed3b32a7163d56440a7c103aab1b5f81a3fb -GMP.v6.2.0+5.x86_64-apple-darwin.tar.gz/md5/245ffa4fc5ea5bfb42deb69d743630b5 -GMP.v6.2.0+5.x86_64-apple-darwin.tar.gz/sha512/da99905c7894e4a6a8f1b5edbc9fa94be4d69df0d76ff8816d562e2191da35209d5e79cd2d004f717018e750a0043f1c749bcac2c7742636b1b755a1b77f7d24 -GMP.v6.2.0+5.x86_64-linux-gnu-cxx03.tar.gz/md5/6d313a77ff5de004d51110e4df39e117 -GMP.v6.2.0+5.x86_64-linux-gnu-cxx03.tar.gz/sha512/3f2594d81dc48170c6f8f003b443703b07078aa0a3ff94432532b3dfd54d3b73ba88b04a77de35a8b8ef07fa139d9e32380ec7d5d638944eb1732b081fbccebc -GMP.v6.2.0+5.x86_64-linux-gnu-cxx11.tar.gz/md5/b5872c5a1b9fdae506e5abb9efe7953a -GMP.v6.2.0+5.x86_64-linux-gnu-cxx11.tar.gz/sha512/f4399c990b6aa773587ef9446c353911981ade9b845cb4b995c2eac26e8b85bb06270d1ea1231bc3b03675b2a1a4b3d01ae313d316a032fd9f6cc1d514fe0ebf -GMP.v6.2.0+5.x86_64-linux-musl-cxx03.tar.gz/md5/addb58e3359ca2d79a2ffac4a762f160 -GMP.v6.2.0+5.x86_64-linux-musl-cxx03.tar.gz/sha512/9807daba6b24551148bf22f33694a85d070be4f5ce749ac8b3089a61ce99062ba55c8ac9435360da7acdc87ad745258b8dae476ca3acce5baf3a4c0d94cf803a -GMP.v6.2.0+5.x86_64-linux-musl-cxx11.tar.gz/md5/1ff1128fd9b104e965a1902b86d84b9a -GMP.v6.2.0+5.x86_64-linux-musl-cxx11.tar.gz/sha512/ef4f7ac863156479fde6d296ca4c9b8b86e3a7b51b9fa0a6a962543a95be06b1d15b5824827e7dcd6a6cc0f67ef4e11458af0f4bfc7f4e1ec89118ebc7039819 -GMP.v6.2.0+5.x86_64-unknown-freebsd.tar.gz/md5/da8e2ed39d01c8c94e3ac6938ad2125b -GMP.v6.2.0+5.x86_64-unknown-freebsd.tar.gz/sha512/942fef1bb6eb778d56fecd65d3a2d8df5dc0203572fc9b5e4342a0c4ca9585273bb7edad72aafca3ced8c4079573a74dabee2b9350e021a3af29b16e4dca3eee -GMP.v6.2.0+5.x86_64-w64-mingw32-cxx03.tar.gz/md5/c03c2273b6add1a64249072f584bca5b -GMP.v6.2.0+5.x86_64-w64-mingw32-cxx03.tar.gz/sha512/f65483d17003a9787dad32fe1ad8851963a2360fc3f7cc15619f2aae815416a7bc0953df3fdcea271a2a0e50403b167e2ca0825243f7a9aef4f69cbcaaebff3b -GMP.v6.2.0+5.x86_64-w64-mingw32-cxx11.tar.gz/md5/3eebe834583990ac58698988e8b1b6a9 -GMP.v6.2.0+5.x86_64-w64-mingw32-cxx11.tar.gz/sha512/1f70c06992fb667bcaf754bc33a81d836f0ad02bb8e5388259741ee5802afc8308fef7688a3ae90c281f7cf9a94ccbb6e82488de0c0c3bee8615ab03e65adc62 -gmp-6.2.0.tar.bz2/md5/c24161e0dd44cae78cd5f67193492a21 -gmp-6.2.0.tar.bz2/sha512/ff22ed47fff176ed56301ecab0213316150a3abb370fed031635804f829c878296d7c65597b1f687f394479eef04fae6eba771162f7d363dc4c94c7334fc1fc0 +GMP.v6.2.1+2.aarch64-apple-darwin.tar.gz/md5/37a4c537149a1d6d7424833294e61dac +GMP.v6.2.1+2.aarch64-apple-darwin.tar.gz/sha512/33dd86279b5b3b08496180c92971c2e7ef84715e9ed3a80071a178ee94de6231ea3cf7b4dd4fa7e0dbd0b386a1a04c4f6b28446e86cb92c100ebb295b2f5ee3a +GMP.v6.2.1+2.aarch64-linux-gnu-cxx03.tar.gz/md5/44ef76b228cdc4cf54e5d4b40a29034d +GMP.v6.2.1+2.aarch64-linux-gnu-cxx03.tar.gz/sha512/255a680c75d3e8ca542dffc47050adfce038e25a12a4131c18dc719d36b364c1a6488ee5743d1c5de445b4bc5ccbb932399f7071083d86fe5bd2befc521cfbfd +GMP.v6.2.1+2.aarch64-linux-gnu-cxx11.tar.gz/md5/0289ffc3621b5d62dc2f9e1b36c41f9f +GMP.v6.2.1+2.aarch64-linux-gnu-cxx11.tar.gz/sha512/f27b82efb5aa1d7eaaed7574d3312969664eac38f45cf40c6de13ca20b256d45481546fc1a402e6c04bee416c842a092a4e57b8df702bbcdc52f742555d07aa7 +GMP.v6.2.1+2.aarch64-linux-musl-cxx03.tar.gz/md5/9ff4c76804f59056b49a9bf5b6a02099 +GMP.v6.2.1+2.aarch64-linux-musl-cxx03.tar.gz/sha512/d86afa10bdc4e20fa259a17ce7d0a5dca2524b42752bc7d5c33e4323973587d234d4c420900deef34670bfce8ab8c6725e7edb45bfd3896b2644a42ec187dfd7 +GMP.v6.2.1+2.aarch64-linux-musl-cxx11.tar.gz/md5/cc9857a965afcdcbc2b378a368360690 +GMP.v6.2.1+2.aarch64-linux-musl-cxx11.tar.gz/sha512/c46bff9fdcbecc71c12914dadb31ee9fd5b4293cb45bda782200daa18d7f7e8b588e0c0f68a39c2fec7cc3d026bcef3620dae35ae2dd3acf2505dcfc084d11bd +GMP.v6.2.1+2.armv6l-linux-gnueabihf-cxx03.tar.gz/md5/5b3343367896e31b29571fe0d2b90390 +GMP.v6.2.1+2.armv6l-linux-gnueabihf-cxx03.tar.gz/sha512/65a501db63c386727aa336d6dbecdff0417628bc9ff7ac1b2161922246d94f8caa71b63fc3789ec6bb10aff03b96d5d0c22c37c82bd95d74e557df8de7e8a09c +GMP.v6.2.1+2.armv6l-linux-gnueabihf-cxx11.tar.gz/md5/cc04dda18412fa11f228e66eb5a03aad +GMP.v6.2.1+2.armv6l-linux-gnueabihf-cxx11.tar.gz/sha512/49fdd452fe8f0129ee06795e04a0cc0238132f9d6f60a124dd2c7395fabbb71f005c16d95fdc00d87f8bf82b048cc54e07f162fbc38223c644854cc72c4d26b0 +GMP.v6.2.1+2.armv6l-linux-musleabihf-cxx03.tar.gz/md5/675599595f3dedb8ca11151168da7110 +GMP.v6.2.1+2.armv6l-linux-musleabihf-cxx03.tar.gz/sha512/eedcdc2230fd81d613d54be356679a97b59491f5f9a17c518239b5504c3dd5da15721d553f57ae21f1c55d253e808e7afd1d1651b8c666379c55c7b48f71217e +GMP.v6.2.1+2.armv6l-linux-musleabihf-cxx11.tar.gz/md5/9a74abbc46439ae8268ca926f0045691 +GMP.v6.2.1+2.armv6l-linux-musleabihf-cxx11.tar.gz/sha512/6329506f7a886d0dd907b051d6cbab1bd0cd21b2d5715f55402bf9ad6cb1ae33e058931bdf6cba17658b0e455f9e4fb7f9aad274755a159106cfe1c4d1ea328a +GMP.v6.2.1+2.armv7l-linux-gnueabihf-cxx03.tar.gz/md5/8c20e0def927a202f2d23aed78aadb4a +GMP.v6.2.1+2.armv7l-linux-gnueabihf-cxx03.tar.gz/sha512/b7f42efae6fce864c9e07714056444ba74befb9cc9a766ffe14e676240f23f83d3241b1bf3a8f4a282acbdc197287fffb27dadedf3055505ad63bb0b9df573c6 +GMP.v6.2.1+2.armv7l-linux-gnueabihf-cxx11.tar.gz/md5/423a625816b3c52efa6021e76f6009b7 +GMP.v6.2.1+2.armv7l-linux-gnueabihf-cxx11.tar.gz/sha512/21cbbfd647d4a7c884344dc66e0fd83d654d22c3338669539e8eab515bdc6bbd772b47f949d28280789e4343e9a8d6319a73dc9e11c23da381b8a452ef7fb098 +GMP.v6.2.1+2.armv7l-linux-musleabihf-cxx03.tar.gz/md5/7d67f981538d7a69ab1e458a54bf56f4 +GMP.v6.2.1+2.armv7l-linux-musleabihf-cxx03.tar.gz/sha512/8aefbcddc326d4ef289dcdba8d3bd56a5f9656a7be30c83b4dbd9a0b8ee26a963c6a2f4294c94b8a8f2f712f1e1c9e17b8b9dcc9967d64294ca466e51656f7c7 +GMP.v6.2.1+2.armv7l-linux-musleabihf-cxx11.tar.gz/md5/ed8713b71636ea75fcc0c9fbc4a8618d +GMP.v6.2.1+2.armv7l-linux-musleabihf-cxx11.tar.gz/sha512/d7f50d06a256fd9176d5fbf682ff599a5ffba62bb35fb37321ab41e88970921a9d9fa4531bd74e73e471c7e15fcae568d0536d3e32a2b2d7f81dc9cd1f0c039f +GMP.v6.2.1+2.i686-linux-gnu-cxx03.tar.gz/md5/875f0bc57172788cb80ca2b80ff3065f +GMP.v6.2.1+2.i686-linux-gnu-cxx03.tar.gz/sha512/808a3c2422b5168260dbf7a3875d5c8151e10b20a8ec87a66bf08f71ad7cf5de20fb7a4f3457c3ab2b4ffc9627764c743baa96f409629c70f2233ea7a5b628b9 +GMP.v6.2.1+2.i686-linux-gnu-cxx11.tar.gz/md5/09ae13f2a6a0dc317d2bca5700d2bf59 +GMP.v6.2.1+2.i686-linux-gnu-cxx11.tar.gz/sha512/9c986e2904247de937e30c05b29e0179986d7747b217468c59bc56af6d4c48d4575f24dace521dc8d66d84230eebd695fe0538972bfd744182ca940a23a9239c +GMP.v6.2.1+2.i686-linux-musl-cxx03.tar.gz/md5/45f53fd95dd69a6ee6b43463976b5aa6 +GMP.v6.2.1+2.i686-linux-musl-cxx03.tar.gz/sha512/4df57d6c88f0ff86e0ee78da8f6ad02decf7a38884ae8c785c114e0e38e791b733e0d046c90712327c08645dd40b7f0391fcb3258cb3bfb8b6a62c59c27d6e83 +GMP.v6.2.1+2.i686-linux-musl-cxx11.tar.gz/md5/8b15988bfb1ba0543eefab73b3ac3439 +GMP.v6.2.1+2.i686-linux-musl-cxx11.tar.gz/sha512/e32dec7ded9bf6fc26033df83521481dde851c68d7cc45efaabeded7603417cdc5016de45f78a956b69aaed00a55a91aa8b1cd5bbe5431b01074dafce2c47751 +GMP.v6.2.1+2.i686-w64-mingw32-cxx03.tar.gz/md5/4138d0b5185f722aef4e1f215f381275 +GMP.v6.2.1+2.i686-w64-mingw32-cxx03.tar.gz/sha512/255d4ecf178b9440b667c56e542baa4422d731f83a67accd41b76268274c2344fbbf94979fddbbd1f6b5751bac2d228a8ef49a93365de78c1772146edd1b4845 +GMP.v6.2.1+2.i686-w64-mingw32-cxx11.tar.gz/md5/606b4b453af25ded1323aee9e085c132 +GMP.v6.2.1+2.i686-w64-mingw32-cxx11.tar.gz/sha512/8605b764ff6e5d81767432fd8e70c25c5ad76f2cac7c2b3d6ed0596df692300973803487c970a896a0a316d46de3e3cae31b21d4e11fe2961e228cd389da13da +GMP.v6.2.1+2.powerpc64le-linux-gnu-cxx03.tar.gz/md5/3fbd157df4ae738da6820b26fb75e75e +GMP.v6.2.1+2.powerpc64le-linux-gnu-cxx03.tar.gz/sha512/6e64c5c4e393c0001bd7085e627126134b5999c2d8df2fa9b72c9f9835d6b0f0ad440a2f58fe6537ec446a517f8df2667881871fce9b4d61c356d2b52080d641 +GMP.v6.2.1+2.powerpc64le-linux-gnu-cxx11.tar.gz/md5/35608e3166278d52a482d7e19313eca6 +GMP.v6.2.1+2.powerpc64le-linux-gnu-cxx11.tar.gz/sha512/a9550fe2b94e0e111a487159c0cd8fb6f1a21b8941ada7bb281572079dbbece921f80b0275bcc8f88117ecc72e7f8e93219350f5444b67295620db1aa9ae947d +GMP.v6.2.1+2.x86_64-apple-darwin.tar.gz/md5/b5004a436660a2533b94b41c592b686c +GMP.v6.2.1+2.x86_64-apple-darwin.tar.gz/sha512/b7b4dc8025ce304c5b899084f42c8f5aad5bbe03509bada17dbe6be952f98306729180a22b5d0a095692f349406db0b98f99f5e3f2be5f2165825e6f7f7d1813 +GMP.v6.2.1+2.x86_64-linux-gnu-cxx03.tar.gz/md5/47ba899c9ac714a4594f999d845f45cf +GMP.v6.2.1+2.x86_64-linux-gnu-cxx03.tar.gz/sha512/99624ec71865d6285ab409ef54f4cf12ba246de6233de56a2fb9f70806574891539efed32e711202003570c157918fde8d53534c695fd5b8476e0d4e0ecd1bd4 +GMP.v6.2.1+2.x86_64-linux-gnu-cxx11.tar.gz/md5/3b0c1258ecafcaf96e549f9b979420ee +GMP.v6.2.1+2.x86_64-linux-gnu-cxx11.tar.gz/sha512/b94d8f25d23597f96cc0cf0aebd1708755a8714ec4a481108add852b77addc737d3d8feba566ec410db019698ca2de826583b1a6105f0d2188679e7f72331df0 +GMP.v6.2.1+2.x86_64-linux-musl-cxx03.tar.gz/md5/061cfe5f416c1365e98d6b1ed89abd63 +GMP.v6.2.1+2.x86_64-linux-musl-cxx03.tar.gz/sha512/b6847f7ff599fa811851788a6ec6ce69ba02dbb3672d0a64b03b7056b35215536b059287709b3d207bc977094e994a7d744061b7ecf95886510285489bb89578 +GMP.v6.2.1+2.x86_64-linux-musl-cxx11.tar.gz/md5/81911acbc0c3607338c6455b1798cab8 +GMP.v6.2.1+2.x86_64-linux-musl-cxx11.tar.gz/sha512/e007441194abc5c80d9521a17e2ab9e6fb54f319571f4045fec2f7464ffaa99652d3252416c15d110dbf9deaad2c1dc94f81c638e28ce620cf543f554eb7d1e0 +GMP.v6.2.1+2.x86_64-unknown-freebsd.tar.gz/md5/ef7173194848e8d00d73ef05fc520f0e +GMP.v6.2.1+2.x86_64-unknown-freebsd.tar.gz/sha512/512c3cf8fb951fe0ef7b1715b78202d0bdf5844fe33e16c4674a19e6335440fb5352d7bde71fce83e8e373efe43281d05b160b11657a582a9d3a0201ce97a189 +GMP.v6.2.1+2.x86_64-w64-mingw32-cxx03.tar.gz/md5/882c6749f217f5a691b744ef728ad089 +GMP.v6.2.1+2.x86_64-w64-mingw32-cxx03.tar.gz/sha512/53424ad8a9dcfb8e0e738d4521b2ab1c75aaf54668a54a76b8bcab2404308e69b531dc25b3dc18bc8eaa7ebd9e2914d6624c5d371e6c0ecb9e8d24aa575e99ab +GMP.v6.2.1+2.x86_64-w64-mingw32-cxx11.tar.gz/md5/bcdd7bcbc69161744397d249a9c82e45 +GMP.v6.2.1+2.x86_64-w64-mingw32-cxx11.tar.gz/sha512/b7f8fb4f5aaf5034d4d2f60e29cc7b5e06c13d4b677af30f30831e1fc95925a575275ebffda36efcc09e29ccd78ba56475c1be3ad0627e28862057764f1ef74e +gmp-6.2.1.tar.bz2/md5/28971fc21cf028042d4897f02fd355ea +gmp-6.2.1.tar.bz2/sha512/8904334a3bcc5c896ececabc75cda9dec642e401fb5397c4992c4fabea5e962c9ce8bd44e8e4233c34e55c8010cc28db0545f5f750cbdbb5f00af538dc763be9 diff --git a/deps/gmp.mk b/deps/gmp.mk index 6de8cb9d8a19d..e8153f9f02059 100644 --- a/deps/gmp.mk +++ b/deps/gmp.mk @@ -26,6 +26,7 @@ $(SRCCACHE)/gmp-$(GMP_VER)/build-patched: $(SRCCACHE)/gmp-$(GMP_VER)/source-extr cd $(dir $@) && patch -p1 < $(SRCDIR)/patches/gmp-exception.patch cd $(dir $@) && patch -p1 < $(SRCDIR)/patches/gmp_alloc_overflow_func.patch cd $(dir $@) && patch -p1 < $(SRCDIR)/patches/gmp-apple-arm64.patch + cd $(dir $@) && patch -p1 < $(SRCDIR)/patches/gmp-CVE-2021-43618.patch echo 1 > $@ $(BUILDDIR)/gmp-$(GMP_VER)/build-configured: $(SRCCACHE)/gmp-$(GMP_VER)/source-extracted diff --git a/deps/patches/gmp-CVE-2021-43618.patch b/deps/patches/gmp-CVE-2021-43618.patch new file mode 100644 index 0000000000000..a4e420e9219da --- /dev/null +++ b/deps/patches/gmp-CVE-2021-43618.patch @@ -0,0 +1,24 @@ +# Origin: https://gmplib.org/repo/gmp-6.2/rev/561a9c25298e +# HG changeset patch +# User Marco Bodrato +# Date 1634836009 -7200 +# Node ID 561a9c25298e17bb01896801ff353546c6923dbd +# Parent e1fd9db13b475209a864577237ea4b9105b3e96e +mpz/inp_raw.c: Avoid bit size overflows + +diff -r e1fd9db13b47 -r 561a9c25298e mpz/inp_raw.c +--- a/mpz/inp_raw.c Tue Dec 22 23:49:51 2020 +0100 ++++ b/mpz/inp_raw.c Thu Oct 21 19:06:49 2021 +0200 +@@ -88,8 +88,11 @@ + + abs_csize = ABS (csize); + ++ if (UNLIKELY (abs_csize > ~(mp_bitcnt_t) 0 / 8)) ++ return 0; /* Bit size overflows */ ++ + /* round up to a multiple of limbs */ +- abs_xsize = BITS_TO_LIMBS (abs_csize*8); ++ abs_xsize = BITS_TO_LIMBS ((mp_bitcnt_t) abs_csize * 8); + + if (abs_xsize != 0) + { diff --git a/stdlib/GMP_jll/Project.toml b/stdlib/GMP_jll/Project.toml index b220e3570b75f..e216ecf10825f 100644 --- a/stdlib/GMP_jll/Project.toml +++ b/stdlib/GMP_jll/Project.toml @@ -1,6 +1,6 @@ name = "GMP_jll" uuid = "781609d7-10c4-51f6-84f2-b8444358ff6d" -version = "6.2.0+5" +version = "6.2.1+2" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" diff --git a/stdlib/GMP_jll/test/runtests.jl b/stdlib/GMP_jll/test/runtests.jl index 87b073444eda6..7c0d877945231 100644 --- a/stdlib/GMP_jll/test/runtests.jl +++ b/stdlib/GMP_jll/test/runtests.jl @@ -4,5 +4,5 @@ using Test, Libdl, GMP_jll @testset "GMP_jll" begin vn = VersionNumber(unsafe_string(unsafe_load(cglobal((:__gmp_version, libgmp), Ptr{Cchar})))) - @test vn == v"6.2.0" + @test vn == v"6.2.1" end From b7e4497efe1ac506dcefab98290789441f771e2a Mon Sep 17 00:00:00 2001 From: FX Coudert Date: Sat, 21 May 2022 20:58:12 +0200 Subject: [PATCH 16/34] Update PCRE2 to 10.40 (#45398) (cherry picked from commit 3d6731be2bf54b7b2ab7f33a28cae7c7a91c0d14) --- deps/Versions.make | 2 +- deps/checksums/pcre | 67 ++--- .../pcre2-sljit-apple-silicon-support.patch | 244 ------------------ deps/pcre.mk | 9 +- stdlib/PCRE2_jll/Project.toml | 2 +- stdlib/PCRE2_jll/test/runtests.jl | 2 +- 6 files changed, 40 insertions(+), 286 deletions(-) delete mode 100644 deps/patches/pcre2-sljit-apple-silicon-support.patch diff --git a/deps/Versions.make b/deps/Versions.make index 835f95fafc58e..11333eef8534e 100644 --- a/deps/Versions.make +++ b/deps/Versions.make @@ -91,7 +91,7 @@ P7ZIP_VER := 16.2.0 P7ZIP_JLL_NAME := p7zip # PCRE -PCRE_VER := 10.36 +PCRE_VER := 10.40 PCRE_JLL_NAME := PCRE2 # SuiteSparse diff --git a/deps/checksums/pcre b/deps/checksums/pcre index 421426e3d2389..5576c6463eacd 100644 --- a/deps/checksums/pcre +++ b/deps/checksums/pcre @@ -1,32 +1,35 @@ -PCRE2.v10.36.0+0.aarch64-apple-darwin.tar.gz/md5/34157dd76b931907009ec32aad7c6e5e -PCRE2.v10.36.0+0.aarch64-apple-darwin.tar.gz/sha512/f2c4a676fb4fad42bdcffcde4876b82d40e2e3aeb7668e3077aea4e98be022cb627110bb6c13a71db941d6135db64a455c969c0cc4b914a898dc8556a9d88e67 -PCRE2.v10.36.0+0.aarch64-linux-gnu.tar.gz/md5/4fb6705dfdd7889fc8f52616527a0956 -PCRE2.v10.36.0+0.aarch64-linux-gnu.tar.gz/sha512/7af0d79aa55c969fe434f89702e328ca04d236e78accced26d5038cd08fbf83c3b4feb7e02bb88fbf0338f94f8e13b099b454eaa3c59e5274d7b572dd2e3d687 -PCRE2.v10.36.0+0.aarch64-linux-musl.tar.gz/md5/968317b2a6fa8d71a82d5f9f1a7a7923 -PCRE2.v10.36.0+0.aarch64-linux-musl.tar.gz/sha512/ba7f89932447c1c3ca007c766c8987789f0792afba924d52b149d966010792b8182ab77d50911ec4fe6553d1794617d6c70ca74b5c3e8b8779fa69c61eb2f456 -PCRE2.v10.36.0+0.armv6l-linux-gnueabihf.tar.gz/md5/d760e518585dd9bfd9e3d3688417b8ef -PCRE2.v10.36.0+0.armv6l-linux-gnueabihf.tar.gz/sha512/d0da6bbbd01e67e5a0ec448ca7bf218d90d4fbee17fd71981221816b5d00d05722347899aa960d88ee8e609b700e7b33d5c9b802b2e5eeccd1710f5b5deda839 -PCRE2.v10.36.0+0.armv6l-linux-musleabihf.tar.gz/md5/b746d89f79fbd5ba5bda60848eac517b -PCRE2.v10.36.0+0.armv6l-linux-musleabihf.tar.gz/sha512/8d025fc4e7f58ba89b7f763ff6250738ef76eb58dbd82baf8257cb5f9fdf0a59730c7854747ab3bda754294f2e2ceb2fc769a51e0e504fdadd68da73b5fc8684 -PCRE2.v10.36.0+0.armv7l-linux-gnueabihf.tar.gz/md5/f4529eccf64a257b5df354f084807eb5 -PCRE2.v10.36.0+0.armv7l-linux-gnueabihf.tar.gz/sha512/46a4e6efa1a6ecbccecbeddeb0a66475917172350702b0c6eed077e2de1d25c266182999f9d0a48074e9124dcca812815d964fb0cce0033f117246e9d1933198 -PCRE2.v10.36.0+0.armv7l-linux-musleabihf.tar.gz/md5/896bdae6d898c2c71751341b5a10e344 -PCRE2.v10.36.0+0.armv7l-linux-musleabihf.tar.gz/sha512/c16c2291b2802037fec3ae5aec2b01ed072a712b7ef48bb2a02cdaae6715dd6dd9e6c4905134047a06ad435684856d7f400dc655ec8c42a9a5ec9a3eebc9a22a -PCRE2.v10.36.0+0.i686-linux-gnu.tar.gz/md5/c545dd71a854c328536d258d1defdf60 -PCRE2.v10.36.0+0.i686-linux-gnu.tar.gz/sha512/c9aa0d188f55ce3cd19b608832bfb5a22bed34fe23b58489e8716e3af2338728fb5bd9f281f29b203b0de00e885cc8bc35e046524d328e09b7371c353ba9fb2b -PCRE2.v10.36.0+0.i686-linux-musl.tar.gz/md5/927e70b0b164e7225019677c1ca8b1a7 -PCRE2.v10.36.0+0.i686-linux-musl.tar.gz/sha512/2d6e46a8cbe322950c905e6e845a5ad7426485e547d51ed5aae9a048a1fb284f2e7998f4dafe719cc512c22ce8ad8622b70d46e2140c4e01a85d1a053bc90190 -PCRE2.v10.36.0+0.i686-w64-mingw32.tar.gz/md5/3c5129a428239ef9bd6220ed6abc3a59 -PCRE2.v10.36.0+0.i686-w64-mingw32.tar.gz/sha512/e342d8fd180b4f663eddb93ac3893d45ab1757b4fefc4c81a42768cbf03d9ec6b27af42ffe5568b8cad42fbcce2ee3d01bb272eeecb2ebd75e236f8a22efb3fd -PCRE2.v10.36.0+0.powerpc64le-linux-gnu.tar.gz/md5/d4158e4c05a45b2a5e8fdf89de1d2d24 -PCRE2.v10.36.0+0.powerpc64le-linux-gnu.tar.gz/sha512/cd652a8acefcab959826239176585c003465e9d0220b712731ad83b0c24b24a6a6875f44a458f208872c3c50cdff205e3e178feed3984c6dbde1e1792a4a7da9 -PCRE2.v10.36.0+0.x86_64-apple-darwin.tar.gz/md5/efa1c7f36aa76f3c9278ea409e99cc4d -PCRE2.v10.36.0+0.x86_64-apple-darwin.tar.gz/sha512/5b3f37a5f99690937adc7346b0f7205b8f8743ee81acad72a8d605a896cd9e9b23a81b26a0dd18b7fac0434ab6a45fd9eed5cc12a97f48d8069d55f537228621 -PCRE2.v10.36.0+0.x86_64-linux-gnu.tar.gz/md5/41c18464e519fc53cc4d496a683b0088 -PCRE2.v10.36.0+0.x86_64-linux-gnu.tar.gz/sha512/afab98dd9cf808a094a7402e532d7adf0b7b562bf1858a3e036e3ad400fa704129c13a2c4d0b32cde6a9786b09d220b72f77e1af6ab2883bcc3ffc6fd7fa80b4 -PCRE2.v10.36.0+0.x86_64-linux-musl.tar.gz/md5/9a24b4e7dcb145c113f9b93f2fc82bef -PCRE2.v10.36.0+0.x86_64-linux-musl.tar.gz/sha512/329c86994da95725b04af4db340765ecf8620bbb255583a74932d9076b78da757e426ca79c0fe0002f9c4be4854fae861ea716c9c0c7b3d0962082c0506e90a7 -PCRE2.v10.36.0+0.x86_64-unknown-freebsd.tar.gz/md5/fb71d0f5c07f23c50dd9b9c5f26cf511 -PCRE2.v10.36.0+0.x86_64-unknown-freebsd.tar.gz/sha512/32f330d2492f9325c28d514343e6eb63e3958df769712814ef4c0975e2918d753a8898a30f49ea9ed5f9ff14fce8ec99cd5758e93c8964fb85ba1982c4c5a792 -PCRE2.v10.36.0+0.x86_64-w64-mingw32.tar.gz/md5/67991b37b9dd96541ba83999fb657ad5 -PCRE2.v10.36.0+0.x86_64-w64-mingw32.tar.gz/sha512/0978ead7b84db12fbeb9ca87b043982fc29350bf4a5342ebbf90746c6471c146b977b9c86cc5a090b013b919b2834745b18af10ace00db992bf82bc791124637 +PCRE2.v10.40.0+0.aarch64-apple-darwin.tar.gz/md5/3d6b01c094c9e1adad2c1d42a3e7c3a6 +PCRE2.v10.40.0+0.aarch64-apple-darwin.tar.gz/sha512/374f9f35ae7925a6db6249850822d90c56c11b1b49971b76f016203e85bcc14ea6ab7e017b0ad5ce56c47b0715b2a396099749656e7d7291008a2dc8cb393792 +PCRE2.v10.40.0+0.aarch64-linux-gnu.tar.gz/md5/0f4c7daae3c08e5438b0af3299cbb003 +PCRE2.v10.40.0+0.aarch64-linux-gnu.tar.gz/sha512/ee9c6275019ef09a2fd7c6a649ebe184b58dae4e65a9b38159bac596e0427819e086084ca56be0f2f2ad0eb98a50a2511999cb46d5e9d1f03d39b04ade5e270d +PCRE2.v10.40.0+0.aarch64-linux-musl.tar.gz/md5/baf858fd38471dd933312079ebaf065d +PCRE2.v10.40.0+0.aarch64-linux-musl.tar.gz/sha512/3b50f6380673d30d487a3b10e6c58b76ff47fbb5c774f59f15bcc0b92e7740e73ad04c62b86e8eab0c916d4c231449f5279eae37aa401fab1a46c6e11687e806 +PCRE2.v10.40.0+0.armv6l-linux-gnueabihf.tar.gz/md5/9c582d85fe43e205679d2ed8d1ee3df7 +PCRE2.v10.40.0+0.armv6l-linux-gnueabihf.tar.gz/sha512/fb7df17fa39ac93c7af92f4afdcdd120b171682ce172561a65fae3c6e3b1c26c5715b1264007fd12713464cbff406fb19117adaf1d50bd239f0dc53e7842ca8e +PCRE2.v10.40.0+0.armv6l-linux-musleabihf.tar.gz/md5/a9c6c90c69d3de7030bd5015092a1340 +PCRE2.v10.40.0+0.armv6l-linux-musleabihf.tar.gz/sha512/7030aaaac0d275e72f3a36fe5104d11eba9bd1909c3d7126c751c9409f619d25c7735c7d3354b48786aef1ca9f1be48a60e0bd04a04c6b098915e6c4b2935e5f +PCRE2.v10.40.0+0.armv7l-linux-gnueabihf.tar.gz/md5/cc4add9c80f47ac3fb682aca3347aca3 +PCRE2.v10.40.0+0.armv7l-linux-gnueabihf.tar.gz/sha512/4a21795524d3cf8112384d133b47e87738a8c1efa71606fb55f5fabe1cc4108b2921c2efb539506552a2b630398a6770d93c9c541d5123b7a84016aad7a112f0 +PCRE2.v10.40.0+0.armv7l-linux-musleabihf.tar.gz/md5/51c54233c6e536671f2c1af74e1773d5 +PCRE2.v10.40.0+0.armv7l-linux-musleabihf.tar.gz/sha512/3889cf1faacd16779c87ac00317fbc36e54f5a99733b838920add360196edbe388c12421380105a87041d3502e5f4bea74460dedc3d797aafde5cb0f960516d0 +PCRE2.v10.40.0+0.i686-linux-gnu.tar.gz/md5/368342965b12beed2c4c92e60f7dda8f +PCRE2.v10.40.0+0.i686-linux-gnu.tar.gz/sha512/bdb3692412d0b1d07bf302fbd129755e4a53e6b39caf135df912da79088e5db29a788680b282292919c45560a795fab60d043feece63cae2296165a9909ecb57 +PCRE2.v10.40.0+0.i686-linux-musl.tar.gz/md5/79bf801c0d86614ebf95ef83016195e6 +PCRE2.v10.40.0+0.i686-linux-musl.tar.gz/sha512/d35d15ccc8b09a33088efb4bf631cbbb3ff332521f37fdaa5fc106e576a54cb57ad1243dc3db1ab17a8195fd1476889b8d548987437a195267fae7683769da38 +PCRE2.v10.40.0+0.i686-w64-mingw32.tar.gz/md5/930cbf007549542b027a1db72bab0e58 +PCRE2.v10.40.0+0.i686-w64-mingw32.tar.gz/sha512/e9bad56ca6e1871f2bf37c8b2b03ecbc77acd3f4b04c95dd6e63a4cb38487fc3349a97ca7f575c158fde8b948c363af3f7cffc4ad89af9df09e536119a1d743b +PCRE2.v10.40.0+0.powerpc64le-linux-gnu.tar.gz/md5/cebf0e67b6ae67fa841e491bf8955ae0 +PCRE2.v10.40.0+0.powerpc64le-linux-gnu.tar.gz/sha512/e04087f3e3268d389c08068ac8ae45f017e742787f20235eb6e4d32257ae3a3e445c61dc80db5a2c73d3fea5721272ec517c8b3be428d8aca097e691a14eb659 +PCRE2.v10.40.0+0.x86_64-apple-darwin.tar.gz/md5/5ed58d794f55139baac9a1ee50da3647 +PCRE2.v10.40.0+0.x86_64-apple-darwin.tar.gz/sha512/e906c6953be8a894d4cfa1792843e85aef58cf3b87baf4bcba99d19c84bd7d67dfbde85f1ddad42cbd51d2b1fa36797ce2ad79d79b19a792ca886bf52632a919 +PCRE2.v10.40.0+0.x86_64-linux-gnu.tar.gz/md5/db3fd5e855ca47b90d9a1faf58c88279 +PCRE2.v10.40.0+0.x86_64-linux-gnu.tar.gz/sha512/9082201b6519a693cf0038cf667841a0a4e4158698e1b7455ed3e0db1a7796c7303cf105975ddf059a6dbf5865eaf99f33d4e42803364935da7fa9e9c3bcb5b5 +PCRE2.v10.40.0+0.x86_64-linux-musl.tar.gz/md5/ab3456b926864ab27d5a4ce8dd42d1e7 +PCRE2.v10.40.0+0.x86_64-linux-musl.tar.gz/sha512/4b9109d9fadde86b1d76c420cb3e8b884ccba6fa08fec4fb039c384af5f040cf52b3232fbf4921cf680f36e54683b28bdb77e3b2a8943acf974f446e99f93475 +PCRE2.v10.40.0+0.x86_64-unknown-freebsd.tar.gz/md5/ee7679ad09e13f3cf9a2089e761bd718 +PCRE2.v10.40.0+0.x86_64-unknown-freebsd.tar.gz/sha512/cce31108246bdc2947865339a7cdbb7f505baf3b1b94fa6f6d825416149d8bc888a0a55961873f041cb94bba623c27f5ecaef23dda284cc57b76b30987fb6f5b +PCRE2.v10.40.0+0.x86_64-w64-mingw32.tar.gz/md5/8178c12311e6f74bc1155d6d49dfb612 +PCRE2.v10.40.0+0.x86_64-w64-mingw32.tar.gz/sha512/9d03dd7ee07fdce9af7e6995e533c59dc274417c0e39a27ccea397291b17d6865bf9c80bbc7c9aa8e908518ba33873b39b9cbfd36bc7137cb5b7432c5684e073 +pcre2-10.40.tar.bz2/md5/a5cc4e276129c177d4fffb40601019a4 +pcre2-10.40.tar.bz2/sha512/00e7b48a6554b9127cb6fe24c5cacf72783416a9754ec88f62f73c52f46ed72c86c1869e62c91a31b2ff2cbafbbedabca44b3f1eb7670bc92f49d8401c7374e8 +>>>>>>> 3d6731be2b (Update PCRE2 to 10.40 (#45398)) diff --git a/deps/patches/pcre2-sljit-apple-silicon-support.patch b/deps/patches/pcre2-sljit-apple-silicon-support.patch deleted file mode 100644 index 3aff832ca08fd..0000000000000 --- a/deps/patches/pcre2-sljit-apple-silicon-support.patch +++ /dev/null @@ -1,244 +0,0 @@ -From e87e1ccf93768238db3d6e28d0272980dba707fa Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= -Date: Mon, 30 Nov 2020 01:35:13 -0800 -Subject: [PATCH] macos: add BigSur support to execalloc (#90) - -Apple Silicon requires that pages that will hold JIT code are -marked with MAP_JIT (even if not using the hardened runtime) -and that a call be made to a pthread function before writing -to them, so a special exception could be made to the current -thread[1]; add support for both. - -since the allocator keeps the metadata about chunk/block in the -executable pages, all functions that modify that metadata will -also need to be updated. - -note that since there is no need for an accurate pointer range -with the apple implementation, NULL is passed for the pointers. - -historically, adding MAP_JIT was only recommended when the hardened -runtime was being used as it adds several undocumented restrictions -(like not being able to use JIT pages accross fork()) so the -new codepath won't be used if running in Intel. - -Tested-by: @Keno -Fixes: #51 - -[1] https://developer.apple.com/documentation/apple_silicon/porting_just-in-time_compilers_to_apple_silicon?language=objc ---- - sljit_src/sljitExecAllocator.c | 113 ++++++++++++++++++--------------- - 1 file changed, 63 insertions(+), 50 deletions(-) - -diff --git a/sljit_src/sljitExecAllocator.c b/sljit_src/sljitExecAllocator.c -index 61a32f2..2e1c138 100644 ---- a/sljit_src/sljitExecAllocator.c -+++ b/sljit_src/sljitExecAllocator.c -@@ -79,6 +79,7 @@ - */ - - #ifdef _WIN32 -+#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) - - static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - { -@@ -91,65 +92,76 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) - VirtualFree(chunk, 0, MEM_RELEASE); - } - --#else -- --#ifdef __APPLE__ --#ifdef MAP_ANON --/* Configures TARGET_OS_OSX when appropriate */ --#include -- --#if TARGET_OS_OSX && defined(MAP_JIT) --#include --#endif /* TARGET_OS_OSX && MAP_JIT */ -- --#ifdef MAP_JIT -+#else /* POSIX */ - -+#if defined(__APPLE__) && defined(MAP_JIT) - /* - On macOS systems, returns MAP_JIT if it is defined _and_ we're running on a -- version where it's OK to have more than one JIT block. -+ version where it's OK to have more than one JIT block or where MAP_JIT is -+ required. - On non-macOS systems, returns MAP_JIT if it is defined. - */ -+#include -+#if TARGET_OS_OSX -+#if defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86 -+#ifdef MAP_ANON -+#include -+#include -+ -+#define SLJIT_MAP_JIT (get_map_jit_flag()) -+ - static SLJIT_INLINE int get_map_jit_flag() - { --#if TARGET_OS_OSX -- sljit_sw page_size = get_page_alignment() + 1; -+ sljit_sw page_size; - void *ptr; -+ struct utsname name; - static int map_jit_flag = -1; - -- /* -- The following code is thread safe because multiple initialization -- sets map_jit_flag to the same value and the code has no side-effects. -- Changing the kernel version witout system restart is (very) unlikely. -- */ -- if (map_jit_flag == -1) { -- struct utsname name; -- -+ if (map_jit_flag < 0) { - map_jit_flag = 0; - uname(&name); - -- /* Kernel version for 10.14.0 (Mojave) */ -+ /* Kernel version for 10.14.0 (Mojave) or later */ - if (atoi(name.release) >= 18) { -+ page_size = get_page_alignment() + 1; - /* Only use MAP_JIT if a hardened runtime is used */ -+ ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, -+ MAP_PRIVATE | MAP_ANON, -1, 0); - -- ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); -- -- if (ptr == MAP_FAILED) { -- map_jit_flag = MAP_JIT; -- } else { -+ if (ptr != MAP_FAILED) - munmap(ptr, page_size); -- } -+ else -+ map_jit_flag = MAP_JIT; - } - } -- - return map_jit_flag; --#else /* !TARGET_OS_OSX */ -- return MAP_JIT; --#endif /* TARGET_OS_OSX */ - } -- --#endif /* MAP_JIT */ - #endif /* MAP_ANON */ --#endif /* __APPLE__ */ -+#else /* !SLJIT_CONFIG_X86 */ -+#if !(defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM) -+#error Unsupported architecture -+#endif /* SLJIT_CONFIG_ARM */ -+#include -+ -+#define SLJIT_MAP_JIT (MAP_JIT) -+#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) \ -+ apple_update_wx_flags(enable_exec) -+ -+static SLJIT_INLINE void apple_update_wx_flags(sljit_s32 enable_exec) -+{ -+ pthread_jit_write_protect_np(enable_exec); -+} -+#endif /* SLJIT_CONFIG_X86 */ -+#else /* !TARGET_OS_OSX */ -+#define SLJIT_MAP_JIT (MAP_JIT) -+#endif /* TARGET_OS_OSX */ -+#endif /* __APPLE__ && MAP_JIT */ -+#ifndef SLJIT_UPDATE_WX_FLAGS -+#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) -+#endif /* !SLJIT_UPDATE_WX_FLAGS */ -+#ifndef SLJIT_MAP_JIT -+#define SLJIT_MAP_JIT (0) -+#endif /* !SLJIT_MAP_JIT */ - - static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - { -@@ -157,12 +169,7 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - const int prot = PROT_READ | PROT_WRITE | PROT_EXEC; - - #ifdef MAP_ANON -- -- int flags = MAP_PRIVATE | MAP_ANON; -- --#ifdef MAP_JIT -- flags |= get_map_jit_flag(); --#endif -+ int flags = MAP_PRIVATE | MAP_ANON | SLJIT_MAP_JIT; - - retval = mmap(NULL, size, prot, flags, -1, 0); - #else /* !MAP_ANON */ -@@ -173,14 +180,15 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - #endif /* MAP_ANON */ - - if (retval == MAP_FAILED) -- retval = NULL; -- else { -- if (mprotect(retval, size, prot) < 0) { -- munmap(retval, size); -- retval = NULL; -- } -+ return NULL; -+ -+ if (mprotect(retval, size, prot) < 0) { -+ munmap(retval, size); -+ return NULL; - } - -+ SLJIT_UPDATE_WX_FLAGS(retval, (uint8_t *)retval + size, 0); -+ - return retval; - } - -@@ -189,7 +197,7 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) - munmap(chunk, size); - } - --#endif -+#endif /* windows */ - - /* --------------------------------------------------------------------- */ - /* Common functions */ -@@ -261,6 +269,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) - while (free_block) { - if (free_block->size >= size) { - chunk_size = free_block->size; -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); - if (chunk_size > size + 64) { - /* We just cut a block from the end of the free block. */ - chunk_size -= size; -@@ -326,6 +335,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr) - allocated_size -= header->size; - - /* Connecting free blocks together if possible. */ -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); - - /* If header->prev_size == 0, free_block will equal to header. - In this case, free_block->header.size will be > 0. */ -@@ -358,6 +368,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr) - } - } - -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 1); - SLJIT_ALLOCATOR_UNLOCK(); - } - -@@ -367,6 +378,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void) - struct free_block* next_free_block; - - SLJIT_ALLOCATOR_LOCK(); -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); - - free_block = free_blocks; - while (free_block) { -@@ -381,5 +393,6 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void) - } - - SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks)); -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 1); - SLJIT_ALLOCATOR_UNLOCK(); - } --- -2.30.0 - diff --git a/deps/pcre.mk b/deps/pcre.mk index 6815b5ac5c1d0..4e6be47ad1858 100644 --- a/deps/pcre.mk +++ b/deps/pcre.mk @@ -6,22 +6,17 @@ PCRE_CFLAGS := -O3 PCRE_LDFLAGS := $(RPATH_ESCAPED_ORIGIN) $(SRCCACHE)/pcre2-$(PCRE_VER).tar.bz2: | $(SRCCACHE) - $(JLDOWNLOAD) $@ https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$(PCRE_VER)/pcre2-$(PCRE_VER).tar.bz2 + $(JLDOWNLOAD) $@ https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$(PCRE_VER)/pcre2-$(PCRE_VER).tar.bz2 $(SRCCACHE)/pcre2-$(PCRE_VER)/source-extracted: $(SRCCACHE)/pcre2-$(PCRE_VER).tar.bz2 $(JLCHECKSUM) $< cd $(dir $<) && $(TAR) jxf $(notdir $<) - cp $(SRCDIR)/patches/config.sub $(SRCCACHE)/pcre2-$(PCRE_VER)/config.sub echo 1 > $@ checksum-pcre2: $(SRCCACHE)/pcre2-$(PCRE_VER).tar.bz2 $(JLCHECKSUM) $< -$(SRCCACHE)/pcre2-$(PCRE_VER)/pcre2-sljit-apple-silicon-support.patch-applied: $(SRCCACHE)/pcre2-$(PCRE_VER)/source-extracted - cd $(SRCCACHE)/pcre2-$(PCRE_VER) && patch -d src/sljit -p2 -f < $(SRCDIR)/patches/pcre2-sljit-apple-silicon-support.patch - echo 1 > $@ - -$(BUILDDIR)/pcre2-$(PCRE_VER)/build-configured: $(SRCCACHE)/pcre2-$(PCRE_VER)/source-extracted $(SRCCACHE)/pcre2-$(PCRE_VER)/pcre2-sljit-apple-silicon-support.patch-applied +$(BUILDDIR)/pcre2-$(PCRE_VER)/build-configured: $(SRCCACHE)/pcre2-$(PCRE_VER)/source-extracted mkdir -p $(dir $@) cd $(dir $@) && \ $(dir $<)/configure $(CONFIGURE_COMMON) --enable-jit --includedir=$(build_includedir) CFLAGS="$(CFLAGS) $(PCRE_CFLAGS)" LDFLAGS="$(LDFLAGS) $(PCRE_LDFLAGS)" diff --git a/stdlib/PCRE2_jll/Project.toml b/stdlib/PCRE2_jll/Project.toml index 7f364d3fefd88..239f1ce1a2cbe 100644 --- a/stdlib/PCRE2_jll/Project.toml +++ b/stdlib/PCRE2_jll/Project.toml @@ -1,6 +1,6 @@ name = "PCRE2_jll" uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15" -version = "10.36.0+0" +version = "10.40.0+0" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" diff --git a/stdlib/PCRE2_jll/test/runtests.jl b/stdlib/PCRE2_jll/test/runtests.jl index b2446e7e5caab..21e7e7db7286b 100644 --- a/stdlib/PCRE2_jll/test/runtests.jl +++ b/stdlib/PCRE2_jll/test/runtests.jl @@ -6,5 +6,5 @@ using Test, Libdl, PCRE2_jll vstr = zeros(UInt8, 32) @test ccall((:pcre2_config_8, libpcre2_8), Cint, (UInt32, Ref{UInt8}), 11, vstr) > 0 vn = VersionNumber(split(unsafe_string(pointer(vstr)), " ")[1]) - @test vn == v"10.36.0" + @test vn == v"10.40.0" end From 06d71b8f0a1c1ffaf72f69832fbbf6b0ebc655c5 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 11 Mar 2022 16:59:07 -0800 Subject: [PATCH 17/34] Fix a concurrency bug in `iterate(::Dict)` (#44534) (cherry picked from commit 6be86a380b09d0f02404140cb042f1ffb06c3442) --- NEWS.md | 9 +++++++-- base/dict.jl | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 916781b397dbe..334517e2e9598 100644 --- a/NEWS.md +++ b/NEWS.md @@ -102,8 +102,13 @@ New library functions * New function `Base.rest` for taking the rest of a collection, starting from a specific iteration state, in a generic way ([#37410]). -New library features --------------------- +Library changes +--------------- + +* A known concurrency issue of `iterate` methods on `Dict` and other derived objects such + as `keys(::Dict)`, `values(::Dict)`, and `Set` is fixed. These methods of `iterate` can + now be called on a dictionary or set shared by arbitrary tasks provided that there are no + tasks mutating the dictionary or set ([#44534]). * The `redirect_*` functions now accept `devnull` to discard all output redirected to it, and as an empty input ([#36146]). diff --git a/base/dict.jl b/base/dict.jl index cc5c9efb6ada8..901c9864e37e4 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -683,7 +683,7 @@ end @propagate_inbounds _iterate(t::Dict{K,V}, i) where {K,V} = i == 0 ? nothing : (Pair{K,V}(t.keys[i],t.vals[i]), i == typemax(Int) ? 0 : i+1) @propagate_inbounds function iterate(t::Dict) - _iterate(t, skip_deleted_floor!(t)) + _iterate(t, skip_deleted(t, t.idxfloor)) end @propagate_inbounds iterate(t::Dict, i) = _iterate(t, skip_deleted(t, i)) From 4f793bb5f78367c3e563f3a839e2162ab69ff8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Mon, 4 Apr 2022 22:11:25 +0200 Subject: [PATCH 18/34] [Zlib_jll] Update to v1.2.12+3 (#44810) Note: this is the first build of the real upstream version 1.2.12 which was released a few days ago. (cherry picked from commit 81e7cfc0b7edaf8da3d892290da5fd20dc2e2a65) --- deps/checksums/zlib | 68 ++++++++++++++++---------------- deps/zlib.version | 4 +- stdlib/Zlib_jll/Project.toml | 2 +- stdlib/Zlib_jll/test/runtests.jl | 2 +- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/deps/checksums/zlib b/deps/checksums/zlib index 6036eb48bcd98..d524a3f588a18 100644 --- a/deps/checksums/zlib +++ b/deps/checksums/zlib @@ -1,34 +1,34 @@ -Zlib.v1.2.12+0.aarch64-apple-darwin.tar.gz/md5/3da8ceb0b4357ebcf6ef8d1deb0e3f1d -Zlib.v1.2.12+0.aarch64-apple-darwin.tar.gz/sha512/76042fa8afe54b01bf927f0a346dca8d80dd141601af8ce4779f5625bf0846b9fe04045d85c58fe49b0f10322c65a2a17a498c540ca3e9646d0e8c9baedd9960 -Zlib.v1.2.12+0.aarch64-linux-gnu.tar.gz/md5/c738dc8c1c12edcf34e5f6c5673c3e2e -Zlib.v1.2.12+0.aarch64-linux-gnu.tar.gz/sha512/da591897441d263f1161412131ba2fb9018929da295314a5aebd35ce945b911298c03c9d2e33ea95255113b2af19cdca8f73138bcf5bfc7dea759c86e4b24ae7 -Zlib.v1.2.12+0.aarch64-linux-musl.tar.gz/md5/d3456a508e5c95a7d09078c7064a450f -Zlib.v1.2.12+0.aarch64-linux-musl.tar.gz/sha512/f8fcb842a770389d21eb5c591b7d777e19cfea66b690ac9b379292df666483dd54fe1e1242df66ac1793fe253b1f70413d8ae81f017974f4a82b47cf87f57ab2 -Zlib.v1.2.12+0.armv6l-linux-gnueabihf.tar.gz/md5/3eb00f9e732f1e00bd4f742330e4ae84 -Zlib.v1.2.12+0.armv6l-linux-gnueabihf.tar.gz/sha512/268ad885a371309d8765cb1b88ee20f624174bd1c65e02f4547d29ff69e6370acd2385d90932da95497c78b75d9066e4ef2944e99afd440219d9c58ce4a3c5cc -Zlib.v1.2.12+0.armv6l-linux-musleabihf.tar.gz/md5/94da46b4c9ed3cebc29c29ae52c418c3 -Zlib.v1.2.12+0.armv6l-linux-musleabihf.tar.gz/sha512/0707f1043212f9d026bef511d30250f1697e65e66ee5f55c1c1ef8c37dc65f9ee4153a416f6d76922e90a3cd217bfc1e6cdeb285af02dc614e49f5800a50f27c -Zlib.v1.2.12+0.armv7l-linux-gnueabihf.tar.gz/md5/e68baf32ed7b38e7d099b8273215eec0 -Zlib.v1.2.12+0.armv7l-linux-gnueabihf.tar.gz/sha512/27b43f1cda48bb355277819195eb24e48b790473a0edd4451fea338b77df23912efc53e93acc7d1b678ffd9f1c3d35f8f79b5f4f2ce2232ba7bafbdd56d0dcec -Zlib.v1.2.12+0.armv7l-linux-musleabihf.tar.gz/md5/5fa1d6d03946b8172a1f97a7928d8647 -Zlib.v1.2.12+0.armv7l-linux-musleabihf.tar.gz/sha512/f8c8f39c7cf1edb1e81ea37861cdd8c67babde0e0eee5051aa813815a7bb0e9c3d9688fa5fd897ee58fe9e080018da74d23f7f405d161890a2644698f077a117 -Zlib.v1.2.12+0.i686-linux-gnu.tar.gz/md5/3e54c3f0e23600b65fe4d694ca2884c9 -Zlib.v1.2.12+0.i686-linux-gnu.tar.gz/sha512/f44cb6dd92ee254f6c7af3261d472ac74b443096853b2bd0d25135bff937eb306726f640edb2dd6671414e131b626f8105f6f5430b030d4e859ce2d7b277498a -Zlib.v1.2.12+0.i686-linux-musl.tar.gz/md5/0155630e60c4943d7d44ec918d7e0097 -Zlib.v1.2.12+0.i686-linux-musl.tar.gz/sha512/2ea00e33f0162cecf4f2ab9a8098976ee45c05a0c96262dce388ff1a8c079449cfbcf01427f19ab621e114eb0fd0341a00753a92b6564d64d751107c79c446ad -Zlib.v1.2.12+0.i686-w64-mingw32.tar.gz/md5/01e39978cf3e0e6c1c63f8ccbc8b2797 -Zlib.v1.2.12+0.i686-w64-mingw32.tar.gz/sha512/2c7a4528eb5884003d3a1a2814dffe242c58b07a089e37e0f31f6b950ea8ae1e6f4c792691ba4f673fab69790215cdcad11c217bf0531b55c5599991d8aedf83 -Zlib.v1.2.12+0.powerpc64le-linux-gnu.tar.gz/md5/468c1ae3575329dfcffa1c3761ca9516 -Zlib.v1.2.12+0.powerpc64le-linux-gnu.tar.gz/sha512/b21f722b21fa58fb8132772403782982b57468071f0ce4e49404eb0fa25f6fa8bc839e5b78fbe58b90b5fcf2e6122a4b05d3ef962c81be2c98934c800731c871 -Zlib.v1.2.12+0.x86_64-apple-darwin.tar.gz/md5/b41e1627c04d338bdee69708a21d2f93 -Zlib.v1.2.12+0.x86_64-apple-darwin.tar.gz/sha512/491831fc646f38a8961f820f599a468f5da19e9c60e618212fb8304d2919e5becf6f166b17ce75011f1a9dcd9aeb84b59a601990515bb14c995347f129c1565a -Zlib.v1.2.12+0.x86_64-linux-gnu.tar.gz/md5/2a253a27b151860a58ba0e910475c215 -Zlib.v1.2.12+0.x86_64-linux-gnu.tar.gz/sha512/7ba7358f0e1f71c8be2bf062ea2dec0076703605895bfe1ebd78da43ae0f0dde449b3d8d777dc5ea6d7d1b51b83e138c23851bfe5f22fc049418209c2e026b35 -Zlib.v1.2.12+0.x86_64-linux-musl.tar.gz/md5/ac8344b22355cbdc6551f0646ea63a09 -Zlib.v1.2.12+0.x86_64-linux-musl.tar.gz/sha512/da89ffbfa429786baf0e6ae2ffd1d0b06fe8c8f7836e7cbeccaa132325570539f811097c70c14c771f907b39eec5b515f9346e8ffe78003d0f92c5f0ff76886c -Zlib.v1.2.12+0.x86_64-unknown-freebsd.tar.gz/md5/34396d60e6ba6562abb4c18f520bcb57 -Zlib.v1.2.12+0.x86_64-unknown-freebsd.tar.gz/sha512/01a39f992b59b1996a4ec6a0127600b5776ea40baddf2826932f30f9424f4c1edf2d570a08b153e7d0331de46c51477d10d796151dfe3816892c3fb083cb63da -Zlib.v1.2.12+0.x86_64-w64-mingw32.tar.gz/md5/5ea885cdd8e48b43d0637b15a43df803 -Zlib.v1.2.12+0.x86_64-w64-mingw32.tar.gz/sha512/c58e407b123112a180c0fd260d0b7da5657db83a1ffa562797617e3f755dcbd2846dee602aba7aa107f98be655669c889b2f96dcfd1f50ca153a5e055905b8e4 -zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz/md5/93d10d4dd040f14ae63417070d1346e8 -zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz/sha512/a1e9c5a2963266a582192d0fe88c179f5239245f11c4df4427dda755ad77d31e1fcf045d7d3fe49141090f4ff8da13d9a2e8d8d317fe6460a5f3e9bdea29b883 +Zlib.v1.2.12+3.aarch64-apple-darwin.tar.gz/md5/2258883a6412fbdac0b807afd133834f +Zlib.v1.2.12+3.aarch64-apple-darwin.tar.gz/sha512/6e82b57646dfe2b86978d51cb4401d565d00d6bdcfabe09ceb888ad8979bd1398fd9ea7652542f149d88c120110f6c3baa919616f01410e9238a5199f50f5dda +Zlib.v1.2.12+3.aarch64-linux-gnu.tar.gz/md5/663aa0d0791b92464e4822a130ac7fa9 +Zlib.v1.2.12+3.aarch64-linux-gnu.tar.gz/sha512/e50f00d92600a78b2f540e0e8e1dce435d0d0499ea80ce3c3cd0e11c8e3b5b1a97eadca9ac863f597cee369e80bcd50ec1c0a0e0f1a87bb0ff94bbaf453dea2d +Zlib.v1.2.12+3.aarch64-linux-musl.tar.gz/md5/471179a2364d59abb6426b378ea4e195 +Zlib.v1.2.12+3.aarch64-linux-musl.tar.gz/sha512/35208e4be5966343ecb2b78471a3e1a947489f83c828b562db3508506dd0493eae3318c7eb3a6b599e911416795023193df862fbb6fcc7389d44710dc30f16a8 +Zlib.v1.2.12+3.armv6l-linux-gnueabihf.tar.gz/md5/53601c0201dadc8c9ff038167d5c4277 +Zlib.v1.2.12+3.armv6l-linux-gnueabihf.tar.gz/sha512/19744283bb412a656b934347cb7a1d121fbaf7e5f9b1aac373ddf2466567b731817a2e72e3a4d993ca7e5b5eb1fd9bb9c24d0126778367b28bdb94721649298b +Zlib.v1.2.12+3.armv6l-linux-musleabihf.tar.gz/md5/f7c923955fc600785aae455807e63c8b +Zlib.v1.2.12+3.armv6l-linux-musleabihf.tar.gz/sha512/623cd1758465c9e40b0dad93981ae93097a03f4aa67487b7e1c7240be2d780d86f35f8db96743c35bbb329d572741b58e73735a2b1cfb9e18e77f4dbcc714063 +Zlib.v1.2.12+3.armv7l-linux-gnueabihf.tar.gz/md5/5ce0fe42f67e09de047626424d61bc82 +Zlib.v1.2.12+3.armv7l-linux-gnueabihf.tar.gz/sha512/322e32d6fe6cd7a3334f5146f8980d4f1fc85b9a1c60271659ba8b4bbfdec314f8d9e8c6c0719248f5dd18e3daefd946811a3dcc74fa3ae5505d6dd653e65309 +Zlib.v1.2.12+3.armv7l-linux-musleabihf.tar.gz/md5/5115c374df90393cb895dd45c77275c4 +Zlib.v1.2.12+3.armv7l-linux-musleabihf.tar.gz/sha512/b04b4f42220833b99923a3ff349e4a05ad9f67c2b62d4848de37c833b287420b1dbec8a039c09d2a95ab6b68a62c6dcbacb4ba7cc069a4e90a11f8592719d2b8 +Zlib.v1.2.12+3.i686-linux-gnu.tar.gz/md5/37e0186f765fada0d76b9cd6f28c8d5d +Zlib.v1.2.12+3.i686-linux-gnu.tar.gz/sha512/1239675bbf46c6243131585283b0fc23baa32e68226fbb2f0b7a833c8979e2df33590947daade533e37bafe21838a10198e9f9de99e094c21fba6b218b2fceab +Zlib.v1.2.12+3.i686-linux-musl.tar.gz/md5/a0d92af6481929eed3a9fec3dbb2e622 +Zlib.v1.2.12+3.i686-linux-musl.tar.gz/sha512/b448590129ef251083b675c3d7494a90151a03297fd9883efb70bde032d106f16f2ec7c28508d9b4a0d0e5a0be0bdb4bcf0d1a9e4b2ade034a6d6cfc4916536e +Zlib.v1.2.12+3.i686-w64-mingw32.tar.gz/md5/cc38d9ec5430e2ed7fed4792c7ac9551 +Zlib.v1.2.12+3.i686-w64-mingw32.tar.gz/sha512/85ad3babb42682d7b2b69513a30fd5e992a56436dcd7e2a44800bf1bc30d60d09aff5769cfaeefd4f5668e7973a0c2d4ad4d28559ea5f28c1c5419ed595eae57 +Zlib.v1.2.12+3.powerpc64le-linux-gnu.tar.gz/md5/8f57d8c31d2355c64a05db0412462d58 +Zlib.v1.2.12+3.powerpc64le-linux-gnu.tar.gz/sha512/9a0208c7a4dbf71b6f7e1ccaf05e3f3a422507cf0431b6482aab1a7b1bea41bd135320567f7dba6666f37c26f48cb3a627f1a1ebd39bf5c2d61148aadf62a986 +Zlib.v1.2.12+3.x86_64-apple-darwin.tar.gz/md5/5d15bb591d26d24aa9d6c9c8cf3df097 +Zlib.v1.2.12+3.x86_64-apple-darwin.tar.gz/sha512/7d8b0ec5a46a85cef3c5de451823c5cfa73b5b7c5ac98699065bbc5692af556195664908cd5c35184b7a9586fc0adab41fc0f76ee8599ca09a740cf49b9be113 +Zlib.v1.2.12+3.x86_64-linux-gnu.tar.gz/md5/25df63b9e6cbef14b0f0bf2a9eec5d14 +Zlib.v1.2.12+3.x86_64-linux-gnu.tar.gz/sha512/2660b762d816491e6b877020d8dd4a1cf1b171d6232dd5e0f47c6ee7b15504b006cc8f051434df778e0910130ef7456e30d531464470d3c4a2502e8f9fd19e76 +Zlib.v1.2.12+3.x86_64-linux-musl.tar.gz/md5/3f0c85d248711608141046d15b2da339 +Zlib.v1.2.12+3.x86_64-linux-musl.tar.gz/sha512/e4256b1b9520d5b0d97fa7e7ca6f6b9aa2583c6e5f14967392d54e48f27e242461f77e522743b229ab9b333eec5fd51f6d7b1559b566bd68ca0741b05b96df3c +Zlib.v1.2.12+3.x86_64-unknown-freebsd.tar.gz/md5/e67dae1456645930c9e2b2fef6f805c8 +Zlib.v1.2.12+3.x86_64-unknown-freebsd.tar.gz/sha512/5915ec48ae80be829c36a71e2ce580d2d14b7a9824c8f279ad5c69fea62d9a03345b665f224b9dde0bc4b808af246f89ec4f932d47a14236bc3b7db7651e5bec +Zlib.v1.2.12+3.x86_64-w64-mingw32.tar.gz/md5/89b152b3de0068c7c2580b87ad529ed3 +Zlib.v1.2.12+3.x86_64-w64-mingw32.tar.gz/sha512/df4b585f6501f45bc85e8d00c1b03c482d70d3491081246f9e9f9560f90c5f6057b1174a81e653f725209323cd743cf05d3e1aba1385afd26cb6f8c50186f818 +zlib-21767c654d31d2dccdde4330529775c6c5fd5389.tar.gz/md5/1fb2320f871561306bc87b3894727b45 +zlib-21767c654d31d2dccdde4330529775c6c5fd5389.tar.gz/sha512/2ad1e728f97a81b65d24fe5bef66658c94222d717a3486a0d11682b61563d7eaaa578f7457078881e8ed8c91b87aec11634d4a64021546e23a3ecabb3285197a diff --git a/deps/zlib.version b/deps/zlib.version index e363169315051..0b16a7f662dd1 100644 --- a/deps/zlib.version +++ b/deps/zlib.version @@ -1,2 +1,2 @@ -ZLIB_BRANCH=v1.2.11 -ZLIB_SHA1=cacf7f1d4e3d44d871b605da3b647f07d718623f +ZLIB_BRANCH=v1.2.12 +ZLIB_SHA1=21767c654d31d2dccdde4330529775c6c5fd5389 diff --git a/stdlib/Zlib_jll/Project.toml b/stdlib/Zlib_jll/Project.toml index 570c1aace7c31..60a2966a562fb 100644 --- a/stdlib/Zlib_jll/Project.toml +++ b/stdlib/Zlib_jll/Project.toml @@ -1,6 +1,6 @@ name = "Zlib_jll" uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.12+0" +version = "1.2.12+3" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" diff --git a/stdlib/Zlib_jll/test/runtests.jl b/stdlib/Zlib_jll/test/runtests.jl index e6adc6b7c951f..cc9e64188a0aa 100644 --- a/stdlib/Zlib_jll/test/runtests.jl +++ b/stdlib/Zlib_jll/test/runtests.jl @@ -3,5 +3,5 @@ using Test, Zlib_jll @testset "Zlib_jll" begin - @test VersionNumber(unsafe_string(ccall((:zlibVersion, libz), Cstring, ()))) == v"1.2.11" + @test VersionNumber(unsafe_string(ccall((:zlibVersion, libz), Cstring, ()))) == v"1.2.12" end From ede6a242ba97962f3debde7648e12cee35f3907c Mon Sep 17 00:00:00 2001 From: FX Coudert Date: Sat, 21 May 2022 15:51:10 +0200 Subject: [PATCH 19/34] Zlib: update version number (#45407) (cherry picked from commit 1c10a9e9b4fbcc55eb1fcc10227f2d493bbe1c84) --- deps/Versions.make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/Versions.make b/deps/Versions.make index 11333eef8534e..728d6bede11b1 100644 --- a/deps/Versions.make +++ b/deps/Versions.make @@ -104,7 +104,7 @@ UNWIND_JLL_NAME := LibUnwind UNWIND_JLL_VER := 1.3.2+6 # zlib -ZLIB_VER := 1.2.11 +ZLIB_VER := 1.2.12 ZLIB_JLL_NAME := Zlib # Specify the version of the Mozilla CA Certificate Store to obtain. From ed7fb2ac8895133012b38b92aa4fc709ff821c10 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 29 Mar 2022 14:55:47 -0400 Subject: [PATCH 20/34] profile: fix async deadlock (#44781) Acquiring this lock in many implementations could result in deadlock, even with an existing reader. Add a TLS check for reentry before, instead of relying on the implementation specifics, to avoid any issues. (cherry picked from commit 7df454bdd678aa84365ce34780bb34e9a2730e75) --- src/debuginfo.cpp | 48 +++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp index 4f6aa1dd8d9b1..003708bed174a 100644 --- a/src/debuginfo.cpp +++ b/src/debuginfo.cpp @@ -48,21 +48,34 @@ typedef object::SymbolRef SymRef; // while holding this lock. // Certain functions in this file might be called from an unmanaged thread // and cannot have any interaction with the julia runtime -static uv_rwlock_t threadsafe; +// They also may be re-entrant, and operating while threads are paused, so we +// separately manage the re-entrant count behavior for safety across platforms +// Note that we cannot safely upgrade read->write +static uv_rwlock_t debuginfo_asyncsafe; +static pthread_key_t debuginfo_asyncsafe_held; extern "C" void jl_init_debuginfo(void) { - uv_rwlock_init(&threadsafe); + uv_rwlock_init(&debuginfo_asyncsafe); + if (pthread_key_create(&debuginfo_asyncsafe_held, NULL)) + jl_error("fatal: pthread_key_create failed"); } extern "C" void jl_lock_profile(void) { - uv_rwlock_rdlock(&threadsafe); + uintptr_t held = (uintptr_t)pthread_getspecific(debuginfo_asyncsafe_held); + if (held++ == 0) + uv_rwlock_rdlock(&debuginfo_asyncsafe); + pthread_setspecific(debuginfo_asyncsafe_held, (void*)held); } extern "C" void jl_unlock_profile(void) { - uv_rwlock_rdunlock(&threadsafe); + uintptr_t held = (uintptr_t)pthread_getspecific(debuginfo_asyncsafe_held); + assert(held); + if (--held == 0) + uv_rwlock_rdunlock(&debuginfo_asyncsafe); + pthread_setspecific(debuginfo_asyncsafe_held, (void*)held); } // some actions aren't signal (especially profiler) safe so we acquire a lock @@ -70,7 +83,8 @@ extern "C" void jl_unlock_profile(void) template static void jl_profile_atomic(T f) { - uv_rwlock_wrlock(&threadsafe); + assert(0 == (uintptr_t)pthread_getspecific(debuginfo_asyncsafe_held)); + uv_rwlock_wrlock(&debuginfo_asyncsafe); #ifndef _OS_WINDOWS_ sigset_t sset; sigset_t oset; @@ -81,7 +95,7 @@ static void jl_profile_atomic(T f) #ifndef _OS_WINDOWS_ pthread_sigmask(SIG_SETMASK, &oset, NULL); #endif - uv_rwlock_wrunlock(&threadsafe); + uv_rwlock_wrunlock(&debuginfo_asyncsafe); } @@ -197,12 +211,12 @@ class JuliaJITEventListener: public JITEventListener jl_method_instance_t *lookupLinfo(size_t pointer) JL_NOTSAFEPOINT { - uv_rwlock_rdlock(&threadsafe); + jl_lock_profile(); auto region = linfomap.lower_bound(pointer); jl_method_instance_t *linfo = NULL; if (region != linfomap.end() && pointer < region->first + region->second.first) linfo = region->second.second; - uv_rwlock_rdunlock(&threadsafe); + jl_unlock_profile(); return linfo; } @@ -525,9 +539,10 @@ static int lookup_pointer( // DWARFContext/DWARFUnit update some internal tables during these queries, so // a lock is needed. - uv_rwlock_wrlock(&threadsafe); + assert(0 == (uintptr_t)pthread_getspecific(debuginfo_asyncsafe_held)); + uv_rwlock_wrlock(&debuginfo_asyncsafe); auto inlineInfo = context->getInliningInfoForAddress(makeAddress(Section, pointer + slide), infoSpec); - uv_rwlock_wrunlock(&threadsafe); + uv_rwlock_wrunlock(&debuginfo_asyncsafe); int fromC = (*frames)[0].fromC; int n_frames = inlineInfo.getNumberOfFrames(); @@ -550,9 +565,9 @@ static int lookup_pointer( info = inlineInfo.getFrame(i); } else { - uv_rwlock_wrlock(&threadsafe); + uv_rwlock_wrlock(&debuginfo_asyncsafe); info = context->getLineInfoForAddress(makeAddress(Section, pointer + slide), infoSpec); - uv_rwlock_wrunlock(&threadsafe); + uv_rwlock_wrunlock(&debuginfo_asyncsafe); } jl_frame_t *frame = &(*frames)[i]; @@ -1208,7 +1223,8 @@ int jl_DI_for_fptr(uint64_t fptr, uint64_t *symsize, int64_t *slide, object::SectionRef *Section, llvm::DIContext **context) JL_NOTSAFEPOINT { int found = 0; - uv_rwlock_wrlock(&threadsafe); + assert(0 == (uintptr_t)pthread_getspecific(debuginfo_asyncsafe_held)); + uv_rwlock_wrlock(&debuginfo_asyncsafe); std::map &objmap = jl_jit_events->getObjectMap(); std::map::iterator fit = objmap.lower_bound(fptr); @@ -1224,7 +1240,7 @@ int jl_DI_for_fptr(uint64_t fptr, uint64_t *symsize, int64_t *slide, } found = 1; } - uv_rwlock_wrunlock(&threadsafe); + uv_rwlock_wrunlock(&debuginfo_asyncsafe); return found; } @@ -1669,13 +1685,13 @@ extern "C" uint64_t jl_getUnwindInfo(uint64_t dwAddr) { // Might be called from unmanaged thread - uv_rwlock_rdlock(&threadsafe); + jl_lock_profile(); std::map &objmap = jl_jit_events->getObjectMap(); std::map::iterator it = objmap.lower_bound(dwAddr); uint64_t ipstart = 0; // ip of the start of the section (if found) if (it != objmap.end() && dwAddr < it->first + it->second.SectionSize) { ipstart = (uint64_t)(uintptr_t)(*it).first; } - uv_rwlock_rdunlock(&threadsafe); + jl_unlock_profile(); return ipstart; } From e0ecf0e4461fde1352a6fb20f4c3fd186b2fe1b0 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 7 Jan 2022 12:21:35 -0500 Subject: [PATCH 21/34] macOS: workaround a dyld/libunwind deadlock issue since 12.1 Apple reintroduced the old bug that we previously worked around in fad04d39d592d8e0fcbfba439e8157f582bbc850 with a similar patch to this. This is needed anywhere that we may attempt to stop threads. Fixes #43578 (cherry picked from commit 2939272af2ef3fe9d8921f7ed0a6500e31a550c9) --- src/Makefile | 1 + src/jl_internal_funcs.inc | 514 ++++++++++++++++++++++++++++++++++++++ src/mach_dyld_atfork.tbd | 25 ++ src/signals-mach.c | 31 ++- src/signals-unix.c | 86 +++---- 5 files changed, 610 insertions(+), 47 deletions(-) create mode 100644 src/jl_internal_funcs.inc create mode 100644 src/mach_dyld_atfork.tbd diff --git a/src/Makefile b/src/Makefile index abc512ce005d8..71a6e1107b139 100644 --- a/src/Makefile +++ b/src/Makefile @@ -118,6 +118,7 @@ endif CLANG_LDFLAGS := $(LLVM_LDFLAGS) ifeq ($(OS), Darwin) CLANG_LDFLAGS += -Wl,-undefined,dynamic_lookup +OSLIBS += $(SRCDIR)/mach_dyld_atfork.tbd endif COMMON_LIBPATHS := -L$(build_libdir) -L$(build_shlibdir) diff --git a/src/jl_internal_funcs.inc b/src/jl_internal_funcs.inc new file mode 100644 index 0000000000000..4058ef66eea68 --- /dev/null +++ b/src/jl_internal_funcs.inc @@ -0,0 +1,514 @@ +#define jl_active_task_stack ijl_active_task_stack +#define jl_add_standard_imports ijl_add_standard_imports +#define jl_alignment ijl_alignment +#define jl_alloc_array_1d ijl_alloc_array_1d +#define jl_alloc_array_2d ijl_alloc_array_2d +#define jl_alloc_array_3d ijl_alloc_array_3d +#define jl_alloc_string ijl_alloc_string +#define jl_alloc_svec ijl_alloc_svec +#define jl_alloc_svec_uninit ijl_alloc_svec_uninit +#define jl_alloc_vec_any ijl_alloc_vec_any +#define jl_apply_array_type ijl_apply_array_type +#define jl_apply_cmpswap_type ijl_apply_cmpswap_type +#define jl_apply_generic ijl_apply_generic +#define jl_apply_tuple_type ijl_apply_tuple_type +#define jl_apply_tuple_type_v ijl_apply_tuple_type_v +#define jl_apply_type ijl_apply_type +#define jl_apply_type1 ijl_apply_type1 +#define jl_apply_type2 ijl_apply_type2 +#define jl_argument_datatype ijl_argument_datatype +#define jl_argument_method_table ijl_argument_method_table +#define jl_arraylen ijl_arraylen +#define jl_arrayref ijl_arrayref +#define jl_arrayset ijl_arrayset +#define jl_arrayunset ijl_arrayunset +#define jl_array_cconvert_cstring ijl_array_cconvert_cstring +#define jl_array_copy ijl_array_copy +#define jl_array_del_at ijl_array_del_at +#define jl_array_del_beg ijl_array_del_beg +#define jl_array_del_end ijl_array_del_end +#define jl_array_eltype ijl_array_eltype +#define jl_array_grow_at ijl_array_grow_at +#define jl_array_grow_beg ijl_array_grow_beg +#define jl_array_grow_end ijl_array_grow_end +#define jl_array_isassigned ijl_array_isassigned +#define jl_array_ptr ijl_array_ptr +#define jl_array_ptr_1d_append ijl_array_ptr_1d_append +#define jl_array_ptr_1d_push ijl_array_ptr_1d_push +#define jl_array_ptr_copy ijl_array_ptr_copy +#define jl_array_rank ijl_array_rank +#define jl_array_size ijl_array_size +#define jl_array_sizehint ijl_array_sizehint +#define jl_array_to_string ijl_array_to_string +#define jl_array_typetagdata ijl_array_typetagdata +#define jl_array_validate_dims ijl_array_validate_dims +#define jl_atexit_hook ijl_atexit_hook +#define jl_atomic_bool_cmpswap_bits ijl_atomic_bool_cmpswap_bits +#define jl_atomic_cmpswap_bits ijl_atomic_cmpswap_bits +#define jl_atomic_error ijl_atomic_error +#define jl_atomic_new_bits ijl_atomic_new_bits +#define jl_atomic_store_bits ijl_atomic_store_bits +#define jl_atomic_swap_bits ijl_atomic_swap_bits +#define jl_backtrace_from_here ijl_backtrace_from_here +#define jl_base_relative_to ijl_base_relative_to +#define jl_binding_owner ijl_binding_owner +#define jl_binding_resolved_p ijl_binding_resolved_p +#define jl_bitcast ijl_bitcast +#define jl_boundp ijl_boundp +#define jl_bounds_error ijl_bounds_error +#define jl_bounds_error_int ijl_bounds_error_int +#define jl_bounds_error_ints ijl_bounds_error_ints +#define jl_bounds_error_tuple_int ijl_bounds_error_tuple_int +#define jl_bounds_error_unboxed_int ijl_bounds_error_unboxed_int +#define jl_bounds_error_v ijl_bounds_error_v +#define jl_box_bool ijl_box_bool +#define jl_box_char ijl_box_char +#define jl_box_float32 ijl_box_float32 +#define jl_box_float64 ijl_box_float64 +#define jl_box_int16 ijl_box_int16 +#define jl_box_int32 ijl_box_int32 +#define jl_box_int64 ijl_box_int64 +#define jl_box_int8 ijl_box_int8 +#define jl_box_slotnumber ijl_box_slotnumber +#define jl_box_ssavalue ijl_box_ssavalue +#define jl_box_uint16 ijl_box_uint16 +#define jl_box_uint32 ijl_box_uint32 +#define jl_box_uint64 ijl_box_uint64 +#define jl_box_uint8 ijl_box_uint8 +#define jl_box_uint8pointer ijl_box_uint8pointer +#define jl_box_voidpointer ijl_box_voidpointer +#define jl_call ijl_call +#define jl_call0 ijl_call0 +#define jl_call1 ijl_call1 +#define jl_call2 ijl_call2 +#define jl_call3 ijl_call3 +#define jl_calloc ijl_calloc +#define jl_call_in_typeinf_world ijl_call_in_typeinf_world +#define jl_capture_interp_frame ijl_capture_interp_frame +#define jl_ceil_llvm ijl_ceil_llvm +#define jl_ceil_llvm_withtype ijl_ceil_llvm_withtype +#define jl_cglobal ijl_cglobal +#define jl_cglobal_auto ijl_cglobal_auto +#define jl_checked_assignment ijl_checked_assignment +#define jl_clear_implicit_imports ijl_clear_implicit_imports +#define jl_close_uv ijl_close_uv +#define jl_code_for_staged ijl_code_for_staged +#define jl_compile_hint ijl_compile_hint +#define jl_compress_argnames ijl_compress_argnames +#define jl_compress_ir ijl_compress_ir +#define jl_compute_fieldtypes ijl_compute_fieldtypes +#define jl_copy_ast ijl_copy_ast +#define jl_copy_code_info ijl_copy_code_info +#define jl_cpu_threads ijl_cpu_threads +#define jl_crc32c_sw ijl_crc32c_sw +#define jl_create_system_image ijl_create_system_image +#define jl_cstr_to_string ijl_cstr_to_string +#define jl_current_exception ijl_current_exception +#define jl_debug_method_invalidation ijl_debug_method_invalidation +#define jl_declare_constant ijl_declare_constant +#define jl_defines_or_exports_p ijl_defines_or_exports_p +#define jl_deprecate_binding ijl_deprecate_binding +#define jl_dlclose ijl_dlclose +#define jl_dlopen ijl_dlopen +#define jl_dlsym ijl_dlsym +#define jl_dump_host_cpu ijl_dump_host_cpu +#define jl_egal ijl_egal +#define jl_egal__bits ijl_egal__bits +#define jl_egal__special ijl_egal__special +#define jl_eh_restore_state ijl_eh_restore_state +#define jl_enqueue_task ijl_enqueue_task +#define jl_enter_handler ijl_enter_handler +#define jl_enter_threaded_region ijl_enter_threaded_region +#define jl_environ ijl_environ +#define jl_eof_error ijl_eof_error +#define jl_eqtable_get ijl_eqtable_get +#define jl_eqtable_nextind ijl_eqtable_nextind +#define jl_eqtable_pop ijl_eqtable_pop +#define jl_eqtable_put ijl_eqtable_put +#define jl_errno ijl_errno +#define jl_error ijl_error +#define jl_errorf ijl_errorf +#define jl_eval_string ijl_eval_string +#define jl_exceptionf ijl_exceptionf +#define jl_exception_clear ijl_exception_clear +#define jl_exception_occurred ijl_exception_occurred +#define jl_excstack_state ijl_excstack_state +#define jl_exit ijl_exit +#define jl_exit_on_sigint ijl_exit_on_sigint +#define jl_exit_threaded_region ijl_exit_threaded_region +#define jl_expand ijl_expand +#define jl_expand_and_resolve ijl_expand_and_resolve +#define jl_expand_stmt ijl_expand_stmt +#define jl_expand_stmt_with_loc ijl_expand_stmt_with_loc +#define jl_expand_with_loc ijl_expand_with_loc +#define jl_expand_with_loc_warn ijl_expand_with_loc_warn +#define jl_field_index ijl_field_index +#define jl_field_isdefined ijl_field_isdefined +#define jl_gc_add_finalizer ijl_gc_add_finalizer +#define jl_gc_add_finalizer_th ijl_gc_add_finalizer_th +#define jl_gc_add_ptr_finalizer ijl_gc_add_ptr_finalizer +#define jl_gc_allocobj ijl_gc_allocobj +#define jl_gc_alloc_0w ijl_gc_alloc_0w +#define jl_gc_alloc_1w ijl_gc_alloc_1w +#define jl_gc_alloc_2w ijl_gc_alloc_2w +#define jl_gc_alloc_3w ijl_gc_alloc_3w +#define jl_gc_alloc_typed ijl_gc_alloc_typed +#define jl_gc_big_alloc ijl_gc_big_alloc +#define jl_gc_collect ijl_gc_collect +#define jl_gc_conservative_gc_support_enabled ijl_gc_conservative_gc_support_enabled +#define jl_gc_counted_calloc ijl_gc_counted_calloc +#define jl_gc_counted_free_with_size ijl_gc_counted_free_with_size +#define jl_gc_counted_malloc ijl_gc_counted_malloc +#define jl_gc_counted_realloc_with_old_size ijl_gc_counted_realloc_with_old_size +#define jl_gc_diff_total_bytes ijl_gc_diff_total_bytes +#define jl_gc_enable ijl_gc_enable +#define jl_gc_enable_conservative_gc_support ijl_gc_enable_conservative_gc_support +#define jl_gc_enable_finalizers ijl_gc_enable_finalizers +#define jl_gc_external_obj_hdr_size ijl_gc_external_obj_hdr_size +#define jl_gc_find_taggedvalue_pool ijl_gc_find_taggedvalue_pool +#define jl_gc_get_total_bytes ijl_gc_get_total_bytes +#define jl_gc_internal_obj_base_ptr ijl_gc_internal_obj_base_ptr +#define jl_gc_is_enabled ijl_gc_is_enabled +#define jl_gc_live_bytes ijl_gc_live_bytes +#define jl_gc_managed_malloc ijl_gc_managed_malloc +#define jl_gc_managed_realloc ijl_gc_managed_realloc +#define jl_gc_mark_queue_obj ijl_gc_mark_queue_obj +#define jl_gc_mark_queue_objarray ijl_gc_mark_queue_objarray +#define jl_gc_max_internal_obj_size ijl_gc_max_internal_obj_size +#define jl_gc_new_weakref ijl_gc_new_weakref +#define jl_gc_new_weakref_th ijl_gc_new_weakref_th +#define jl_gc_num ijl_gc_num +#define jl_gc_pool_alloc ijl_gc_pool_alloc +#define jl_gc_queue_multiroot ijl_gc_queue_multiroot +#define jl_gc_queue_root ijl_gc_queue_root +#define jl_gc_safepoint ijl_gc_safepoint +#define jl_gc_schedule_foreign_sweepfunc ijl_gc_schedule_foreign_sweepfunc +#define jl_gc_set_cb_notify_external_alloc ijl_gc_set_cb_notify_external_alloc +#define jl_gc_set_cb_notify_external_free ijl_gc_set_cb_notify_external_free +#define jl_gc_set_cb_post_gc ijl_gc_set_cb_post_gc +#define jl_gc_set_cb_pre_gc ijl_gc_set_cb_pre_gc +#define jl_gc_set_cb_root_scanner ijl_gc_set_cb_root_scanner +#define jl_gc_set_cb_task_scanner ijl_gc_set_cb_task_scanner +#define jl_gc_sync_total_bytes ijl_gc_sync_total_bytes +#define jl_gc_total_hrtime ijl_gc_total_hrtime +#define jl_gdblookup ijl_gdblookup +#define jl_generating_output ijl_generating_output +#define jl_generic_function_def ijl_generic_function_def +#define jl_gensym ijl_gensym +#define jl_getallocationgranularity ijl_getallocationgranularity +#define jl_getnameinfo ijl_getnameinfo +#define jl_getpagesize ijl_getpagesize +#define jl_getpid ijl_getpid +#define jl_get_ARCH ijl_get_ARCH +#define jl_get_backtrace ijl_get_backtrace +#define jl_get_binding ijl_get_binding +#define jl_get_binding_for_method_def ijl_get_binding_for_method_def +#define jl_get_binding_or_error ijl_get_binding_or_error +#define jl_get_binding_wr ijl_get_binding_wr +#define jl_get_cpu_name ijl_get_cpu_name +#define jl_get_current_task ijl_get_current_task +#define jl_get_default_sysimg_path ijl_get_default_sysimg_path +#define jl_get_excstack ijl_get_excstack +#define jl_get_fenv_consts ijl_get_fenv_consts +#define jl_get_field ijl_get_field +#define jl_get_global ijl_get_global +#define jl_get_image_file ijl_get_image_file +#define jl_get_JIT ijl_get_JIT +#define jl_get_julia_bin ijl_get_julia_bin +#define jl_get_julia_bindir ijl_get_julia_bindir +#define jl_get_keyword_sorter ijl_get_keyword_sorter +#define jl_get_kwsorter ijl_get_kwsorter +#define jl_get_method_inferred ijl_get_method_inferred +#define jl_get_module_binding ijl_get_module_binding +#define jl_get_module_compile ijl_get_module_compile +#define jl_get_module_infer ijl_get_module_infer +#define jl_get_module_of_binding ijl_get_module_of_binding +#define jl_get_module_optlevel ijl_get_module_optlevel +#define jl_get_next_task ijl_get_next_task +#define jl_get_nth_field ijl_get_nth_field +#define jl_get_nth_field_checked ijl_get_nth_field_checked +#define jl_get_nth_field_noalloc ijl_get_nth_field_noalloc +#define jl_get_pgcstack ijl_get_pgcstack +#define jl_get_ptls_states ijl_get_ptls_states +#define jl_get_root_symbol ijl_get_root_symbol +#define jl_get_safe_restore ijl_get_safe_restore +#define jl_get_size ijl_get_size +#define jl_get_task_tid ijl_get_task_tid +#define jl_get_tls_world_age ijl_get_tls_world_age +#define jl_get_UNAME ijl_get_UNAME +#define jl_get_world_counter ijl_get_world_counter +#define jl_get_zero_subnormals ijl_get_zero_subnormals +#define jl_gf_invoke_lookup ijl_gf_invoke_lookup +#define jl_gf_invoke_lookup_worlds ijl_gf_invoke_lookup_worlds +#define jl_git_branch ijl_git_branch +#define jl_git_commit ijl_git_commit +#define jl_global_event_loop ijl_global_event_loop +#define jl_has_empty_intersection ijl_has_empty_intersection +#define jl_has_free_typevars ijl_has_free_typevars +#define jl_has_so_reuseport ijl_has_so_reuseport +#define jl_has_typevar ijl_has_typevar +#define jl_has_typevar_from_unionall ijl_has_typevar_from_unionall +#define jl_hrtime ijl_hrtime +#define jl_idtable_rehash ijl_idtable_rehash +#define jl_infer_thunk ijl_infer_thunk +#define jl_init ijl_init +#define jl_init_options ijl_init_options +#define jl_init_restored_modules ijl_init_restored_modules +#define jl_init_with_image ijl_init_with_image +#define jl_init_with_image__threading ijl_init_with_image__threading +#define jl_init__threading ijl_init__threading +#define jl_install_sigint_handler ijl_install_sigint_handler +#define jl_instantiate_type_in_env ijl_instantiate_type_in_env +#define jl_instantiate_unionall ijl_instantiate_unionall +#define jl_intersect_types ijl_intersect_types +#define jl_intrinsic_name ijl_intrinsic_name +#define jl_invoke ijl_invoke +#define jl_invoke_api ijl_invoke_api +#define jl_in_threaded_region ijl_in_threaded_region +#define jl_iolock_begin ijl_iolock_begin +#define jl_iolock_end ijl_iolock_end +#define jl_ios_buffer_n ijl_ios_buffer_n +#define jl_ios_fd ijl_ios_fd +#define jl_ios_get_nbyte_int ijl_ios_get_nbyte_int +#define jl_ir_flag_inferred ijl_ir_flag_inferred +#define jl_ir_flag_inlineable ijl_ir_flag_inlineable +#define jl_ir_flag_pure ijl_ir_flag_pure +#define jl_ir_nslots ijl_ir_nslots +#define jl_ir_slotflag ijl_ir_slotflag +#define jl_isa ijl_isa +#define jl_isa_compileable_sig ijl_isa_compileable_sig +#define jl_islayout_inline ijl_islayout_inline +#define jl_istopmod ijl_istopmod +#define jl_is_binding_deprecated ijl_is_binding_deprecated +#define jl_is_char_signed ijl_is_char_signed +#define jl_is_const ijl_is_const +#define jl_is_debugbuild ijl_is_debugbuild +#define jl_is_identifier ijl_is_identifier +#define jl_is_imported ijl_is_imported +#define jl_is_initialized ijl_is_initialized +#define jl_is_in_pure_context ijl_is_in_pure_context +#define jl_is_memdebug ijl_is_memdebug +#define jl_is_not_broken_subtype ijl_is_not_broken_subtype +#define jl_is_operator ijl_is_operator +#define jl_is_task_started ijl_is_task_started +#define jl_is_unary_and_binary_operator ijl_is_unary_and_binary_operator +#define jl_is_unary_operator ijl_is_unary_operator +#define jl_lazy_load_and_lookup ijl_lazy_load_and_lookup +#define jl_lisp_prompt ijl_lisp_prompt +#define jl_load ijl_load +#define jl_load_ ijl_load_ +#define jl_load_and_lookup ijl_load_and_lookup +#define jl_load_dynamic_library ijl_load_dynamic_library +#define jl_load_file_string ijl_load_file_string +#define jl_lookup_code_address ijl_lookup_code_address +#define jl_lseek ijl_lseek +#define jl_lstat ijl_lstat +#define jl_macroexpand ijl_macroexpand +#define jl_macroexpand1 ijl_macroexpand1 +#define jl_malloc ijl_malloc +#define jl_malloc_stack ijl_malloc_stack +#define jl_matching_methods ijl_matching_methods +#define jl_maxrss ijl_maxrss +#define jl_method_def ijl_method_def +#define jl_method_instance_add_backedge ijl_method_instance_add_backedge +#define jl_method_table_add_backedge ijl_method_table_add_backedge +#define jl_method_table_disable ijl_method_table_disable +#define jl_method_table_for ijl_method_table_for +#define jl_method_table_insert ijl_method_table_insert +#define jl_methtable_lookup ijl_methtable_lookup +#define jl_mi_cache_insert ijl_mi_cache_insert +#define jl_module_build_id ijl_module_build_id +#define jl_module_export ijl_module_export +#define jl_module_exports_p ijl_module_exports_p +#define jl_module_globalref ijl_module_globalref +#define jl_module_import ijl_module_import +#define jl_module_name ijl_module_name +#define jl_module_names ijl_module_names +#define jl_module_parent ijl_module_parent +#define jl_module_use ijl_module_use +#define jl_module_using ijl_module_using +#define jl_module_usings ijl_module_usings +#define jl_module_uuid ijl_module_uuid +#define jl_native_alignment ijl_native_alignment +#define jl_nb_available ijl_nb_available +#define jl_new_array ijl_new_array +#define jl_new_bits ijl_new_bits +#define jl_new_codeinst ijl_new_codeinst +#define jl_new_code_info_uninit ijl_new_code_info_uninit +#define jl_new_datatype ijl_new_datatype +#define jl_new_foreign_type ijl_new_foreign_type +#define jl_new_method_instance_uninit ijl_new_method_instance_uninit +#define jl_new_method_table ijl_new_method_table +#define jl_new_method_uninit ijl_new_method_uninit +#define jl_new_module ijl_new_module +#define jl_new_primitivetype ijl_new_primitivetype +#define jl_new_struct ijl_new_struct +#define jl_new_structt ijl_new_structt +#define jl_new_structv ijl_new_structv +#define jl_new_struct_uninit ijl_new_struct_uninit +#define jl_new_task ijl_new_task +#define jl_new_typename_in ijl_new_typename_in +#define jl_new_typevar ijl_new_typevar +#define jl_next_from_addrinfo ijl_next_from_addrinfo +#define jl_normalize_to_compilable_sig ijl_normalize_to_compilable_sig +#define jl_no_exc_handler ijl_no_exc_handler +#define jl_object_id ijl_object_id +#define jl_object_id_ ijl_object_id_ +#define jl_obvious_subtype ijl_obvious_subtype +#define jl_operator_precedence ijl_operator_precedence +#define jl_parse ijl_parse +#define jl_parse_all ijl_parse_all +#define jl_parse_input_line ijl_parse_input_line +#define jl_parse_opts ijl_parse_opts +#define jl_parse_string ijl_parse_string +#define jl_pathname_for_handle ijl_pathname_for_handle +#define jl_pchar_to_array ijl_pchar_to_array +#define jl_pchar_to_string ijl_pchar_to_string +#define jl_pointerref ijl_pointerref +#define jl_pointerset ijl_pointerset +#define jl_pop_handler ijl_pop_handler +#define jl_preload_sysimg_so ijl_preload_sysimg_so +#define jl_prepend_cwd ijl_prepend_cwd +#define jl_printf ijl_printf +#define jl_print_backtrace ijl_print_backtrace +#define jl_process_events ijl_process_events +#define jl_profile_clear_data ijl_profile_clear_data +#define jl_profile_delay_nsec ijl_profile_delay_nsec +#define jl_profile_get_data ijl_profile_get_data +#define jl_profile_init ijl_profile_init +#define jl_profile_is_running ijl_profile_is_running +#define jl_profile_len_data ijl_profile_len_data +#define jl_profile_maxlen_data ijl_profile_maxlen_data +#define jl_profile_start_timer ijl_profile_start_timer +#define jl_profile_stop_timer ijl_profile_stop_timer +#define jl_ptrarrayref ijl_ptrarrayref +#define jl_ptr_to_array ijl_ptr_to_array +#define jl_ptr_to_array_1d ijl_ptr_to_array_1d +#define jl_queue_work ijl_queue_work +#define jl_raise_debugger ijl_raise_debugger +#define jl_readuntil ijl_readuntil +#define jl_read_verify_header ijl_read_verify_header +#define jl_realloc ijl_realloc +#define jl_register_newmeth_tracer ijl_register_newmeth_tracer +#define jl_reshape_array ijl_reshape_array +#define jl_resolve_globals_in_ir ijl_resolve_globals_in_ir +#define jl_restore_excstack ijl_restore_excstack +#define jl_restore_incremental ijl_restore_incremental +#define jl_restore_incremental_from_buf ijl_restore_incremental_from_buf +#define jl_restore_system_image ijl_restore_system_image +#define jl_restore_system_image_data ijl_restore_system_image_data +#define jl_rethrow ijl_rethrow +#define jl_rethrow_other ijl_rethrow_other +#define jl_rettype_inferred ijl_rettype_inferred +#define jl_running_on_valgrind ijl_running_on_valgrind +#define jl_safe_printf ijl_safe_printf +#define jl_save_incremental ijl_save_incremental +#define jl_save_system_image ijl_save_system_image +#define jl_SC_CLK_TCK ijl_SC_CLK_TCK +#define jl_set_ARGS ijl_set_ARGS +#define jl_set_const ijl_set_const +#define jl_set_errno ijl_set_errno +#define jl_set_global ijl_set_global +#define jl_set_istopmod ijl_set_istopmod +#define jl_set_module_compile ijl_set_module_compile +#define jl_set_module_infer ijl_set_module_infer +#define jl_set_module_nospecialize ijl_set_module_nospecialize +#define jl_set_module_optlevel ijl_set_module_optlevel +#define jl_set_module_uuid ijl_set_module_uuid +#define jl_set_next_task ijl_set_next_task +#define jl_set_nth_field ijl_set_nth_field +#define jl_set_safe_restore ijl_set_safe_restore +#define jl_set_sysimg_so ijl_set_sysimg_so +#define jl_set_task_tid ijl_set_task_tid +#define jl_set_typeinf_func ijl_set_typeinf_func +#define jl_set_zero_subnormals ijl_set_zero_subnormals +#define jl_sigatomic_begin ijl_sigatomic_begin +#define jl_sigatomic_end ijl_sigatomic_end +#define jl_sig_throw ijl_sig_throw +#define jl_spawn ijl_spawn +#define jl_specializations_get_linfo ijl_specializations_get_linfo +#define jl_specializations_lookup ijl_specializations_lookup +#define jl_static_show ijl_static_show +#define jl_static_show_func_sig ijl_static_show_func_sig +#define jl_stderr_obj ijl_stderr_obj +#define jl_stderr_stream ijl_stderr_stream +#define jl_stdin_stream ijl_stdin_stream +#define jl_stdout_obj ijl_stdout_obj +#define jl_stdout_stream ijl_stdout_stream +#define jl_stored_inline ijl_stored_inline +#define jl_string_ptr ijl_string_ptr +#define jl_string_to_array ijl_string_to_array +#define jl_subtype ijl_subtype +#define jl_subtype_env ijl_subtype_env +#define jl_subtype_env_size ijl_subtype_env_size +#define jl_svec ijl_svec +#define jl_svec1 ijl_svec1 +#define jl_svec2 ijl_svec2 +#define jl_svec_copy ijl_svec_copy +#define jl_svec_fill ijl_svec_fill +#define jl_svec_isassigned ijl_svec_isassigned +#define jl_svec_ref ijl_svec_ref +#define jl_switch ijl_switch +#define jl_switchto ijl_switchto +#define jl_symbol ijl_symbol +#define jl_symbol_lookup ijl_symbol_lookup +#define jl_symbol_n ijl_symbol_n +#define jl_tagged_gensym ijl_tagged_gensym +#define jl_take_buffer ijl_take_buffer +#define jl_task_get_next ijl_task_get_next +#define jl_task_stack_buffer ijl_task_stack_buffer +#define jl_test_cpu_feature ijl_test_cpu_feature +#define jl_threadid ijl_threadid +#define jl_throw ijl_throw +#define jl_throw_out_of_memory_error ijl_throw_out_of_memory_error +#define jl_too_few_args ijl_too_few_args +#define jl_too_many_args ijl_too_many_args +#define jl_toplevel_eval ijl_toplevel_eval +#define jl_toplevel_eval_in ijl_toplevel_eval_in +#define jl_try_substrtod ijl_try_substrtod +#define jl_try_substrtof ijl_try_substrtof +#define jl_tty_set_mode ijl_tty_set_mode +#define jl_tupletype_fill ijl_tupletype_fill +#define jl_typeassert ijl_typeassert +#define jl_typeinf_begin ijl_typeinf_begin +#define jl_typeinf_end ijl_typeinf_end +#define jl_typename_str ijl_typename_str +#define jl_typeof_str ijl_typeof_str +#define jl_types_equal ijl_types_equal +#define jl_type_equality_is_identity ijl_type_equality_is_identity +#define jl_type_error ijl_type_error +#define jl_type_error_rt ijl_type_error_rt +#define jl_type_intersection ijl_type_intersection +#define jl_type_intersection_with_env ijl_type_intersection_with_env +#define jl_type_morespecific ijl_type_morespecific +#define jl_type_morespecific_no_subtype ijl_type_morespecific_no_subtype +#define jl_type_union ijl_type_union +#define jl_type_unionall ijl_type_unionall +#define jl_unbox_bool ijl_unbox_bool +#define jl_unbox_float32 ijl_unbox_float32 +#define jl_unbox_float64 ijl_unbox_float64 +#define jl_unbox_int16 ijl_unbox_int16 +#define jl_unbox_int32 ijl_unbox_int32 +#define jl_unbox_int64 ijl_unbox_int64 +#define jl_unbox_int8 ijl_unbox_int8 +#define jl_unbox_uint16 ijl_unbox_uint16 +#define jl_unbox_uint32 ijl_unbox_uint32 +#define jl_unbox_uint64 ijl_unbox_uint64 +#define jl_unbox_uint8 ijl_unbox_uint8 +#define jl_unbox_uint8pointer ijl_unbox_uint8pointer +#define jl_unbox_voidpointer ijl_unbox_voidpointer +#define jl_uncompress_argnames ijl_uncompress_argnames +#define jl_uncompress_argname_n ijl_uncompress_argname_n +#define jl_uncompress_ir ijl_uncompress_ir +#define jl_undefined_var_error ijl_undefined_var_error +#define jl_value_ptr ijl_value_ptr +#define jl_ver_is_release ijl_ver_is_release +#define jl_ver_major ijl_ver_major +#define jl_ver_minor ijl_ver_minor +#define jl_ver_patch ijl_ver_patch +#define jl_ver_string ijl_ver_string +#define jl_vexceptionf ijl_vexceptionf +#define jl_vprintf ijl_vprintf +#define jl_wakeup_thread ijl_wakeup_thread +#define jl_yield ijl_yield +#define jl_setjmp ijl_setjmp diff --git a/src/mach_dyld_atfork.tbd b/src/mach_dyld_atfork.tbd new file mode 100644 index 0000000000000..9a5d18099dbcf --- /dev/null +++ b/src/mach_dyld_atfork.tbd @@ -0,0 +1,25 @@ +--- !tapi-tbd +# copied from XCode's libSystem.tbd (current-version: 1311) +# to provide weak-linkage info for new symbols on old systems +tbd-version: 4 +targets: [ x86_64-macos, x86_64-maccatalyst, arm64-macos, arm64-maccatalyst, + arm64e-macos, arm64e-maccatalyst ] +uuids: + - target: x86_64-macos + value: AFE6C76A-B47A-35F5-91D0-4E9FC439E90D + - target: x86_64-maccatalyst + value: AFE6C76A-B47A-35F5-91D0-4E9FC439E90D + - target: arm64-macos + value: 2EA09BDB-811B-33AA-BB58-4B53AA2DB522 + - target: arm64-maccatalyst + value: 2EA09BDB-811B-33AA-BB58-4B53AA2DB522 + - target: arm64e-macos + value: 09AB3723-C26D-3762-93BA-98E9C38B89C1 + - target: arm64e-maccatalyst + value: 09AB3723-C26D-3762-93BA-98E9C38B89C1 +install-name: '/usr/lib/libSystem.B.dylib' +exports: + - targets: [ arm64-macos, arm64e-macos, x86_64-macos, x86_64-maccatalyst, + arm64-maccatalyst, arm64e-maccatalyst ] + symbols: [ __dyld_atfork_parent, __dyld_atfork_prepare ] +... diff --git a/src/signals-mach.c b/src/signals-mach.c index 0d97d3b0dce56..a46df6ef52ce7 100644 --- a/src/signals-mach.c +++ b/src/signals-mach.c @@ -31,6 +31,11 @@ extern void *_keymgr_get_and_lock_processwide_ptr(unsigned int key); extern int _keymgr_get_and_lock_processwide_ptr_2(unsigned int key, void **result); extern int _keymgr_set_lockmode_processwide_ptr(unsigned int key, unsigned int mode); +// private dyld3/dyld4 stuff +extern void _dyld_atfork_prepare(void) __attribute__((weak_import)); +extern void _dyld_atfork_parent(void) __attribute__((weak_import)); +//extern void _dyld_fork_child(void) __attribute__((weak_import)); + static void attach_exception_port(thread_port_t thread, int segv_only); // low 16 bits are the thread id, the next 8 bits are the original gc_state @@ -511,6 +516,28 @@ static kern_return_t profiler_segv_handler } #endif +static int jl_lock_profile_mach(void) +{ + jl_lock_profile(); + void *unused = NULL; + int keymgr_locked = _keymgr_get_and_lock_processwide_ptr_2(KEYMGR_GCC3_DW2_OBJ_LIST, &unused) == 0; + if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) + _dyld_atfork_prepare(); + return keymgr_locked; +} + +static void jl_unlock_profile_mach(int keymgr_locked) +{ + if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) + _dyld_atfork_parent(); + if (keymgr_locked) + _keymgr_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST); + jl_unlock_profile(); +} + +#define jl_lock_profile() int keymgr_locked = jl_lock_profile_mach() +#define jl_unlock_profile() jl_unlock_profile_mach(keymgr_locked) + void *mach_profile_listener(void *arg) { (void)arg; @@ -529,8 +556,6 @@ void *mach_profile_listener(void *arg) // sample each thread, round-robin style in reverse order // (so that thread zero gets notified last) jl_lock_profile(); - void *unused = NULL; - int keymgr_locked = _keymgr_get_and_lock_processwide_ptr_2(KEYMGR_GCC3_DW2_OBJ_LIST, &unused) == 0; for (i = jl_n_threads; i-- > 0; ) { // if there is no space left, break early if (jl_profile_is_buffer_full()) { @@ -583,8 +608,6 @@ void *mach_profile_listener(void *arg) // We're done! Resume the thread. jl_thread_resume(i, 0); } - if (keymgr_locked) - _keymgr_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST); jl_unlock_profile(); if (running) { // Reset the alarm diff --git a/src/signals-unix.c b/src/signals-unix.c index de3b5e13c98df..d08af5c7c77cc 100644 --- a/src/signals-unix.c +++ b/src/signals-unix.c @@ -669,54 +669,54 @@ static void *signal_listener(void *arg) unw_context_t *signal_context; // sample each thread, round-robin style in reverse order // (so that thread zero gets notified last) - if (critical || profile) - jl_lock_profile(); - for (int i = jl_n_threads; i-- > 0; ) { - // notify thread to stop - jl_thread_suspend_and_get_state(i, &signal_context); - - // do backtrace on thread contexts for critical signals - // this part must be signal-handler safe - if (critical) { - bt_size += rec_backtrace_ctx(bt_data + bt_size, - JL_MAX_BT_SIZE / jl_n_threads - 1, - signal_context, NULL); - bt_data[bt_size++].uintptr = 0; - } - - // do backtrace for profiler - if (profile && running) { - if (jl_profile_is_buffer_full()) { - // Buffer full: Delete the timer - jl_profile_stop_timer(); + if (critical || profile) { + jl_lock_profile(); + for (int i = jl_n_threads; i-- > 0; ) { + // notify thread to stop + jl_thread_suspend_and_get_state(i, &signal_context); + + // do backtrace on thread contexts for critical signals + // this part must be signal-handler safe + if (critical) { + bt_size += rec_backtrace_ctx(bt_data + bt_size, + JL_MAX_BT_SIZE / jl_n_threads - 1, + signal_context, NULL); + bt_data[bt_size++].uintptr = 0; } - else { - // unwinding can fail, so keep track of the current state - // and restore from the SEGV handler if anything happens. - jl_ptls_t ptls = jl_get_ptls_states(); - jl_jmp_buf *old_buf = ptls->safe_restore; - jl_jmp_buf buf; - - ptls->safe_restore = &buf; - if (jl_setjmp(buf, 0)) { - jl_safe_printf("WARNING: profiler attempt to access an invalid memory location\n"); - } else { - // Get backtrace data - bt_size_cur += rec_backtrace_ctx((jl_bt_element_t*)bt_data_prof + bt_size_cur, - bt_size_max - bt_size_cur - 1, signal_context, NULL); - } - ptls->safe_restore = old_buf; - // Mark the end of this block with 0 - bt_data_prof[bt_size_cur++].uintptr = 0; + // do backtrace for profiler + if (profile && running) { + if (jl_profile_is_buffer_full()) { + // Buffer full: Delete the timer + jl_profile_stop_timer(); + } + else { + // unwinding can fail, so keep track of the current state + // and restore from the SEGV handler if anything happens. + jl_ptls_t ptls = jl_get_ptls_states(); + jl_jmp_buf *old_buf = ptls->safe_restore; + jl_jmp_buf buf; + + ptls->safe_restore = &buf; + if (jl_setjmp(buf, 0)) { + jl_safe_printf("WARNING: profiler attempt to access an invalid memory location\n"); + } else { + // Get backtrace data + bt_size_cur += rec_backtrace_ctx((jl_bt_element_t*)bt_data_prof + bt_size_cur, + bt_size_max - bt_size_cur - 1, signal_context, NULL); + } + ptls->safe_restore = old_buf; + + // Mark the end of this block with 0 + bt_data_prof[bt_size_cur++].uintptr = 0; + } } - } - // notify thread to resume - jl_thread_resume(i, sig); - } - if (critical || profile) + // notify thread to resume + jl_thread_resume(i, sig); + } jl_unlock_profile(); + } #ifndef HAVE_MACH if (profile && running) { #if defined(HAVE_TIMER) From 5ec2d687a6ba85d0a64a69884c01f54ff10a9195 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 12 Jan 2022 00:20:32 -0500 Subject: [PATCH 22/34] macOS: extend the workaround to cover the dyld/exc_server deadlock issue, since 12.1 Later, we should probably switch to using mach_exc_server generated from `mig mach_exc.defs`. (cherry picked from commit 267b124f1f1f1558a7619a527e11a786a99f01d4) --- src/signals-mach.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/signals-mach.c b/src/signals-mach.c index a46df6ef52ce7..7fab17ba60750 100644 --- a/src/signals-mach.c +++ b/src/signals-mach.c @@ -516,27 +516,30 @@ static kern_return_t profiler_segv_handler } #endif -static int jl_lock_profile_mach(void) +// WARNING: we are unable to handle sigsegv while the dlsymlock is held +static int jl_lock_profile_mach(int dlsymlock) { jl_lock_profile(); + // workaround for old keymgr bugs void *unused = NULL; int keymgr_locked = _keymgr_get_and_lock_processwide_ptr_2(KEYMGR_GCC3_DW2_OBJ_LIST, &unused) == 0; - if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) + // workaround for new dlsym4 bugs (API and bugs introduced in macOS 12.1) + if (dlsymlock && _dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) _dyld_atfork_prepare(); return keymgr_locked; } -static void jl_unlock_profile_mach(int keymgr_locked) +static void jl_unlock_profile_mach(int dlsymlock, int keymgr_locked) { - if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) - _dyld_atfork_parent(); + if (dlsymlock && _dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) \ + _dyld_atfork_parent(); \ if (keymgr_locked) _keymgr_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST); jl_unlock_profile(); } -#define jl_lock_profile() int keymgr_locked = jl_lock_profile_mach() -#define jl_unlock_profile() jl_unlock_profile_mach(keymgr_locked) +#define jl_lock_profile() int keymgr_locked = jl_lock_profile_mach(1) +#define jl_unlock_profile() jl_unlock_profile_mach(1, keymgr_locked) void *mach_profile_listener(void *arg) { @@ -555,7 +558,7 @@ void *mach_profile_listener(void *arg) HANDLE_MACH_ERROR("mach_msg", ret); // sample each thread, round-robin style in reverse order // (so that thread zero gets notified last) - jl_lock_profile(); + int keymgr_locked = jl_lock_profile_mach(0); for (i = jl_n_threads; i-- > 0; ) { // if there is no space left, break early if (jl_profile_is_buffer_full()) { @@ -563,9 +566,13 @@ void *mach_profile_listener(void *arg) break; } + if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) + _dyld_atfork_prepare(); // briefly acquire the dlsym lock host_thread_state_t state; jl_thread_suspend_and_get_state2(i, &state); unw_context_t *uc = (unw_context_t*)&state; + if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) + _dyld_atfork_parent(); // quickly release the dlsym lock if (running) { #ifdef LIBOSXUNWIND @@ -608,7 +615,7 @@ void *mach_profile_listener(void *arg) // We're done! Resume the thread. jl_thread_resume(i, 0); } - jl_unlock_profile(); + jl_unlock_profile_mach(0, keymgr_locked); if (running) { // Reset the alarm kern_return_t ret = clock_alarm(clk, TIME_RELATIVE, timerprof, profile_port); From 1b60be51cc0ecd26f7fd729dea7e463e1aea77d8 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Wed, 23 Mar 2022 11:14:15 +0100 Subject: [PATCH 23/34] avoid using `@sync_add` on remotecalls (#44671) * avoid using `@sync_add` on remotecalls It seems like @sync_add adds the Futures to a queue (Channel) for @sync, which in turn calls wait() for all the futures synchronously. Not only that is slightly detrimental for network operations (latencies add up), but in case of Distributed the call to wait() may actually cause some compilation on remote processes, which is also wait()ed for. In result, some operations took a great amount of "serial" processing time if executed on many workers at once. For me, this closes #44645. The major change can be illustrated as follows: First add some workers: ``` using Distributed addprocs(10) ``` and then trigger something that, for example, causes package imports on the workers: ``` using SomeTinyPackage ``` In my case (importing UnicodePlots on 10 workers), this improves the loading time over 10 workers from ~11s to ~5.5s. This is a far bigger issue when worker count gets high. The time of the processing on each worker is usually around 0.3s, so triggering this problem even on a relatively small cluster (64 workers) causes a really annoying delay, and running `@everywhere` for the first time on reasonable clusters (I tested with 1024 workers, see #44645) usually takes more than 5 minutes. Which sucks. Anyway, on 64 workers this reduces the "first import" time from ~30s to ~6s, and on 1024 workers this seems to reduce the time from over 5 minutes (I didn't bother to measure that precisely now, sorry) to ~11s. Related issues: - Probably fixes #39291. - #42156 is a kinda complementary -- it removes the most painful source of slowness (the 0.3s precompilation on the workers), but the fact that the wait()ing is serial remains a problem if the network latencies are high. May help with #38931 Co-authored-by: Valentin Churavy (cherry picked from commit 62e0729dbc5f9d5d93d14dcd49457f02a0c6d3a7) --- base/task.jl | 37 +++++++++++++++++++++- stdlib/Distributed/src/Distributed.jl | 4 +-- stdlib/Distributed/src/clusterserialize.jl | 2 +- stdlib/Distributed/src/macros.jl | 4 +-- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/base/task.jl b/base/task.jl index db586d59d02ca..f9adfb9d418fe 100644 --- a/base/task.jl +++ b/base/task.jl @@ -406,6 +406,12 @@ isolating the asynchronous code from changes to the variable's value in the curr Interpolating values via `\$` is available as of Julia 1.4. """ macro async(expr) + do_async_macro(expr) +end + +# generate the code for @async, possibly wrapping the task in something before +# pushing it to the wait queue. +function do_async_macro(expr; wrap=identity) letargs = Base._lift_one_interp!(expr) thunk = esc(:(()->($expr))) @@ -414,7 +420,7 @@ macro async(expr) let $(letargs...) local task = Task($thunk) if $(Expr(:islocal, var)) - put!($var, task) + put!($var, $(wrap(:task))) end schedule(task) task @@ -422,6 +428,35 @@ macro async(expr) end end +# task wrapper that doesn't create exceptions wrapped in TaskFailedException +struct UnwrapTaskFailedException + task::Task +end + +# common code for wait&fetch for UnwrapTaskFailedException +function unwrap_task_failed(f::Function, t::UnwrapTaskFailedException) + try + f(t.task) + catch ex + if ex isa TaskFailedException + throw(ex.task.exception) + else + rethrow() + end + end +end + +# the unwrapping for above task wrapper (gets triggered in sync_end()) +wait(t::UnwrapTaskFailedException) = unwrap_task_failed(wait, t) + +# same for fetching the tasks, for convenience +fetch(t::UnwrapTaskFailedException) = unwrap_task_failed(fetch, t) + +# macro for running async code that doesn't throw wrapped exceptions +macro async_unwrap(expr) + do_async_macro(expr, wrap=task->:(Base.UnwrapTaskFailedException($task))) +end + # Capture interpolated variables in $() and move them to let-block function _lift_one_interp!(e) letargs = Any[] # store the new gensymed arguments diff --git a/stdlib/Distributed/src/Distributed.jl b/stdlib/Distributed/src/Distributed.jl index 50108f05eed26..4c7427e265afa 100644 --- a/stdlib/Distributed/src/Distributed.jl +++ b/stdlib/Distributed/src/Distributed.jl @@ -10,7 +10,7 @@ import Base: getindex, wait, put!, take!, fetch, isready, push!, length, hash, ==, kill, close, isopen, showerror # imports for use -using Base: Process, Semaphore, JLOptions, buffer_writes, @sync_add, +using Base: Process, Semaphore, JLOptions, buffer_writes, @async_unwrap, VERSION_STRING, binding_module, atexit, julia_exename, julia_cmd, AsyncGenerator, acquire, release, invokelatest, shell_escape_posixly, shell_escape_wincmd, escape_microsoft_c_args, @@ -75,7 +75,7 @@ function _require_callback(mod::Base.PkgId) # broadcast top-level (e.g. from Main) import/using from node 1 (only) @sync for p in procs() p == 1 && continue - @sync_add remotecall(p) do + @async_unwrap remotecall_wait(p) do Base.require(mod) nothing end diff --git a/stdlib/Distributed/src/clusterserialize.jl b/stdlib/Distributed/src/clusterserialize.jl index e37987c5bf875..28025ae867c78 100644 --- a/stdlib/Distributed/src/clusterserialize.jl +++ b/stdlib/Distributed/src/clusterserialize.jl @@ -243,7 +243,7 @@ An exception is raised if a global constant is requested to be cleared. """ function clear!(syms, pids=workers(); mod=Main) @sync for p in pids - @sync_add remotecall(clear_impl!, p, syms, mod) + @async_unwrap remotecall_wait(clear_impl!, p, syms, mod) end end clear!(sym::Symbol, pid::Int; mod=Main) = clear!([sym], [pid]; mod=mod) diff --git a/stdlib/Distributed/src/macros.jl b/stdlib/Distributed/src/macros.jl index b53890017d4de..f14aa7f42e3c1 100644 --- a/stdlib/Distributed/src/macros.jl +++ b/stdlib/Distributed/src/macros.jl @@ -226,10 +226,10 @@ function remotecall_eval(m::Module, procs, ex) if pid == myid() run_locally += 1 else - @sync_add remotecall(Core.eval, pid, m, ex) + @async_unwrap remotecall_wait(Core.eval, pid, m, ex) end end - yield() # ensure that the remotecall_fetch have had a chance to start + yield() # ensure that the remotecalls have had a chance to start # execute locally last as we do not want local execution to block serialization # of the request to remote nodes. From 240d427a5a3534209fd593c6ffc0728a974a5849 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Sat, 16 Oct 2021 09:17:36 -0700 Subject: [PATCH 24/34] Fix USE_BINARYBUILDER_OPENBLAS=0 on macOS (#42538) * Fix USE_BINARYBUILDER_OPENBLAS=0 on macOS We didn't properly move the OpenBLAS -> Objconv dependency chain over to manifest files. This was not visible until now because we rarely build OpenBLAS from source without also building Objconv from source. Fixes https://github.com/JuliaLang/julia/issues/42519 * Also update path to `objconv` binary (cherry picked from commit 6af7584899bb096d510b5d715118207e44f93490) --- deps/blas.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/blas.mk b/deps/blas.mk index c9c745993f51c..2e7b36fe59385 100644 --- a/deps/blas.mk +++ b/deps/blas.mk @@ -42,8 +42,8 @@ endif ifeq ($(USE_BLAS64), 1) OPENBLAS_BUILD_OPTS += INTERFACE64=1 SYMBOLSUFFIX="$(OPENBLAS_SYMBOLSUFFIX)" LIBPREFIX="libopenblas$(OPENBLAS_LIBNAMESUFFIX)" ifeq ($(OS), Darwin) -OPENBLAS_BUILD_OPTS += OBJCONV=$(abspath $(BUILDDIR)/objconv/objconv) -$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-compiled: | $(BUILDDIR)/objconv/build-compiled +OPENBLAS_BUILD_OPTS += OBJCONV=$(abspath $(build_bindir)/objconv) +$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-compiled: | $(build_prefix)/manifest/objconv endif endif From 12719ea773cfeaf0d408f2cae030c977ead8a261 Mon Sep 17 00:00:00 2001 From: FX Coudert Date: Sat, 21 May 2022 17:27:39 +0200 Subject: [PATCH 25/34] OpenBLAS: Find objconv in its proper path (#45391) (cherry picked from commit 434d340afc7e4cc4d18b09c3858a6c6bc47ba85b) --- deps/blas.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/blas.mk b/deps/blas.mk index 2e7b36fe59385..10541ca6791e3 100644 --- a/deps/blas.mk +++ b/deps/blas.mk @@ -42,7 +42,7 @@ endif ifeq ($(USE_BLAS64), 1) OPENBLAS_BUILD_OPTS += INTERFACE64=1 SYMBOLSUFFIX="$(OPENBLAS_SYMBOLSUFFIX)" LIBPREFIX="libopenblas$(OPENBLAS_LIBNAMESUFFIX)" ifeq ($(OS), Darwin) -OPENBLAS_BUILD_OPTS += OBJCONV=$(abspath $(build_bindir)/objconv) +OPENBLAS_BUILD_OPTS += OBJCONV=$(abspath $(build_depsbindir)/objconv) $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-compiled: | $(build_prefix)/manifest/objconv endif endif From dd6f86ac79779091974ef1fe4db33d0b62f93916 Mon Sep 17 00:00:00 2001 From: Jerry Ling Date: Tue, 29 Mar 2022 10:01:32 -0400 Subject: [PATCH 26/34] fix `===` when encountering null pointer (#44749) (cherry picked from commit 1a7355b3866fecfebdcb1923cfd691b48fe5a762) --- src/builtins.c | 21 +++++++++++++-------- test/core.jl | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/builtins.c b/src/builtins.c index 913d6d70dba4b..54d3989878bbd 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -96,20 +96,25 @@ static int NOINLINE compare_fields(jl_value_t *a, jl_value_t *b, jl_datatype_t * else { jl_datatype_t *ft = (jl_datatype_t*)jl_field_type_concrete(dt, f); if (jl_is_uniontype(ft)) { - uint8_t asel = ((uint8_t*)ao)[jl_field_size(dt, f) - 1]; - uint8_t bsel = ((uint8_t*)bo)[jl_field_size(dt, f) - 1]; + size_t idx = jl_field_size(dt, f) - 1; + uint8_t asel = ((uint8_t*)ao)[idx]; + uint8_t bsel = ((uint8_t*)bo)[idx]; if (asel != bsel) return 0; ft = (jl_datatype_t*)jl_nth_union_component((jl_value_t*)ft, asel); } else if (ft->layout->first_ptr >= 0) { - // If the field is a inline immutable that can be can be undef - // we need to check to check for undef first since undef struct + // If the field is a inline immutable that can be undef + // we need to check for undef first since undef struct // may have fields that are different but should still be treated as equal. - jl_value_t *ptra = ((jl_value_t**)ao)[ft->layout->first_ptr]; - jl_value_t *ptrb = ((jl_value_t**)bo)[ft->layout->first_ptr]; - if (ptra == NULL && ptrb == NULL) { - return 1; + int32_t idx = ft->layout->first_ptr; + jl_value_t *ptra = ((jl_value_t**)ao)[idx]; + jl_value_t *ptrb = ((jl_value_t**)bo)[idx]; + if ((ptra == NULL) != (ptrb == NULL)) { + return 0; + } + else if (ptra == NULL) { // implies ptrb == NULL + continue; // skip this field (it is #undef) } } if (!ft->layout->haspadding) { diff --git a/test/core.jl b/test/core.jl index 4d5590d7642dc..bc5eb37b7aab9 100644 --- a/test/core.jl +++ b/test/core.jl @@ -9,6 +9,21 @@ const Bottom = Union{} # For curmod_* include("testenv.jl") +# test `===` handling null pointer in struct #44712 +struct N44712 + a::Some{Any} + b::Int + N44712() = new() +end +let a = Int[0, 1], b = Int[0, 2] + GC.@preserve a b begin + @test unsafe_load(Ptr{N44712}(pointer(a))) !== unsafe_load(Ptr{N44712}(pointer(b))) + end +end + +# another possible issue in #44712 +@test (("", 0),) !== (("", 1),) + f47(x::Vector{Vector{T}}) where {T} = 0 @test_throws MethodError f47(Vector{Vector}()) @test f47(Vector{Vector{Int}}()) == 0 From 8411f793760797d1b2b9da47f3a02f95bf3b5e98 Mon Sep 17 00:00:00 2001 From: FX Coudert Date: Tue, 24 May 2022 10:24:30 -0600 Subject: [PATCH 27/34] Update p7zip to 17.04 (#45435) Co-authored-by: KristofferC (cherry picked from commit 86f5501f248bb30304fc19a9abc8affee98e42f8) --- deps/Versions.make | 2 +- deps/checksums/p7zip | 68 ++-- deps/p7zip.mk | 34 +- deps/patches/p7zip-12-CVE-2016-9296.patch | 23 -- deps/patches/p7zip-13-CVE-2017-17969.patch | 35 -- ...7zip-15-Enhanced-encryption-strength.patch | 298 ------------------ deps/patches/p7zip-Windows_ErrorMsg.patch | 33 -- stdlib/p7zip_jll/Project.toml | 2 +- 8 files changed, 45 insertions(+), 450 deletions(-) delete mode 100644 deps/patches/p7zip-12-CVE-2016-9296.patch delete mode 100644 deps/patches/p7zip-13-CVE-2017-17969.patch delete mode 100644 deps/patches/p7zip-15-Enhanced-encryption-strength.patch delete mode 100644 deps/patches/p7zip-Windows_ErrorMsg.patch diff --git a/deps/Versions.make b/deps/Versions.make index 728d6bede11b1..a44bd004a0c4a 100644 --- a/deps/Versions.make +++ b/deps/Versions.make @@ -87,7 +87,7 @@ OSXUNWIND_JLL_VER := 0.0.6+1 PATCHELF_VER := 0.9 # p7zip -P7ZIP_VER := 16.2.0 +P7ZIP_VER := 17.04 P7ZIP_JLL_NAME := p7zip # PCRE diff --git a/deps/checksums/p7zip b/deps/checksums/p7zip index 8a997306349a3..b3c24a811a043 100644 --- a/deps/checksums/p7zip +++ b/deps/checksums/p7zip @@ -1,34 +1,34 @@ -p7zip-16.2.0.tar.bz2/md5/a0128d661cfe7cc8c121e73519c54fbf -p7zip-16.2.0.tar.bz2/sha512/d2c4d53817f96bb4c7683f42045198d4cd509cfc9c3e2cb85c8d9dc4ab6dfa7496449edeac4e300ecf986a9cbbc90bd8f8feef8156895d94617c04e507add55f -p7zip.v16.2.1+0.aarch64-apple-darwin.tar.gz/md5/0c91d306e3223f8f1eb56265da639a19 -p7zip.v16.2.1+0.aarch64-apple-darwin.tar.gz/sha512/7e2a9e1f6605336a2be550216c0649626f865d604dd769792bf887210f07dd691c0159e2dfedd333d41217a33504f74e78f42bae651c487ae09f696e4611bd50 -p7zip.v16.2.1+0.aarch64-linux-gnu.tar.gz/md5/e9c41ff134653bfcb296f6e8e1be72da -p7zip.v16.2.1+0.aarch64-linux-gnu.tar.gz/sha512/e90ebb352b1eb249bba26bfc3f621a9d6a65f1ba8b4d68bf3ff28a02573fbe37438b0c94c52a9c1cbcb6297e418d71a53c87067d7becf175af5fec8db020d3f7 -p7zip.v16.2.1+0.aarch64-linux-musl.tar.gz/md5/faa7fea160322ab3a9480f22277e7e42 -p7zip.v16.2.1+0.aarch64-linux-musl.tar.gz/sha512/617a7a5796e7cdcc7040073f5f27232ef32160591d5160aa8fc59d36cf51eb873884e7b417994b1626874ca3eed6af2e5e9dfd551724c1431489f233edeb8901 -p7zip.v16.2.1+0.armv6l-linux-gnueabihf.tar.gz/md5/c13fe2468bd4f14892a187bf1781d34a -p7zip.v16.2.1+0.armv6l-linux-gnueabihf.tar.gz/sha512/1d8c6b2f0efa10f104ed4a141a1719d596e341db6b646c01e5c5472bff637eb3bfe6c5742fa101bf344875cc3c7fbc2733eaca5bd69e14e771982173c0311cff -p7zip.v16.2.1+0.armv6l-linux-musleabihf.tar.gz/md5/e108a692f7003e260cfdbde2b480a3cf -p7zip.v16.2.1+0.armv6l-linux-musleabihf.tar.gz/sha512/2bdc37302c6a97f77fe154d68d18c29e842e3c31ea8eb858089c9e9ca391939e25a9ac309780c4d290853e7bb34307cbe50ba0868fafa455cb9a40b004d6bd2c -p7zip.v16.2.1+0.armv7l-linux-gnueabihf.tar.gz/md5/1f518b75b8eaaa07dbb7eb66b4d23e87 -p7zip.v16.2.1+0.armv7l-linux-gnueabihf.tar.gz/sha512/7478d036adaba001a844159050c7e34a27a1d8f2a15cb8143505100f24818431a5c47eacb721eb98c720b2b29c395095118cf15f04e8c914e111e16a529bcd1e -p7zip.v16.2.1+0.armv7l-linux-musleabihf.tar.gz/md5/1c075c36df1df55d899cc0e4dafe43c4 -p7zip.v16.2.1+0.armv7l-linux-musleabihf.tar.gz/sha512/0a2237cfb42ab5dbc144a9542693356321501b23dddc9f585aef3d544e6a6559cf4c2279400d8fc03d5f0c7093550709c544d11c82f3ded9b3bf3647f09592b9 -p7zip.v16.2.1+0.i686-linux-gnu.tar.gz/md5/31f0d322e45bed3782abff84e0713ee6 -p7zip.v16.2.1+0.i686-linux-gnu.tar.gz/sha512/e68a1130a4b4799907f7def729aecdac0bac038112d0579bf9d0accb21ef12c745bd3ca2470c7e6b26bc9008be99b5d35e472d2fc44f5b7bdf96fcf3c867b399 -p7zip.v16.2.1+0.i686-linux-musl.tar.gz/md5/2a9a26c0c87ff8b862d27d6589754dc7 -p7zip.v16.2.1+0.i686-linux-musl.tar.gz/sha512/91a48dd5e42b064f79d5be5cc2b2e57c7c8104cc8f889fb3440e235ff022152150b04f05eff91fa949bd071d2788cc44bbe37117c425e2d45d4194d6ee26a398 -p7zip.v16.2.1+0.i686-w64-mingw32.tar.gz/md5/b38c4c41127007c30e5ff545416601ae -p7zip.v16.2.1+0.i686-w64-mingw32.tar.gz/sha512/6525300d454023fbff9981620a9a77c343dd30982c3685c786c8e952bba13389f29de1c1790ad81914c48de70cd15ac4fdc2c7aca2dc6d9f36303cf0d520139f -p7zip.v16.2.1+0.powerpc64le-linux-gnu.tar.gz/md5/a2c5ee0149930648011db1739df40229 -p7zip.v16.2.1+0.powerpc64le-linux-gnu.tar.gz/sha512/a7f24669abfde913ef94d5fd04d0d34b155dd099939c522601ba48ec73ce27953f497c5d279aa7ef9d1bde94216e514d3bbc7e81803da0f6438b18631d0485e1 -p7zip.v16.2.1+0.x86_64-apple-darwin.tar.gz/md5/eea35b8d9ccb08a5d894d52afff274e0 -p7zip.v16.2.1+0.x86_64-apple-darwin.tar.gz/sha512/c15aa482ea1de5065266f9810ca27e9d3860c3ea5e847f4532c74c90fb5ba9820704acad41fd759ef030b08143404310e3973993da2d12413027cd9070d4a2a8 -p7zip.v16.2.1+0.x86_64-linux-gnu.tar.gz/md5/baf766508e5a5f832ffcad60ec23d56e -p7zip.v16.2.1+0.x86_64-linux-gnu.tar.gz/sha512/e7fe2b1ee150be1d7a23d960030364468a95c3186fe26b3fb10da4dc9a964a99b5f7dc7eeb47e8df0533bd86a61a072ddb3b6b4d0761e38fe3ca9e81f28752b2 -p7zip.v16.2.1+0.x86_64-linux-musl.tar.gz/md5/b333059a4129829cdd8b4aba47a47459 -p7zip.v16.2.1+0.x86_64-linux-musl.tar.gz/sha512/97648c0c1c7ed316271b6c15c1a3cc94bad51f5c294b49e93780ae46b3eb2ad6398c427beed973d2ca1c6da2142c8f858ba1ce0cc94d0710853cc92d5c5e5b4d -p7zip.v16.2.1+0.x86_64-unknown-freebsd.tar.gz/md5/343d1a7d0fd583cf1ba2b6cc2e8ac700 -p7zip.v16.2.1+0.x86_64-unknown-freebsd.tar.gz/sha512/6e35174e1f3c07599cecf028089325a84b7c0c43f626ab0b32fb734d7408e3954c0ee48cc566e27399b234b28b0a62693554316dc58a8d1c89e99422e9c31d16 -p7zip.v16.2.1+0.x86_64-w64-mingw32.tar.gz/md5/bcb1901fc5fd6ceb7e842cb5a5592e2f -p7zip.v16.2.1+0.x86_64-w64-mingw32.tar.gz/sha512/deb783b6e83a02485ad0eec513de6c8bafc99282938c5771e58ec683db711bb78454d9ef531a3ba6dd1042baf64e22e1de8e82eed3708f160fab986f97e5736d +p7zip.v17.4.0+0.aarch64-apple-darwin.tar.gz/md5/af8134ed9c24b99d69e4edb4d5226ca5 +p7zip.v17.4.0+0.aarch64-apple-darwin.tar.gz/sha512/b8bb6aee60a54cca37568af8b2d9baedd892ba0d4918b93bcb29d74189524af7115901f4fabafb1ca58ed17e97c59846fcdfbd460abc81059806802b0a7be840 +p7zip.v17.4.0+0.aarch64-linux-gnu.tar.gz/md5/20abac5ebb99f31742878013c02f96a3 +p7zip.v17.4.0+0.aarch64-linux-gnu.tar.gz/sha512/6d8ebf895b969b1f707d0c23a19db4cd0dee47957d076e6e389395e09404d55bfcb78bb14bb67bb35b93b6a0072f2b4f097d839503d1ccab62b4ce28939dc71d +p7zip.v17.4.0+0.aarch64-linux-musl.tar.gz/md5/185c979c7419b7ded3832c0f5cfd3b77 +p7zip.v17.4.0+0.aarch64-linux-musl.tar.gz/sha512/722e880c9f111738cb4cde84bf62c36892dbefdba625ae2b9e0fae76a7b1eabfa481a9838fbf9667223f19f62b6f09fcfd42b50c2bff7a65af0fae3616250fc7 +p7zip.v17.4.0+0.armv6l-linux-gnueabihf.tar.gz/md5/dceb37181763f86bf12f8ca473cf3403 +p7zip.v17.4.0+0.armv6l-linux-gnueabihf.tar.gz/sha512/51e409bbcd3c54838cb3219b2476c8b45c8340e0a2fd26cced0d8484ae7f51711723e06e9023fce9ae9a1b51b5fb94aba536428ce2a5c5902b38498a0b3c2b50 +p7zip.v17.4.0+0.armv6l-linux-musleabihf.tar.gz/md5/193ecd888787ea03a500d102a7e33afa +p7zip.v17.4.0+0.armv6l-linux-musleabihf.tar.gz/sha512/d525aad33f5ed27dc993f31c6db2996b830716bfac9bc7c49cb462ea3f0b412d0d3267765b9952c85e9c9be31d36d095d55ba89c0fa2c92823d9490372389c95 +p7zip.v17.4.0+0.armv7l-linux-gnueabihf.tar.gz/md5/096f11a7f1af5ff730bb8cfef22e335e +p7zip.v17.4.0+0.armv7l-linux-gnueabihf.tar.gz/sha512/1866ffd0169e0795594aaa70f1af8102ebbd79b3cafaadfb9c6a537dac0cdbb6eb7c31ad5165a975508c1b850744f94b60d9c530d658cdcc5536a474203cff21 +p7zip.v17.4.0+0.armv7l-linux-musleabihf.tar.gz/md5/fef1576982f45d1922582f6f7a7d6665 +p7zip.v17.4.0+0.armv7l-linux-musleabihf.tar.gz/sha512/71061585b32fa1a8e0a403a60c07e9f90586291a9799d7e2d6f7e6ec9f7b0ebf4b45ed080efd87cad82c45f71ec9a14cbcf9134a73bad4f5e3329f23bc6df01a +p7zip.v17.4.0+0.i686-linux-gnu.tar.gz/md5/8818389b3bf00f10c6a39fe0c4a331b4 +p7zip.v17.4.0+0.i686-linux-gnu.tar.gz/sha512/bec2051a258f7e8a762b7cd4324e7b8f00fe5d99d48f05fb3557c41604e8b08af9ab66ab830f4a48086656be41aaf011b2aae0fb530e0ffefec38689f85a3bb5 +p7zip.v17.4.0+0.i686-linux-musl.tar.gz/md5/4ed9c16a65ed1d656aa214013e46eb28 +p7zip.v17.4.0+0.i686-linux-musl.tar.gz/sha512/7a5b3e15d0038bea0de7fc28ce058d7f93b8e04f271e30953a6b52d2b5d71f59d10177033e888a50cf8dfeb4f44bcf3271c9b9d1b28d0122ab2b239decdad446 +p7zip.v17.4.0+0.i686-w64-mingw32.tar.gz/md5/d06cff2ec0b7c8415700587f931ce1ac +p7zip.v17.4.0+0.i686-w64-mingw32.tar.gz/sha512/ed72440f5306a57465a70b00bff33185a83c3e223844a79aa0b0d1fbe30dbd35da75e6188725aa621f5c4574a09527daf1e4893c7c6979ab91b2c09b4979dbcb +p7zip.v17.4.0+0.powerpc64le-linux-gnu.tar.gz/md5/949ca7d111e497b82c9c762e5ac63a6b +p7zip.v17.4.0+0.powerpc64le-linux-gnu.tar.gz/sha512/4842e0d44bf6380100723209596f526181fefe8a81d59c28658d03ea16600e71d010d5c7898b4c943efdd9caaa2301c3fdb0dccb343d631d1734acda1c559f65 +p7zip.v17.4.0+0.x86_64-apple-darwin.tar.gz/md5/2322c7a08f62592ca394a716949008bc +p7zip.v17.4.0+0.x86_64-apple-darwin.tar.gz/sha512/9549f3e1052730ce13414636b32f0d1a9a1ac944a2b622380eac0da144b11fd65d437afe877ba6797d651da9c4ec77f0ebd3e515146caceaa2524829419eda48 +p7zip.v17.4.0+0.x86_64-linux-gnu.tar.gz/md5/a21b12946a62ef3688d5fc965974e8f7 +p7zip.v17.4.0+0.x86_64-linux-gnu.tar.gz/sha512/d32faeac23acf8a023f65350ba1d62bb3d9f904e32570ae03b8fb0a5375758784dd95be8caeecd007cbde40e103854a077e2c817f62afa72491f3b8966deb738 +p7zip.v17.4.0+0.x86_64-linux-musl.tar.gz/md5/c448e872d4ad66beb2d46d9134952f2f +p7zip.v17.4.0+0.x86_64-linux-musl.tar.gz/sha512/92588f4817e145ef655c718dec049e7f43dd93644f43f19cd320643fac5f5b2312837c7a6c3e782e97fd08747311c58ed4657484f8bc778942fc5206ff8ea4e5 +p7zip.v17.4.0+0.x86_64-unknown-freebsd.tar.gz/md5/2cca6259a2eb1b0fea777d566267bf05 +p7zip.v17.4.0+0.x86_64-unknown-freebsd.tar.gz/sha512/92f90e2be4a8b8fcd80a4ceacac8bbab750913526b85f9279f8ee9ed91b77248b5de2d35d0c6241d0ad51fda185f4cb1ead1dcc9d23e2bef35e0b61efe3c3170 +p7zip.v17.4.0+0.x86_64-w64-mingw32.tar.gz/md5/5d272c78d7ffb40da0f333463f3cc098 +p7zip.v17.4.0+0.x86_64-w64-mingw32.tar.gz/sha512/2d999c6df4786cec1bba396b3a651a63740f4b799e9fc11754afd24438076e898daae74b4d3c7072450428e89881991e8884711cd4c349879a00c7aeeb4e1d3e +p7zip-17.04.tar.gz/md5/00acfd6be87848231722d2d53f89e4a5 +p7zip-17.04.tar.gz/sha512/ad176db5b657b1c39584f6792c47978d94f2f1ccb1cf5bdb0f52ab31a7356b3822f4a922152c4253f4aa7e79166ba052b6592530b7a38f548cd555fe9c008be3 diff --git a/deps/p7zip.mk b/deps/p7zip.mk index 20c85602f767a..8c0d11d74a061 100644 --- a/deps/p7zip.mk +++ b/deps/p7zip.mk @@ -1,36 +1,20 @@ ## p7zip ## ifneq ($(USE_BINARYBUILDER_P7ZIP),1) -# Force optimization for P7ZIP flags (Issue #11668) -$(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2: | $(SRCCACHE) - $(JLDOWNLOAD) $@ https://downloads.sourceforge.net/project/p7zip/p7zip/16.02/p7zip_16.02_src_all.tar.bz2 -$(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2 +$(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz: | $(SRCCACHE) + $(JLDOWNLOAD) $@ https://github.com/jinfeihan57/p7zip/archive/refs/tags/v$(P7ZIP_VER).tar.gz + +$(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz $(JLCHECKSUM) $< mkdir -p $(dir $@) - cd $(dir $@) && $(TAR) --strip-components 1 -jxf $< + cd $(dir $@) && $(TAR) --strip-components 1 -zxf $< echo 1 > $@ -checksum-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2 +checksum-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz $(JLCHECKSUM) $< -$(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-12-CVE-2016-9296.patch-applied: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted - cd $(dir $@) && patch -p1 -f < $(SRCDIR)/patches/p7zip-12-CVE-2016-9296.patch - echo 1 > $@ - -$(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-13-CVE-2017-17969.patch-applied: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-12-CVE-2016-9296.patch-applied - cd $(dir $@) && patch -p1 -f < $(SRCDIR)/patches/p7zip-13-CVE-2017-17969.patch - echo 1 > $@ - -$(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-15-Enhanced-encryption-strength.patch-applied: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-13-CVE-2017-17969.patch-applied - cd $(dir $@) && patch -p4 -f < $(SRCDIR)/patches/p7zip-15-Enhanced-encryption-strength.patch - echo 1 > $@ - -$(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-Windows_ErrorMsg.patch-applied: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-15-Enhanced-encryption-strength.patch-applied - cd $(dir $@) && patch -p0 -f < $(SRCDIR)/patches/p7zip-Windows_ErrorMsg.patch - echo 1 > $@ - -$(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/p7zip-Windows_ErrorMsg.patch-applied +$(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/source-extracted $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-compiled: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured $(MAKE) -C $(dir $<) $(MAKE_COMMON) CC="$(CC)" CXX="$(CXX)" 7za echo 1 > $@ @@ -49,10 +33,10 @@ clean-p7zip: -$(MAKE) -C $(BUILDDIR)/p7zip-$(P7ZIP_VER) clean distclean-p7zip: - -rm -rf $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2 $(SRCCACHE)/p7zip-$(P7ZIP_VER) $(BUILDDIR)/p7zip-$(P7ZIP_VER) + -rm -rf $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz $(SRCCACHE)/p7zip-$(P7ZIP_VER) $(BUILDDIR)/p7zip-$(P7ZIP_VER) -get-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.bz2 +get-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER).tar.gz extract-p7zip: $(SRCCACHE)/p7zip-$(P7ZIP_VER)/source-extracted configure-p7zip: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-configured compile-p7zip: $(BUILDDIR)/p7zip-$(P7ZIP_VER)/build-compiled diff --git a/deps/patches/p7zip-12-CVE-2016-9296.patch b/deps/patches/p7zip-12-CVE-2016-9296.patch deleted file mode 100644 index 42245c92c0aae..0000000000000 --- a/deps/patches/p7zip-12-CVE-2016-9296.patch +++ /dev/null @@ -1,23 +0,0 @@ -From: Robert Luberda -Date: Sat, 19 Nov 2016 08:48:08 +0100 -Subject: Fix nullptr dereference (CVE-2016-9296) - -Patch taken from https://sourceforge.net/p/p7zip/bugs/185/ ---- - CPP/7zip/Archive/7z/7zIn.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp -index b0c6b98..7c6dde2 100644 ---- a/CPP/7zip/Archive/7z/7zIn.cpp -+++ b/CPP/7zip/Archive/7z/7zIn.cpp -@@ -1097,7 +1097,8 @@ HRESULT CInArchive::ReadAndDecodePackedStreams( - if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i]) - ThrowIncorrect(); - } -- HeadersSize += folders.PackPositions[folders.NumPackStreams]; -+ if (folders.PackPositions) -+ HeadersSize += folders.PackPositions[folders.NumPackStreams]; - return S_OK; - } - diff --git a/deps/patches/p7zip-13-CVE-2017-17969.patch b/deps/patches/p7zip-13-CVE-2017-17969.patch deleted file mode 100644 index a9787c4a90886..0000000000000 --- a/deps/patches/p7zip-13-CVE-2017-17969.patch +++ /dev/null @@ -1,35 +0,0 @@ -From: =?utf-8?q?Antoine_Beaupr=C3=A9?= -Date: Fri, 2 Feb 2018 11:11:41 +0100 -Subject: Heap-based buffer overflow in 7zip/Compress/ShrinkDecoder.cpp - -Origin: vendor, https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/27d7/attachment/CVE-2017-17969.patch -Forwarded: https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/#27d7 -Bug: https://sourceforge.net/p/p7zip/bugs/204/ -Bug-Debian: https://bugs.debian.org/888297 -Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2017-17969 -Reviewed-by: Salvatore Bonaccorso -Last-Update: 2018-02-01 -Applied-Upstream: 18.00-beta ---- - CPP/7zip/Compress/ShrinkDecoder.cpp | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/CPP/7zip/Compress/ShrinkDecoder.cpp b/CPP/7zip/Compress/ShrinkDecoder.cpp -index 80b7e67..ca37764 100644 ---- a/CPP/7zip/Compress/ShrinkDecoder.cpp -+++ b/CPP/7zip/Compress/ShrinkDecoder.cpp -@@ -121,8 +121,13 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream * - { - _stack[i++] = _suffixes[cur]; - cur = _parents[cur]; -+ if (cur >= kNumItems || i >= kNumItems) -+ break; - } -- -+ -+ if (cur >= kNumItems || i >= kNumItems) -+ break; -+ - _stack[i++] = (Byte)cur; - lastChar2 = (Byte)cur; - diff --git a/deps/patches/p7zip-15-Enhanced-encryption-strength.patch b/deps/patches/p7zip-15-Enhanced-encryption-strength.patch deleted file mode 100644 index ab1cfb9c743fb..0000000000000 --- a/deps/patches/p7zip-15-Enhanced-encryption-strength.patch +++ /dev/null @@ -1,298 +0,0 @@ -From ea31bbe661abef761e49983b56923e6523b9463a Mon Sep 17 00:00:00 2001 -From: aone -Date: Thu, 7 Mar 2019 10:06:16 +0100 -Subject: [PATCH] Enhanced encryption strength from 7-Zip 19.00 - -https://github.com/aonez/Keka/issues/379 -https://sourceforge.net/p/sevenzip/bugs/2176 ---- - .../CPP/7zip/Archive/Wim/WimHandlerOut.cpp | 2 +- - Bin/p7zip/source/CPP/7zip/Crypto/7zAes.cpp | 4 +- - Bin/p7zip/source/CPP/7zip/Crypto/RandGen.cpp | 135 ++++++++++++++++-- - Bin/p7zip/source/CPP/7zip/Crypto/RandGen.h | 19 +++ - Bin/p7zip/source/CPP/7zip/Crypto/WzAes.cpp | 2 +- - .../source/CPP/7zip/Crypto/ZipCrypto.cpp | 2 +- - 6 files changed, 146 insertions(+), 18 deletions(-) - -diff --git a/Bin/p7zip/source/CPP/7zip/Archive/Wim/WimHandlerOut.cpp b/Bin/p7zip/source/CPP/7zip/Archive/Wim/WimHandlerOut.cpp -index 1d198df0..39679883 100644 ---- a/Bin/p7zip/source/CPP/7zip/Archive/Wim/WimHandlerOut.cpp -+++ b/Bin/p7zip/source/CPP/7zip/Archive/Wim/WimHandlerOut.cpp -@@ -671,7 +671,7 @@ void CHeader::SetDefaultFields(bool useLZX) - ChunkSize = kChunkSize; - ChunkSizeBits = kChunkSizeBits; - } -- g_RandomGenerator.Generate(Guid, 16); -+ MY_RAND_GEN(Guid, 16); - PartNumber = 1; - NumParts = 1; - NumImages = 1; -diff --git a/Bin/p7zip/source/CPP/7zip/Crypto/7zAes.cpp b/Bin/p7zip/source/CPP/7zip/Crypto/7zAes.cpp -index d33b562a..2ed69bad 100644 ---- a/Bin/p7zip/source/CPP/7zip/Crypto/7zAes.cpp -+++ b/Bin/p7zip/source/CPP/7zip/Crypto/7zAes.cpp -@@ -164,8 +164,8 @@ STDMETHODIMP CEncoder::ResetInitVector() - { - for (unsigned i = 0; i < sizeof(_iv); i++) - _iv[i] = 0; -- _ivSize = 8; -- g_RandomGenerator.Generate(_iv, _ivSize); -+ _ivSize = 16; -+ MY_RAND_GEN(_iv, _ivSize); - return S_OK; - } - -diff --git a/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.cpp b/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.cpp -index f5ea31f0..a70f4ec8 100644 ---- a/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.cpp -+++ b/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.cpp -@@ -2,14 +2,44 @@ - - #include "StdAfx.h" - -+#include "RandGen.h" -+ -+#ifndef USE_STATIC_SYSTEM_RAND -+ - #ifndef _7ZIP_ST - #include "../../Windows/Synchronization.h" - #endif - --#include "RandGen.h" - --#ifndef _WIN32 -+#ifdef _WIN32 -+ -+#ifdef _WIN64 -+#define USE_STATIC_RtlGenRandom -+#endif -+ -+#ifdef USE_STATIC_RtlGenRandom -+ -+#include -+ -+EXTERN_C_BEGIN -+#ifndef RtlGenRandom -+ #define RtlGenRandom SystemFunction036 -+ BOOLEAN WINAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); -+#endif -+EXTERN_C_END -+ -+#else -+EXTERN_C_BEGIN -+typedef BOOLEAN (WINAPI * Func_RtlGenRandom)(PVOID RandomBuffer, ULONG RandomBufferLength); -+EXTERN_C_END -+#endif -+ -+ -+#else - #include -+#include -+#include -+#include - #define USE_POSIX_TIME - #define USE_POSIX_TIME2 - #endif -@@ -21,11 +51,9 @@ - #endif - #endif - --// This is not very good random number generator. --// Please use it only for salt. --// First generated data block depends from timer and processID. -+// The seed and first generated data block depend from processID, -+// theadID, timer and system random generator, if available. - // Other generated data blocks depend from previous state --// Maybe it's possible to restore original timer value from generated value. - - #define HASH_UPD(x) Sha256_Update(&hash, (const Byte *)&x, sizeof(x)); - -@@ -34,25 +62,102 @@ void CRandomGenerator::Init() - CSha256 hash; - Sha256_Init(&hash); - -+ unsigned numIterations = 1000; -+ -+ { -+ #ifndef UNDER_CE -+ const unsigned kNumIterations_Small = 100; -+ const unsigned kBufSize = 32; -+ Byte buf[kBufSize]; -+ #endif -+ - #ifdef _WIN32 -+ - DWORD w = ::GetCurrentProcessId(); - HASH_UPD(w); - w = ::GetCurrentThreadId(); - HASH_UPD(w); -+ -+ #ifdef UNDER_CE -+ /* -+ if (CeGenRandom(kBufSize, buf)) -+ { -+ numIterations = kNumIterations_Small; -+ Sha256_Update(&hash, buf, kBufSize); -+ } -+ */ -+ #elif defined(USE_STATIC_RtlGenRandom) -+ if (RtlGenRandom(buf, kBufSize)) -+ { -+ numIterations = kNumIterations_Small; -+ Sha256_Update(&hash, buf, kBufSize); -+ } - #else -+ { -+ HMODULE hModule = ::LoadLibrary(TEXT("Advapi32.dll")); -+ if (hModule) -+ { -+ // SystemFunction036() is real name of RtlGenRandom() function -+ Func_RtlGenRandom my_RtlGenRandom = (Func_RtlGenRandom)GetProcAddress(hModule, "SystemFunction036"); -+ if (my_RtlGenRandom) -+ { -+ if (my_RtlGenRandom(buf, kBufSize)) -+ { -+ numIterations = kNumIterations_Small; -+ Sha256_Update(&hash, buf, kBufSize); -+ } -+ } -+ ::FreeLibrary(hModule); -+ } -+ } -+ #endif -+ -+ #else -+ - pid_t pid = getpid(); - HASH_UPD(pid); - pid = getppid(); - HASH_UPD(pid); -+ -+ { -+ int f = open("/dev/urandom", O_RDONLY); -+ unsigned numBytes = kBufSize; -+ if (f >= 0) -+ { -+ do -+ { -+ int n = read(f, buf, numBytes); -+ if (n <= 0) -+ break; -+ Sha256_Update(&hash, buf, n); -+ numBytes -= n; -+ } -+ while (numBytes); -+ close(f); -+ if (numBytes == 0) -+ numIterations = kNumIterations_Small; -+ } -+ } -+ /* -+ { -+ int n = getrandom(buf, kBufSize, 0); -+ if (n > 0) -+ { -+ Sha256_Update(&hash, buf, n); -+ if (n == kBufSize) -+ numIterations = kNumIterations_Small; -+ } -+ } -+ */ -+ -+ #endif -+ } -+ -+ #ifdef _DEBUG -+ numIterations = 2; - #endif - -- for (unsigned i = 0; i < -- #ifdef _DEBUG -- 2; -- #else -- 1000; -- #endif -- i++) -+ do - { - #ifdef _WIN32 - LARGE_INTEGER v; -@@ -83,6 +188,8 @@ void CRandomGenerator::Init() - Sha256_Update(&hash, _buff, SHA256_DIGEST_SIZE); - } - } -+ while (--numIterations); -+ - Sha256_Final(&hash, _buff); - _needInit = false; - } -@@ -120,3 +227,5 @@ void CRandomGenerator::Generate(Byte *data, unsigned size) - } - - CRandomGenerator g_RandomGenerator; -+ -+#endif -diff --git a/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.h b/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.h -index cfdcd60d..5122ec4b 100644 ---- a/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.h -+++ b/Bin/p7zip/source/CPP/7zip/Crypto/RandGen.h -@@ -5,6 +5,21 @@ - - #include "../../../C/Sha256.h" - -+#ifdef _WIN64 -+// #define USE_STATIC_SYSTEM_RAND -+#endif -+ -+#ifdef USE_STATIC_SYSTEM_RAND -+ -+#ifdef _WIN32 -+#include -+#define MY_RAND_GEN(data, size) RtlGenRandom(data, size) -+#else -+#define MY_RAND_GEN(data, size) getrandom(data, size, 0) -+#endif -+ -+#else -+ - class CRandomGenerator - { - Byte _buff[SHA256_DIGEST_SIZE]; -@@ -18,4 +33,8 @@ public: - - extern CRandomGenerator g_RandomGenerator; - -+#define MY_RAND_GEN(data, size) g_RandomGenerator.Generate(data, size) -+ -+#endif -+ - #endif -diff --git a/Bin/p7zip/source/CPP/7zip/Crypto/WzAes.cpp b/Bin/p7zip/source/CPP/7zip/Crypto/WzAes.cpp -index 4572f06e..d415ab84 100644 ---- a/Bin/p7zip/source/CPP/7zip/Crypto/WzAes.cpp -+++ b/Bin/p7zip/source/CPP/7zip/Crypto/WzAes.cpp -@@ -96,7 +96,7 @@ STDMETHODIMP CBaseCoder::Init() - HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream) - { - unsigned saltSize = _key.GetSaltSize(); -- g_RandomGenerator.Generate(_key.Salt, saltSize); -+ MY_RAND_GEN(_key.Salt, saltSize); - Init2(); - RINOK(WriteStream(outStream, _key.Salt, saltSize)); - return WriteStream(outStream, _key.PwdVerifComputed, kPwdVerifSize); -diff --git a/Bin/p7zip/source/CPP/7zip/Crypto/ZipCrypto.cpp b/Bin/p7zip/source/CPP/7zip/Crypto/ZipCrypto.cpp -index ae715063..8610297a 100644 ---- a/Bin/p7zip/source/CPP/7zip/Crypto/ZipCrypto.cpp -+++ b/Bin/p7zip/source/CPP/7zip/Crypto/ZipCrypto.cpp -@@ -49,7 +49,7 @@ HRESULT CEncoder::WriteHeader_Check16(ISequentialOutStream *outStream, UInt16 cr - PKZIP 2.0+ used 1 byte CRC check. It's more secure. - We also use 1 byte CRC. */ - -- g_RandomGenerator.Generate(h, kHeaderSize - 1); -+ MY_RAND_GEN(h, kHeaderSize - 1); - // h[kHeaderSize - 2] = (Byte)(crc); - h[kHeaderSize - 1] = (Byte)(crc >> 8); - --- -2.17.1 - diff --git a/deps/patches/p7zip-Windows_ErrorMsg.patch b/deps/patches/p7zip-Windows_ErrorMsg.patch deleted file mode 100644 index 71de3e9f59c86..0000000000000 --- a/deps/patches/p7zip-Windows_ErrorMsg.patch +++ /dev/null @@ -1,33 +0,0 @@ -This fixes the build with Clang 6.0: - - ../../../../CPP/Windows/ErrorMsg.cpp:24:10: error: case value evaluates to -2147024809, which cannot be narrowed to type 'DWORD' (aka 'unsigned int') [-Wc++11-narrowing] - case E_INVALIDARG : txt = "E_INVALIDARG"; break ; - ^ - ../../../../CPP/Common/MyWindows.h:89:22: note: expanded from macro 'E_INVALIDARG' - #define E_INVALIDARG ((HRESULT)0x80070057L) - ^ - -The HRESULT cast in the macro causes the value to be read as signed int. ---- CPP/Windows/ErrorMsg.cpp.orig 2015-01-18 18:20:28 UTC -+++ CPP/Windows/ErrorMsg.cpp -@@ -15,13 +15,13 @@ UString MyFormatMessage(DWORD errorCode) - - switch(errorCode) { - case ERROR_NO_MORE_FILES : txt = "No more files"; break ; -- case E_NOTIMPL : txt = "E_NOTIMPL"; break ; -- case E_NOINTERFACE : txt = "E_NOINTERFACE"; break ; -- case E_ABORT : txt = "E_ABORT"; break ; -- case E_FAIL : txt = "E_FAIL"; break ; -- case STG_E_INVALIDFUNCTION : txt = "STG_E_INVALIDFUNCTION"; break ; -- case E_OUTOFMEMORY : txt = "E_OUTOFMEMORY"; break ; -- case E_INVALIDARG : txt = "E_INVALIDARG"; break ; -+ case (DWORD)(E_NOTIMPL) : txt = "E_NOTIMPL"; break ; -+ case (DWORD)(E_NOINTERFACE) : txt = "E_NOINTERFACE"; break ; -+ case (DWORD)(E_ABORT) : txt = "E_ABORT"; break ; -+ case (DWORD)(E_FAIL) : txt = "E_FAIL"; break ; -+ case (DWORD)(STG_E_INVALIDFUNCTION) : txt = "STG_E_INVALIDFUNCTION"; break ; -+ case (DWORD)(E_OUTOFMEMORY) : txt = "E_OUTOFMEMORY"; break ; -+ case (DWORD)(E_INVALIDARG) : txt = "E_INVALIDARG"; break ; - case ERROR_DIRECTORY : txt = "Error Directory"; break ; - default: - txt = strerror(errorCode); diff --git a/stdlib/p7zip_jll/Project.toml b/stdlib/p7zip_jll/Project.toml index 69330b7e80539..76f8c85ab0d25 100644 --- a/stdlib/p7zip_jll/Project.toml +++ b/stdlib/p7zip_jll/Project.toml @@ -1,6 +1,6 @@ name = "p7zip_jll" uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "16.2.1+0" +version = "17.4.0+0" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" From 416a76934ae6d98e56ec56e6571fa8cba04ca7d0 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 26 Jan 2022 14:51:58 -0500 Subject: [PATCH 28/34] [Distributed] Set stdin to devnull before closing it Distributed closes and destroys stdin, but some tests attempted to explicitly use it, leading to test problems. We previously interpreted this as passing devnull, but this is better to be explicit. (cherry picked from commit 64a86f9bca119db3a64e02294f9da16ed6b50a07) --- stdlib/Distributed/src/cluster.jl | 5 ++++- stdlib/Distributed/test/distributed_exec.jl | 6 +++++- stdlib/REPL/src/TerminalMenus/util.jl | 10 +++++----- .../TerminalMenus/legacytests/old_multiselect_menu.jl | 4 ++-- .../test/TerminalMenus/legacytests/old_radio_menu.jl | 6 +++--- stdlib/REPL/test/TerminalMenus/multiselect_menu.jl | 4 ++-- .../test/TerminalMenus/multiselect_with_skip_menu.jl | 4 ++-- stdlib/REPL/test/TerminalMenus/radio_menu.jl | 6 +++--- stdlib/REPL/test/TerminalMenus/runtests.jl | 11 ++++++----- 9 files changed, 32 insertions(+), 24 deletions(-) diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index fff26710ac973..80e5d6283cdbc 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -230,7 +230,10 @@ start_worker(cookie::AbstractString=readline(stdin); kwargs...) = start_worker(s function start_worker(out::IO, cookie::AbstractString=readline(stdin); close_stdin::Bool=true, stderr_to_stdout::Bool=true) init_multi() - close_stdin && close(stdin) # workers will not use it + if close_stdin # workers will not use it + redirect_stdin(devnull) + close(stdin) + end stderr_to_stdout && redirect_stderr(stdout) init_worker(cookie) diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 1192afca26975..4f0db3ad7d0b2 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -1619,7 +1619,11 @@ cluster_cookie("") for close_stdin in (true, false), stderr_to_stdout in (true, false) local npids = addprocs_with_testenv(RetainStdioTester(close_stdin,stderr_to_stdout)) @test remotecall_fetch(myid, npids[1]) == npids[1] - @test close_stdin != remotecall_fetch(()->isopen(stdin), npids[1]) + if close_stdin + @test remotecall_fetch(()->stdin === devnull && !isreadable(stdin), npids[1]) + else + @test remotecall_fetch(()->stdin !== devnull && isopen(stdin) && isreadable(stdin), npids[1]) + end @test stderr_to_stdout == remotecall_fetch(()->(stderr === stdout), npids[1]) rmprocs(npids) end diff --git a/stdlib/REPL/src/TerminalMenus/util.jl b/stdlib/REPL/src/TerminalMenus/util.jl index 8ad9ec0e4100d..91e336070d2cf 100644 --- a/stdlib/REPL/src/TerminalMenus/util.jl +++ b/stdlib/REPL/src/TerminalMenus/util.jl @@ -17,24 +17,24 @@ readbyte(stream::IO=stdin) = read(stream, Char) # Read the next key from stdin. It is also able to read several bytes for # escaped keys such as the arrow keys, home/end keys, etc. # Escaped keys are returned using the `Key` enum. -readkey(stream::Base.LibuvStream=stdin) = UInt32(_readkey(stream)) -function _readkey(stream::Base.LibuvStream=stdin) +readkey(stream::IO=stdin) = UInt32(_readkey(stream)) +function _readkey(stream::IO=stdin) c = readbyte(stream) # Escape characters if c == '\x1b' - stream.buffer.size < 2 && return '\x1b' + bytesavailable(stream) < 1 && return '\x1b' esc_a = readbyte(stream) esc_a == 'v' && return PAGE_UP # M-v esc_a == '<' && return HOME_KEY # M-< esc_a == '>' && return END_KEY # M-> - stream.buffer.size < 3 && return '\x1b' + bytesavailable(stream) < 1 && return '\x1b' esc_b = readbyte(stream) if esc_a == '[' || esc_a == 'O' if esc_b >= '0' && esc_b <= '9' - stream.buffer.size < 4 && return '\x1b' + bytesavailable(stream) < 1 && return '\x1b' esc_c = readbyte(stream) if esc_c == '~' esc_b == '1' && return HOME_KEY diff --git a/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl b/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl index 49dbcc42c3095..9902a992ea081 100644 --- a/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/legacytests/old_multiselect_menu.jl @@ -33,6 +33,6 @@ TerminalMenus.writeLine(buf, multi_menu, 1, true) # Test SDTIN multi_menu = MultiSelectMenu(string.(1:10), warn=false) -@test simulate_input(Set([1,2]), multi_menu, :enter, :down, :enter, 'd') +@test simulate_input(multi_menu, :enter, :down, :enter, 'd') == Set([1,2]) multi_menu = MultiSelectMenu(["single option"], warn=false) -@test simulate_input(Set([1]), multi_menu, :up, :up, :down, :enter, 'd') +@test simulate_input(multi_menu, :up, :up, :down, :enter, 'd') == Set([1]) diff --git a/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl b/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl index 9438808a847d6..248d5cd6a3183 100644 --- a/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/legacytests/old_radio_menu.jl @@ -36,8 +36,8 @@ TerminalMenus.writeLine(buf, radio_menu, 1, true) # Test using stdin radio_menu = RadioMenu(string.(1:10), warn=false) -@test simulate_input(3, radio_menu, :down, :down, :enter) +@test simulate_input(radio_menu, :down, :down, :enter) == 3 radio_menu = RadioMenu(["single option"], warn=false) -@test simulate_input(1, radio_menu, :up, :up, :down, :up, :enter) +@test simulate_input(radio_menu, :up, :up, :down, :up, :enter) == 1 radio_menu = RadioMenu(string.(1:3), pagesize=1, warn=false) -@test simulate_input(3, radio_menu, :down, :down, :down, :down, :enter) +@test simulate_input(radio_menu, :down, :down, :down, :down, :enter) == 3 diff --git a/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl b/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl index d625554c813b0..d6568fb6b04c1 100644 --- a/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/multiselect_menu.jl @@ -52,6 +52,6 @@ end # Test SDTIN multi_menu = MultiSelectMenu(string.(1:10), charset=:ascii) -@test simulate_input(Set([1,2]), multi_menu, :enter, :down, :enter, 'd') +@test simulate_input(multi_menu, :enter, :down, :enter, 'd') == Set([1,2]) multi_menu = MultiSelectMenu(["single option"], charset=:ascii) -@test simulate_input(Set([1]), multi_menu, :up, :up, :down, :enter, 'd') +@test simulate_input(multi_menu, :up, :up, :down, :enter, 'd') == Set([1]) diff --git a/stdlib/REPL/test/TerminalMenus/multiselect_with_skip_menu.jl b/stdlib/REPL/test/TerminalMenus/multiselect_with_skip_menu.jl index 84f259ad7642c..609b168c2ddba 100644 --- a/stdlib/REPL/test/TerminalMenus/multiselect_with_skip_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/multiselect_with_skip_menu.jl @@ -121,10 +121,10 @@ menu = MultiSelectWithSkipMenu(string.(1:5), selected=[2, 3]) buf = IOBuffer() TerminalMenus.printmenu(buf, menu, 1; init=true) @test occursin("2 items selected", String(take!(buf))) -@test simulate_input(Set([2, 3, 4]), menu, 'n', :enter, 'd') +@test simulate_input(menu, 'n', :enter, 'd') == Set([2, 3, 4]) buf = IOBuffer() TerminalMenus.printmenu(buf, menu, 1; init=true) @test occursin("3 items selected", String(take!(buf))) menu = MultiSelectWithSkipMenu(string.(1:5), selected=[2, 3]) -@test simulate_input(Set([2]), menu, 'P', :enter, 'd', cursor=5) +@test simulate_input(menu, 'P', :enter, 'd', cursor=5) == Set([2]) diff --git a/stdlib/REPL/test/TerminalMenus/radio_menu.jl b/stdlib/REPL/test/TerminalMenus/radio_menu.jl index 28a19fa7d9ac0..a02683e5f0cb0 100644 --- a/stdlib/REPL/test/TerminalMenus/radio_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/radio_menu.jl @@ -45,8 +45,8 @@ end # Test using stdin radio_menu = RadioMenu(string.(1:10); charset=:ascii) -@test simulate_input(3, radio_menu, :down, :down, :enter) +@test simulate_input(radio_menu, :down, :down, :enter) == 3 radio_menu = RadioMenu(["single option"], charset=:ascii) -@test simulate_input(1, radio_menu, :up, :up, :down, :up, :enter) +@test simulate_input(radio_menu, :up, :up, :down, :up, :enter) == 1 radio_menu = RadioMenu(string.(1:3), pagesize=1, charset=:ascii) -@test simulate_input(3, radio_menu, :down, :down, :down, :down, :enter) +@test simulate_input(radio_menu, :down, :down, :down, :down, :enter) == 3 diff --git a/stdlib/REPL/test/TerminalMenus/runtests.jl b/stdlib/REPL/test/TerminalMenus/runtests.jl index fab105244d0a1..e5e5f0ac431ce 100644 --- a/stdlib/REPL/test/TerminalMenus/runtests.jl +++ b/stdlib/REPL/test/TerminalMenus/runtests.jl @@ -4,21 +4,22 @@ import REPL using REPL.TerminalMenus using Test -function simulate_input(expected, menu::TerminalMenus.AbstractMenu, keys...; - kwargs...) +function simulate_input(menu::TerminalMenus.AbstractMenu, keys...; kwargs...) keydict = Dict(:up => "\e[A", :down => "\e[B", :enter => "\r") + new_stdin = Base.BufferStream() for key in keys if isa(key, Symbol) - write(stdin.buffer, keydict[key]) + write(new_stdin, keydict[key]) else - write(stdin.buffer, "$key") + write(new_stdin, "$key") end end + TerminalMenus.terminal.in_stream = new_stdin - request(menu; suppress_output=true, kwargs...) == expected + return request(menu; suppress_output=true, kwargs...) end include("radio_menu.jl") From 038c94948a918c57a4a14f6e427104ffe9f10b18 Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Mon, 25 Jan 2021 15:06:01 -0500 Subject: [PATCH 29/34] Fix #39367, doc for inbounds use each index (#39369) (cherry picked from commit f31ef767ef9cb0eb1de04d23e2e9e1ac765869b3) --- base/essentials.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/essentials.jl b/base/essentials.jl index aba10a1a011c6..fc75213ee3678 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -538,7 +538,7 @@ element `i` of array `A` is skipped to improve performance. ```julia function sum(A::AbstractArray) r = zero(eltype(A)) - for i = 1:length(A) + for i in eachindex(A) @inbounds r += A[i] end return r From 7989b169e7eef0d6345444020bf98efb597e8061 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Mon, 13 Jun 2022 23:59:18 -0700 Subject: [PATCH 30/34] Limit some buildkite jobs to run on only x86_64 machines (#45665) This should fix the `Exec format error` problems we've had recently due to us adding some non-x86_64 linux workers to the pool. --- .buildkite/pipelines/main/misc/doctest.yml | 1 + .buildkite/pipelines/main/misc/embedding.yml | 1 + .buildkite/pipelines/main/misc/llvmpasses.yml | 1 + .buildkite/pipelines/main/misc/sanitizers.yml | 1 + .buildkite/pipelines/main/misc/whitespace.yml | 1 + .buildkite/pipelines/main/platforms/package_linux.yml | 1 + .buildkite/pipelines/main/platforms/tester_linux.yml | 1 + 7 files changed, 7 insertions(+) diff --git a/.buildkite/pipelines/main/misc/doctest.yml b/.buildkite/pipelines/main/misc/doctest.yml index b83139ddc1f9b..33e42debb478d 100644 --- a/.buildkite/pipelines/main/misc/doctest.yml +++ b/.buildkite/pipelines/main/misc/doctest.yml @@ -3,6 +3,7 @@ agents: # Only run on `sandbox.jl` machines (not `docker`-isolated ones) since we need nestable sandboxing sandbox.jl: "true" os: "linux" + arch: "x86_64" steps: - label: "doctest" key: doctest diff --git a/.buildkite/pipelines/main/misc/embedding.yml b/.buildkite/pipelines/main/misc/embedding.yml index bdd2a0a6065f5..ba273e239d69f 100644 --- a/.buildkite/pipelines/main/misc/embedding.yml +++ b/.buildkite/pipelines/main/misc/embedding.yml @@ -3,6 +3,7 @@ agents: # Only run on `sandbox.jl` machines (not `docker`-isolated ones) since we need nestable sandboxing sandbox.jl: "true" os: "linux" + arch: "x86_64" steps: - label: "embedding" key: "embedding" diff --git a/.buildkite/pipelines/main/misc/llvmpasses.yml b/.buildkite/pipelines/main/misc/llvmpasses.yml index 1f6d89014eb0d..25bcad1247db9 100644 --- a/.buildkite/pipelines/main/misc/llvmpasses.yml +++ b/.buildkite/pipelines/main/misc/llvmpasses.yml @@ -3,6 +3,7 @@ agents: # Only run on `sandbox.jl` machines (not `docker`-isolated ones) since we need nestable sandboxing sandbox.jl: "true" os: "linux" + arch: "x86_64" steps: - label: "analyzegc" key: "analyzegc" diff --git a/.buildkite/pipelines/main/misc/sanitizers.yml b/.buildkite/pipelines/main/misc/sanitizers.yml index a0c40dda7e12f..d406bcf403d37 100644 --- a/.buildkite/pipelines/main/misc/sanitizers.yml +++ b/.buildkite/pipelines/main/misc/sanitizers.yml @@ -3,6 +3,7 @@ agents: # Only run on `sandbox.jl` machines (not `docker`-isolated ones) since we need nestable sandboxing sandbox.jl: "true" os: "linux" + arch: "x86_64" steps: - label: "asan" key: "asan" diff --git a/.buildkite/pipelines/main/misc/whitespace.yml b/.buildkite/pipelines/main/misc/whitespace.yml index 673221e54cfdc..076e71b6fd514 100644 --- a/.buildkite/pipelines/main/misc/whitespace.yml +++ b/.buildkite/pipelines/main/misc/whitespace.yml @@ -3,6 +3,7 @@ agents: # Only run on `sandbox.jl` machines (not `docker`-isolated ones) since we need nestable sandboxing sandbox.jl: "true" os: "linux" + arch: "x86_64" steps: - label: "whitespace" key: "whitespace" diff --git a/.buildkite/pipelines/main/platforms/package_linux.yml b/.buildkite/pipelines/main/platforms/package_linux.yml index ce778c393b064..0e49cab2d6fc9 100644 --- a/.buildkite/pipelines/main/platforms/package_linux.yml +++ b/.buildkite/pipelines/main/platforms/package_linux.yml @@ -3,6 +3,7 @@ agents: # Only run on `sandbox.jl` machines (not `docker`-isolated ones) since we need nestable sandboxing sandbox.jl: "true" os: "linux" + arch: "x86_64" steps: - label: "package_${PLATFORM?}${LABEL?}" key: package_${PLATFORM?}${LABEL?} diff --git a/.buildkite/pipelines/main/platforms/tester_linux.yml b/.buildkite/pipelines/main/platforms/tester_linux.yml index 18b019e66c8b7..85bc64f51903e 100644 --- a/.buildkite/pipelines/main/platforms/tester_linux.yml +++ b/.buildkite/pipelines/main/platforms/tester_linux.yml @@ -3,6 +3,7 @@ agents: # Only run on `sandbox.jl` machines (not `docker`-isolated ones) since we need nestable sandboxing sandbox.jl: "true" os: "linux" + arch: "x86_64" steps: - label: "tester_${PLATFORM?}${LABEL?}" key: tester_${PLATFORM?}${LABEL?} From c3116fd0a63b14eb7150a40d1814ba0bd8299563 Mon Sep 17 00:00:00 2001 From: KristofferC Date: Wed, 15 Jun 2022 09:03:51 +0200 Subject: [PATCH 31/34] bump Pkg version to latest 1.6 --- .../Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/md5 | 1 + .../Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/sha512 | 1 + .../Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/md5 | 1 - .../Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/sha512 | 1 - stdlib/Pkg.version | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/md5 create mode 100644 deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/sha512 delete mode 100644 deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/md5 delete mode 100644 deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/sha512 diff --git a/deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/md5 b/deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/md5 new file mode 100644 index 0000000000000..792ba36386814 --- /dev/null +++ b/deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/md5 @@ -0,0 +1 @@ +7a68069fd63b0152c9a494a0866a25c7 diff --git a/deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/sha512 b/deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/sha512 new file mode 100644 index 0000000000000..20b53d6f56b57 --- /dev/null +++ b/deps/checksums/Pkg-292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5.tar.gz/sha512 @@ -0,0 +1 @@ +829d7524d0750f4c57fbf0557b4db0e029c07c7dfb0fbb0c772d1d983df4da6b1693cb653b0b615fec2e1c8ef8e4b1a52ad0ef0cee04527e72ac4a4500982cc8 diff --git a/deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/md5 b/deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/md5 deleted file mode 100644 index 70a2532147b3d..0000000000000 --- a/deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -945e57c4f3c20aa69069b89eb050a3e5 diff --git a/deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/sha512 b/deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/sha512 deleted file mode 100644 index 1a926cbfb1076..0000000000000 --- a/deps/checksums/Pkg-30a31381d06d845999314d39005ee8457bd08924.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -5b026a801e60023598b51ee4d24bb6fd19eb811f7f7840fb88ece2335bbe1048f43fa94e7dcd65239c2b50540feab4028fabe4cb4fa5eafdb6075fe2b336bca8 diff --git a/stdlib/Pkg.version b/stdlib/Pkg.version index 9a4b56c59ef4a..1f9dc181395bd 100644 --- a/stdlib/Pkg.version +++ b/stdlib/Pkg.version @@ -1,4 +1,4 @@ PKG_BRANCH = release-1.6 -PKG_SHA1 = 30a31381d06d845999314d39005ee8457bd08924 +PKG_SHA1 = 292c1e637a0a8e15b8b5fa8e6fe14dcc0b0cd6e5 PKG_GIT_URL := https://github.com/JuliaLang/Pkg.jl.git PKG_TAR_URL = https://api.github.com/repos/JuliaLang/Pkg.jl/tarball/$1 From 064fb731920a3f9709edaaf13dda9da09d8cf65d Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Sun, 19 Jun 2022 04:36:22 -0600 Subject: [PATCH 32/34] Pass along backlog keyword argument in Sockets.listen (#45737) (cherry picked from commit 4f1c68e071a5ad54d9d8a1aeb1f3622bb4498d5f) --- stdlib/Sockets/src/Sockets.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/Sockets/src/Sockets.jl b/stdlib/Sockets/src/Sockets.jl index 1e5b90cdda390..d9e980706140f 100644 --- a/stdlib/Sockets/src/Sockets.jl +++ b/stdlib/Sockets/src/Sockets.jl @@ -629,7 +629,7 @@ listen(port::Integer; backlog::Integer=BACKLOG_DEFAULT) = listen(localhost, port listen(host::IPAddr, port::Integer; backlog::Integer=BACKLOG_DEFAULT) = listen(InetAddr(host, port); backlog=backlog) function listen(sock::LibuvServer; backlog::Integer=BACKLOG_DEFAULT) - uv_error("listen", trylisten(sock)) + uv_error("listen", trylisten(sock; backlog=backlog)) return sock end From 5c5c85ae40321dbfcaa774af66c14b7900029bd9 Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Sun, 19 Jun 2022 15:31:01 -0400 Subject: [PATCH 33/34] Use https for downloading of unicode data from unicode.org (#45750) (cherry picked from commit 9b83dd8920734c1d869ced888b6d8a734fff365d) --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index ef5dadc3f3ab3..77bb9a03f46cd 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -27,7 +27,7 @@ DOCUMENTER_OPTIONS := linkcheck=$(linkcheck) doctest=$(doctest) buildroot=$(call UNICODE_DATA_VERSION=13.0.0 $(SRCCACHE)/UnicodeData-$(UNICODE_DATA_VERSION).txt: @mkdir -p "$(SRCCACHE)" - $(JLDOWNLOAD) "$@" http://www.unicode.org/Public/$(UNICODE_DATA_VERSION)/ucd/UnicodeData.txt + $(JLDOWNLOAD) "$@" https://www.unicode.org/Public/$(UNICODE_DATA_VERSION)/ucd/UnicodeData.txt deps: $(SRCCACHE)/UnicodeData-$(UNICODE_DATA_VERSION).txt $(JLCHECKSUM) "$<" From 443c321683c50192d8f9e5129222352d8a03af85 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Mon, 4 Jul 2022 03:40:40 -0700 Subject: [PATCH 34/34] [release-1.6] Backport MbedTLS security patches (#45848) * [release-1.6] Backport MbedTLS security patches A few MbedTLS security patches should be backported to our LTS release. In the future, we should lock ourselves to MbedTLS LTS releases so that we can take advantage of their backporting as well. * Bump mbedtls version and checksums --- deps/checksums/mbedtls | 64 +- deps/mbedtls.mk | 23 +- .../mbedtls-security-advisory-2021-07-1.patch | 301 ++++ .../mbedtls-security-advisory-2021-07-2.patch | 1377 +++++++++++++++++ .../mbedtls-security-advisory-2021-12.patch | 25 + stdlib/MbedTLS_jll/Project.toml | 2 +- 6 files changed, 1758 insertions(+), 34 deletions(-) create mode 100644 deps/patches/mbedtls-security-advisory-2021-07-1.patch create mode 100644 deps/patches/mbedtls-security-advisory-2021-07-2.patch create mode 100644 deps/patches/mbedtls-security-advisory-2021-12.patch diff --git a/deps/checksums/mbedtls b/deps/checksums/mbedtls index b736ae1c690b4..267e6fd1dd28a 100644 --- a/deps/checksums/mbedtls +++ b/deps/checksums/mbedtls @@ -1,34 +1,34 @@ -MbedTLS.v2.24.0+1.aarch64-apple-darwin.tar.gz/md5/63178c9516d47e07905b538993e2de0a -MbedTLS.v2.24.0+1.aarch64-apple-darwin.tar.gz/sha512/d2c6456c55054b26223083c8286fb92b5161d9b75b5e6e0fedeccaf95490a17576602cf5df728bdf367fb45dbe71cde15260c690d8fce7cc22651bbd416fc6b6 -MbedTLS.v2.24.0+1.aarch64-linux-gnu.tar.gz/md5/2fee5b47f2b4c99c3124919613acc111 -MbedTLS.v2.24.0+1.aarch64-linux-gnu.tar.gz/sha512/7147823424d773024b4bc0cf4fbcd3a188af01a15cd93421c1946c9972ffc3417f4b8e1b671f80a13878f579473d8500aec1d5f74a9d6fdf6ed707de41deeb87 -MbedTLS.v2.24.0+1.aarch64-linux-musl.tar.gz/md5/d92a7e134cb4d4ce65a7d307c6252d83 -MbedTLS.v2.24.0+1.aarch64-linux-musl.tar.gz/sha512/6c8ade10420b1f6ff9e7734a653b932e041d1ff6a1360209aaf2498beb4c1a7b7c5019c9f205ba87077c8181c45097012ed758af828ad4ea510ff5288a879975 -MbedTLS.v2.24.0+1.armv6l-linux-gnueabihf.tar.gz/md5/bd30d16b25e503e4604ba65d7a15d9d6 -MbedTLS.v2.24.0+1.armv6l-linux-gnueabihf.tar.gz/sha512/58f821563241750f96e9ee0d03fceec50471d5e16bc70754759c01f18e9148d1a6750f947ca08f7eb6234e154bff022177cffd73f43fd52231ec5f8d1de2bf10 -MbedTLS.v2.24.0+1.armv6l-linux-musleabihf.tar.gz/md5/62b54065945595921eb16d894ddad13a -MbedTLS.v2.24.0+1.armv6l-linux-musleabihf.tar.gz/sha512/41790b50dc8ed9a82106c7885948c13f0e3fa2eb0275a3c939cd9ee59fa027c790ebfe4df26df2c97a971a1a889cb81b82fee94533c855d0d8a7e07540825431 -MbedTLS.v2.24.0+1.armv7l-linux-gnueabihf.tar.gz/md5/3584feb530503683cd32d28d99ac1fb2 -MbedTLS.v2.24.0+1.armv7l-linux-gnueabihf.tar.gz/sha512/1373fa258ee69d11771868fead86a6cf550362a47e34c4a6a2ecc3e76400104a7228220ad5333c52dc1a658e6e9316659cc076c8262f02a6e06cc92296586495 -MbedTLS.v2.24.0+1.armv7l-linux-musleabihf.tar.gz/md5/6a3a986a4dc8c258886b1af6fa7ed6cd -MbedTLS.v2.24.0+1.armv7l-linux-musleabihf.tar.gz/sha512/cc7cfb0eef06a68f662428025da70c19297ed2c052579da1f6380e836d729a222d736923f3a605a81a6c88e9d07ecaee653b5003a9f0ef1042f7ceae7a05c0ca -MbedTLS.v2.24.0+1.i686-linux-gnu.tar.gz/md5/a21258724fd9830ad845df925230fc98 -MbedTLS.v2.24.0+1.i686-linux-gnu.tar.gz/sha512/14df3ce37e792823f6132842ac47da3c740a011e52c3abf66123509c3da872a6b91003442e0a99ea2a3b8fa2d375fa1ac26ae62bfa2a73297aefbc221552a2b6 -MbedTLS.v2.24.0+1.i686-linux-musl.tar.gz/md5/9a8fc61aefa6f2a59b73fa1eb7605a47 -MbedTLS.v2.24.0+1.i686-linux-musl.tar.gz/sha512/513bc8f83cd13c85d6641d372b2e75dc983f3626d83e2ae24bf2afd9b08ce758edbcaebc8766da048e615b66aee493220df8520798030cf02107b5daf7d028b4 -MbedTLS.v2.24.0+1.i686-w64-mingw32.tar.gz/md5/c11c0834f23cc24fa3a0d8578c98f384 -MbedTLS.v2.24.0+1.i686-w64-mingw32.tar.gz/sha512/d750ca2005d8f0d5e9c06eec381dcd4271a2776b833b543b375e338e8d9077573d880467aacee5789d414a9ef7a06e63c5a45fb5d604459057ed25e23df3a8ba -MbedTLS.v2.24.0+1.powerpc64le-linux-gnu.tar.gz/md5/cd985543dc1b80e471849fead1121440 -MbedTLS.v2.24.0+1.powerpc64le-linux-gnu.tar.gz/sha512/92fcd67604291d76e52a0e37c9edb76789fad53b521d38a45035a78c2435150489854ca1e6d443bfeec99ee6fe33dcaa901c47076a936dd62b6a2c20ca961293 -MbedTLS.v2.24.0+1.x86_64-apple-darwin.tar.gz/md5/e5797b1b47fc23e9ddbdb6feff46e928 -MbedTLS.v2.24.0+1.x86_64-apple-darwin.tar.gz/sha512/de2c7a759abdd6e4fcb19603be7c3ece32451e4c5a36b28f11a0dd34f4705e79d799f620a8783de28d4ddb312adace65057b0c8a78007e8ea61dbe5738a16f44 -MbedTLS.v2.24.0+1.x86_64-linux-gnu.tar.gz/md5/93e8be223370fb3dc44c8f8f51e0aef3 -MbedTLS.v2.24.0+1.x86_64-linux-gnu.tar.gz/sha512/f3fba7d6f38e9ae9896d2f7a6194aaf547cc303631d914fd718fb06ba771ea0d3cf89edad3cc1b6fdc7978a8ba6b90f347dab94da526bc7f5c76c76d9275ed3b -MbedTLS.v2.24.0+1.x86_64-linux-musl.tar.gz/md5/6350f1dc3987f2d2f563b7b02a3bb508 -MbedTLS.v2.24.0+1.x86_64-linux-musl.tar.gz/sha512/2071bf8420e8142f86d3459e43e3fc0badf5bf6a2db3436750504f890734b5c6f92a751abc1cbba8fee596804bf53fa3c14353ab6dc8850e27216b67f28fe905 -MbedTLS.v2.24.0+1.x86_64-unknown-freebsd.tar.gz/md5/4fe5764a2c4d471392cf633dfd114f51 -MbedTLS.v2.24.0+1.x86_64-unknown-freebsd.tar.gz/sha512/9908e90d9a16c987f8ef945b07a40c5a73d0f78716bba170e0db84daf2888efe877e229ecc395c3c37bc8bdf87dba2eeceb52d49b650743661214601c5f22484 -MbedTLS.v2.24.0+1.x86_64-w64-mingw32.tar.gz/md5/392247046d060a2cff4ceeaad2f534fb -MbedTLS.v2.24.0+1.x86_64-w64-mingw32.tar.gz/sha512/9d2feb78170826a470a41d63b5dcc18093261e7f9751d11297e2d8462ecd0abb1fdb16df20e9223b8ab6ed06a19bfd539433f37ee9f44bdd20b0a578f87166f3 mbedtls-2.24.0.tar.gz/md5/9d1adcec4aa6729ae1dc56c3a24cb7d2 mbedtls-2.24.0.tar.gz/sha512/a51e80cedfa5c1772c79cba2dacd33f551516debf083803f7a5c1f4817c928e3bfb343fbe0c2e70ed591d0eba8fdc1bc46d11de7c3d12f50826de8f2f2ece279 +MbedTLS.v2.24.0+4.aarch64-apple-darwin.tar.gz/md5/4569a485b86ea4531cd8ef7a0f044ce6 +MbedTLS.v2.24.0+4.aarch64-apple-darwin.tar.gz/sha512/31078eff977b45ff40ae101924af65694dc0e70e6a3fb1aac0ab62045e0c7ebe50c0b85df27a48b02430cd8f9b6b56b07c8ff68a4966307b1869f0b8f57ea080 +MbedTLS.v2.24.0+4.aarch64-linux-gnu.tar.gz/md5/11400a06c3373fdbf984d26b33ac47fd +MbedTLS.v2.24.0+4.aarch64-linux-gnu.tar.gz/sha512/2b646dce93029a20629d2c958b1bfa6413329b995156ce45884372a97f1ed2ff5a27a96fcef32757f21e875283614b3483b845c107bb3c56166260af47613b22 +MbedTLS.v2.24.0+4.aarch64-linux-musl.tar.gz/md5/f32638984793dd4bb8789333eafa66e6 +MbedTLS.v2.24.0+4.aarch64-linux-musl.tar.gz/sha512/3269acc4e0d3e9e65ecc0fd752d9fdfe7cb5e370611f4a715aed74b5a1aabefc6ecc4a4d71c55e0f1d0364bb00a570194e52e7af91d844228e6b5b9500ba253f +MbedTLS.v2.24.0+4.armv6l-linux-gnueabihf.tar.gz/md5/8ad16b5c1a6102ddf4dbbef125b368fa +MbedTLS.v2.24.0+4.armv6l-linux-gnueabihf.tar.gz/sha512/d153e6e5d3090638d3212cc0adbc73df7d4749ddaf6de8ceb3156b26aef4835da2737e1f1d5b91bb29a1ebe5ff232dc93d51847029323c93310d5bb3d69bfbcb +MbedTLS.v2.24.0+4.armv6l-linux-musleabihf.tar.gz/md5/bd6d8ad4f42d8c1398ac3d7a5cee5389 +MbedTLS.v2.24.0+4.armv6l-linux-musleabihf.tar.gz/sha512/1840ff6cb59e097f6cdf0a70bcc3f7155342f798eb5d6e78562e6b45fc93cd183490a3e17231af6a4c2743f516b2bc897e22c6d792882ad7930984b59f9a7215 +MbedTLS.v2.24.0+4.armv7l-linux-gnueabihf.tar.gz/md5/2f91e3945dec75e58c593c0d0e04dca9 +MbedTLS.v2.24.0+4.armv7l-linux-gnueabihf.tar.gz/sha512/ff1a1df04ff89e2f9d278bd99b764f71da8c9eec8cd06feb4d48f58321c29bcb27e3bb5bdfd9fad313b22b8c7b55ebd9d2ed8a668bf807e4eb8a1be8c7a834d2 +MbedTLS.v2.24.0+4.armv7l-linux-musleabihf.tar.gz/md5/7fc7e8b68767c1b43c4f4d3a42050943 +MbedTLS.v2.24.0+4.armv7l-linux-musleabihf.tar.gz/sha512/d1ac843a6916b1f8e1c048a7347e3a14c46d1e81becb0ee62d25de6de32cda43c22546d93b1c922f3ceee5c5a5c7f07453e078f5d741bab0f6b6a0eb420c0ce1 +MbedTLS.v2.24.0+4.i686-linux-gnu.tar.gz/md5/969b6f461fc1b7bc7dd6265dfa63131a +MbedTLS.v2.24.0+4.i686-linux-gnu.tar.gz/sha512/ae0c2d3a0fa1b0eecf33356176c1a2bdf5ada09dae7afda6ef1d512c4ad42d17eac0f709539c22b3594bff2128f24e308a5b390e53af93ec50e2780ef079902e +MbedTLS.v2.24.0+4.i686-linux-musl.tar.gz/md5/0541dcd8779aedafdf4e3f6390ac4a6b +MbedTLS.v2.24.0+4.i686-linux-musl.tar.gz/sha512/299544cf4d7f94095bae946e2029307077b60cbdb77919650f8965d7c955ce8e8dfcdde287cbaa27d40e5e02cc8a669f0c5903e18e576478a6a956a95ae527fe +MbedTLS.v2.24.0+4.i686-w64-mingw32.tar.gz/md5/ec2140c28f5f7c156b8395034a1dcef0 +MbedTLS.v2.24.0+4.i686-w64-mingw32.tar.gz/sha512/7dbf759281bc9945a83314c7a941875c5f3dd29ab0657f44a04dc6f8dab00b5496e4cffa1400317b6381542351266c9563eb0bba7a44eb9fdb51e65e0b3b07d2 +MbedTLS.v2.24.0+4.powerpc64le-linux-gnu.tar.gz/md5/425be7f5cddab06e2f55162804357fe9 +MbedTLS.v2.24.0+4.powerpc64le-linux-gnu.tar.gz/sha512/4350f86366c39e5f464fa73672d570a245189427aa7afefa72f82d6c3a825a710eb55a961007747f2a8f62d60ef3f35b0fc50c6023f444eed42f261a3556f825 +MbedTLS.v2.24.0+4.x86_64-apple-darwin.tar.gz/md5/184a1894ffdb536be46bdb74abd281d4 +MbedTLS.v2.24.0+4.x86_64-apple-darwin.tar.gz/sha512/8d7011b5f71756cec44deea8dd32497d485a0ae4beb57583a45143e9d6e0f3db7bf2d8178f7c0b59e86f3dddce901e1fcc4fd3ba0d31f232d968bbbbe5f5fdd8 +MbedTLS.v2.24.0+4.x86_64-linux-gnu.tar.gz/md5/b4f4793e8d717f69ab437b649aa84218 +MbedTLS.v2.24.0+4.x86_64-linux-gnu.tar.gz/sha512/7ac6c551c1a7563a59e5d4d8fe9286bc3ab29c58aab510e27a84d7b304c6f3ea1e875999a158dd0dd639cc63e77b11e915c4ac5b5596ca6fda4b17274725998b +MbedTLS.v2.24.0+4.x86_64-linux-musl.tar.gz/md5/1d5f06af710f8e0009550763e5698123 +MbedTLS.v2.24.0+4.x86_64-linux-musl.tar.gz/sha512/cff4c596b9498d7e7e0cedcd17c6021fa161614d183c767209faef2926a31b2859ce237502ef774ac3e3bc37006c6651b9fd912360e19099d1c70cfafa2ed4fe +MbedTLS.v2.24.0+4.x86_64-unknown-freebsd.tar.gz/md5/f65a6c7d7fbe4db90622300add4522c0 +MbedTLS.v2.24.0+4.x86_64-unknown-freebsd.tar.gz/sha512/0f5e67293d5d7818ed68028cbd4207ebcb058829199b3a0b442e9672e079ab74c689b9399a3a09ea87a9818a85adc9623235557818f89a28ae9b48be33fb16bb +MbedTLS.v2.24.0+4.x86_64-w64-mingw32.tar.gz/md5/91161dd9cf7eb60f46c8c538c22f29db +MbedTLS.v2.24.0+4.x86_64-w64-mingw32.tar.gz/sha512/732e72fed17fb40537edee9600c5b8459f31c667819eacfb3e6c87960b913044282b017f1ad472c5ef8bc91e2bbccee7b5ca56f6d082c39c4090d04f37954839 diff --git a/deps/mbedtls.mk b/deps/mbedtls.mk index 83085ed2d2709..e59519008232a 100644 --- a/deps/mbedtls.mk +++ b/deps/mbedtls.mk @@ -39,8 +39,29 @@ $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-cmake-findpy.patch-applied: $(SRCCACHE)/$(MBE patch -p1 -f < $(SRCDIR)/patches/mbedtls-cmake-findpy.patch echo 1 > $@ +$(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-07-1.patch-applied: $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-cmake-findpy.patch-applied + # Apply backported set of patches for MbedTLS security issue first fixed in 2.27.0 + cd $(SRCCACHE)/$(MBEDTLS_SRC) && \ + patch -p1 -f < $(SRCDIR)/patches/mbedtls-security-advisory-2021-07-1.patch + echo 1 > $@ + +$(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-07-2.patch-applied: $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-07-1.patch-applied + # Apply backported set of patches for MbedTLS security issue first fixed in 2.27.0 + cd $(SRCCACHE)/$(MBEDTLS_SRC) && \ + patch -p1 -f < $(SRCDIR)/patches/mbedtls-security-advisory-2021-07-2.patch + echo 1 > $@ + +$(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-12.patch-applied: $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-07-2.patch-applied + # Apply backported set of patches for MbedTLS security issue first fixed in 2.28.0 + cd $(SRCCACHE)/$(MBEDTLS_SRC) && \ + patch -p1 -f < $(SRCDIR)/patches/mbedtls-security-advisory-2021-12.patch + echo 1 > $@ + $(BUILDDIR)/$(MBEDTLS_SRC)/build-configured: \ - $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-cmake-findpy.patch-applied + $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-cmake-findpy.patch-applied \ + $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-07-1.patch-applied \ + $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-07-2.patch-applied \ + $(SRCCACHE)/$(MBEDTLS_SRC)/mbedtls-security-advisory-2021-12.patch-applied $(BUILDDIR)/$(MBEDTLS_SRC)/build-configured: $(SRCCACHE)/$(MBEDTLS_SRC)/source-extracted mkdir -p $(dir $@) diff --git a/deps/patches/mbedtls-security-advisory-2021-07-1.patch b/deps/patches/mbedtls-security-advisory-2021-07-1.patch new file mode 100644 index 0000000000000..6c4d95b49c6d9 --- /dev/null +++ b/deps/patches/mbedtls-security-advisory-2021-07-1.patch @@ -0,0 +1,301 @@ +commit 0d11b3b4a56ba3055f2c977375f9149c6da9b823 +Author: Manuel Pégourié-Gonnard +Date: Tue Mar 9 11:22:20 2021 +0100 + + Use constant-time look-up for modular exponentiation + + Signed-off-by: Manuel Pégourié-Gonnard + + Avoid using == for sensitive comparisons + + mbedtls_mpi_cf_bool_eq() is a verbatim copy of mbedtls_ssl_cf_bool_eq() + + Deduplication will be part of a future task. + + Signed-off-by: Manuel Pégourié-Gonnard + + Use bit operations for mpi_safe_cond_assign() + + - copied limbs + - sign + - cleared limbs + + Signed-off-by: Manuel Pégourié-Gonnard + + Use bit operations for mpi_safe_cond_swap() + + Unrelated to RSA (only used in ECP), but while improving one + mbedtls_safe_cond_xxx function, let's improve the other as well. + + Signed-off-by: Manuel Pégourié-Gonnard + + Avoid UB caused by conversion to int + + Signed-off-by: Manuel Pégourié-Gonnard + + Simplify sign selection + + Signed-off-by: Manuel Pégourié-Gonnard + + Silence MSVC type conversion warnings + + Signed-off-by: Manuel Pégourié-Gonnard + +diff --git a/library/bignum.c b/library/bignum.c +index 9325632b4..f8754284d 100644 +--- a/library/bignum.c ++++ b/library/bignum.c +@@ -237,6 +237,36 @@ void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y ) + memcpy( Y, &T, sizeof( mbedtls_mpi ) ); + } + ++/** ++ * Select between two sign values in constant-time. ++ * ++ * This is functionally equivalent to second ? a : b but uses only bit ++ * operations in order to avoid branches. ++ * ++ * \param[in] a The first sign; must be either +1 or -1. ++ * \param[in] b The second sign; must be either +1 or -1. ++ * \param[in] second Must be either 1 (return b) or 0 (return a). ++ * ++ * \return The selected sign value. ++ */ ++static int mpi_safe_cond_select_sign( int a, int b, unsigned char second ) ++{ ++ /* In order to avoid questions about what we can reasonnably assume about ++ * the representations of signed integers, move everything to unsigned ++ * by taking advantage of the fact that a and b are either +1 or -1. */ ++ unsigned ua = a + 1; ++ unsigned ub = b + 1; ++ ++ /* second was 0 or 1, mask is 0 or 2 as are ua and ub */ ++ const unsigned mask = second << 1; ++ ++ /* select ua or ub */ ++ unsigned ur = ( ua & ~mask ) | ( ub & mask ); ++ ++ /* ur is now 0 or 2, convert back to -1 or +1 */ ++ return( (int) ur - 1 ); ++} ++ + /* + * Conditionally assign dest = src, without leaking information + * about whether the assignment was made or not. +@@ -249,8 +279,23 @@ static void mpi_safe_cond_assign( size_t n, + unsigned char assign ) + { + size_t i; ++ ++ /* MSVC has a warning about unary minus on unsigned integer types, ++ * but this is well-defined and precisely what we want to do here. */ ++#if defined(_MSC_VER) ++#pragma warning( push ) ++#pragma warning( disable : 4146 ) ++#endif ++ ++ /* all-bits 1 if assign is 1, all-bits 0 if assign is 0 */ ++ const mbedtls_mpi_uint mask = -assign; ++ ++#if defined(_MSC_VER) ++#pragma warning( pop ) ++#endif ++ + for( i = 0; i < n; i++ ) +- dest[i] = dest[i] * ( 1 - assign ) + src[i] * assign; ++ dest[i] = ( src[i] & mask ) | ( dest[i] & ~mask ); + } + + /* +@@ -262,20 +307,34 @@ int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned + { + int ret = 0; + size_t i; ++ mbedtls_mpi_uint limb_mask; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( Y != NULL ); + ++ /* MSVC has a warning about unary minus on unsigned integer types, ++ * but this is well-defined and precisely what we want to do here. */ ++#if defined(_MSC_VER) ++#pragma warning( push ) ++#pragma warning( disable : 4146 ) ++#endif ++ + /* make sure assign is 0 or 1 in a time-constant manner */ + assign = (assign | (unsigned char)-assign) >> 7; ++ /* all-bits 1 if assign is 1, all-bits 0 if assign is 0 */ ++ limb_mask = -assign; ++ ++#if defined(_MSC_VER) ++#pragma warning( pop ) ++#endif + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) ); + +- X->s = X->s * ( 1 - assign ) + Y->s * assign; ++ X->s = mpi_safe_cond_select_sign( X->s, Y->s, assign ); + + mpi_safe_cond_assign( Y->n, X->p, Y->p, assign ); + + for( i = Y->n; i < X->n; i++ ) +- X->p[i] *= ( 1 - assign ); ++ X->p[i] &= ~limb_mask; + + cleanup: + return( ret ); +@@ -291,6 +350,7 @@ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char sw + { + int ret, s; + size_t i; ++ mbedtls_mpi_uint limb_mask; + mbedtls_mpi_uint tmp; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( Y != NULL ); +@@ -298,22 +358,35 @@ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char sw + if( X == Y ) + return( 0 ); + ++ /* MSVC has a warning about unary minus on unsigned integer types, ++ * but this is well-defined and precisely what we want to do here. */ ++#if defined(_MSC_VER) ++#pragma warning( push ) ++#pragma warning( disable : 4146 ) ++#endif ++ + /* make sure swap is 0 or 1 in a time-constant manner */ + swap = (swap | (unsigned char)-swap) >> 7; ++ /* all-bits 1 if swap is 1, all-bits 0 if swap is 0 */ ++ limb_mask = -swap; ++ ++#if defined(_MSC_VER) ++#pragma warning( pop ) ++#endif + + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( Y, X->n ) ); + + s = X->s; +- X->s = X->s * ( 1 - swap ) + Y->s * swap; +- Y->s = Y->s * ( 1 - swap ) + s * swap; ++ X->s = mpi_safe_cond_select_sign( X->s, Y->s, swap ); ++ Y->s = mpi_safe_cond_select_sign( Y->s, s, swap ); + + + for( i = 0; i < X->n; i++ ) + { + tmp = X->p[i]; +- X->p[i] = X->p[i] * ( 1 - swap ) + Y->p[i] * swap; +- Y->p[i] = Y->p[i] * ( 1 - swap ) + tmp * swap; ++ X->p[i] = ( X->p[i] & ~limb_mask ) | ( Y->p[i] & limb_mask ); ++ Y->p[i] = ( Y->p[i] & ~limb_mask ) | ( tmp & limb_mask ); + } + + cleanup: +@@ -2089,6 +2162,71 @@ static void mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, + mpi_montmul( A, &U, N, mm, T ); + } + ++/* ++ * Constant-flow boolean "equal" comparison: ++ * return x == y ++ * ++ * This function can be used to write constant-time code by replacing branches ++ * with bit operations - it can be used in conjunction with ++ * mbedtls_ssl_cf_mask_from_bit(). ++ * ++ * This function is implemented without using comparison operators, as those ++ * might be translated to branches by some compilers on some platforms. ++ */ ++static size_t mbedtls_mpi_cf_bool_eq( size_t x, size_t y ) ++{ ++ /* diff = 0 if x == y, non-zero otherwise */ ++ const size_t diff = x ^ y; ++ ++ /* MSVC has a warning about unary minus on unsigned integer types, ++ * but this is well-defined and precisely what we want to do here. */ ++#if defined(_MSC_VER) ++#pragma warning( push ) ++#pragma warning( disable : 4146 ) ++#endif ++ ++ /* diff_msb's most significant bit is equal to x != y */ ++ const size_t diff_msb = ( diff | -diff ); ++ ++#if defined(_MSC_VER) ++#pragma warning( pop ) ++#endif ++ ++ /* diff1 = (x != y) ? 1 : 0 */ ++ const size_t diff1 = diff_msb >> ( sizeof( diff_msb ) * 8 - 1 ); ++ ++ return( 1 ^ diff1 ); ++} ++ ++/** ++ * Select an MPI from a table without leaking the index. ++ * ++ * This is functionally equivalent to mbedtls_mpi_copy(R, T[idx]) except it ++ * reads the entire table in order to avoid leaking the value of idx to an ++ * attacker able to observe memory access patterns. ++ * ++ * \param[out] R Where to write the selected MPI. ++ * \param[in] T The table to read from. ++ * \param[in] T_size The number of elements in the table. ++ * \param[in] idx The index of the element to select; ++ * this must satisfy 0 <= idx < T_size. ++ * ++ * \return \c 0 on success, or a negative error code. ++ */ ++static int mpi_select( mbedtls_mpi *R, const mbedtls_mpi *T, size_t T_size, size_t idx ) ++{ ++ int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; ++ ++ for( size_t i = 0; i < T_size; i++ ) ++ { ++ MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( R, &T[i], ++ (unsigned char) mbedtls_mpi_cf_bool_eq( i, idx ) ) ); ++ } ++ ++cleanup: ++ return( ret ); ++} ++ + /* + * Sliding-window exponentiation: X = A^E mod N (HAC 14.85) + */ +@@ -2101,7 +2239,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, + size_t i, j, nblimbs; + size_t bufsize, nbits; + mbedtls_mpi_uint ei, mm, state; +- mbedtls_mpi RR, T, W[ 2 << MBEDTLS_MPI_WINDOW_SIZE ], Apos; ++ mbedtls_mpi RR, T, W[ 1 << MBEDTLS_MPI_WINDOW_SIZE ], WW, Apos; + int neg; + + MPI_VALIDATE_RET( X != NULL ); +@@ -2121,6 +2259,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, + mpi_montg_init( &mm, N ); + mbedtls_mpi_init( &RR ); mbedtls_mpi_init( &T ); + mbedtls_mpi_init( &Apos ); ++ mbedtls_mpi_init( &WW ); + memset( W, 0, sizeof( W ) ); + + i = mbedtls_mpi_bitlen( E ); +@@ -2261,7 +2400,8 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, + /* + * X = X * W[wbits] R^-1 mod N + */ +- mpi_montmul( X, &W[wbits], N, mm, &T ); ++ MBEDTLS_MPI_CHK( mpi_select( &WW, W, (size_t) 1 << wsize, wbits ) ); ++ mpi_montmul( X, &WW, N, mm, &T ); + + state--; + nbits = 0; +@@ -2299,6 +2439,7 @@ cleanup: + mbedtls_mpi_free( &W[i] ); + + mbedtls_mpi_free( &W[1] ); mbedtls_mpi_free( &T ); mbedtls_mpi_free( &Apos ); ++ mbedtls_mpi_free( &WW ); + + if( _RR == NULL || _RR->p == NULL ) + mbedtls_mpi_free( &RR ); diff --git a/deps/patches/mbedtls-security-advisory-2021-07-2.patch b/deps/patches/mbedtls-security-advisory-2021-07-2.patch new file mode 100644 index 0000000000000..9b2a289038478 --- /dev/null +++ b/deps/patches/mbedtls-security-advisory-2021-07-2.patch @@ -0,0 +1,1377 @@ +commit c8e7f13258d5966807b44a797047812765ec7a4a +Author: Manuel Pégourié-Gonnard +Date: Wed Jun 23 10:14:58 2021 +0200 + + Reject low-order points on Curve25519 early + + We were already rejecting them at the end, due to the fact that with the + usual (x, z) formulas they lead to the result (0, 0) so when we want to + normalize at the end, trying to compute the modular inverse of z will + give an error. + + If we wanted to support those points, we'd a special case in + ecp_normalize_mxz(). But it's actually permitted by all sources + (RFC 7748 say we MAY reject 0 as a result) and recommended by some to + reject those points (either to ensure contributory behaviour, or to + protect against timing attack when the underlying field arithmetic is + not constant-time). + + Since our field arithmetic is indeed not constant-time, let's reject + those points before they get mixed with sensitive data (in + ecp_mul_mxz()), in order to avoid exploitable leaks caused by the + special cases they would trigger. (See the "May the Fourth" paper + https://eprint.iacr.org/2017/806.pdf) + + Signed-off-by: Manuel Pégourié-Gonnard + + Add test for check_pubkey for x25519 + + Signed-off-by: Manuel Pégourié-Gonnard + + Use a more compact encoding of bad points + + Base 10 is horrible, base 256 is much better. + + Signed-off-by: Manuel Pégourié-Gonnard + + Use more compact encoding of Montgomery curve constants + + Base 256 beats base 16. + + Signed-off-by: Manuel Pégourié-Gonnard + + Avoid complaints about undeclared non-static symbols + + Clang was complaining and check-names.sh too + + This only duplicates macros, so no impact on code size. In 3.0 we can + probably avoid the duplication by using an internal header under + library/ but this won't work for 2.16. + + Signed-off-by: Manuel Pégourié-Gonnard + + Prevent memory leak in ecp_check_pubkey_x25519() + + Signed-off-by: Janos Follath + + Remove redundant ecp_check_pub() tests + + Signed-off-by: Janos Follath + + Move mpi constant macros to bn_mul.h + + Signed-off-by: Janos Follath + + Use mbedtls_mpi_lset() more + + Signed-off-by: Janos Follath + + Add DoS test case for ecp_check_pub + + A test case for which the loop would take practically forever if it was + reached. The point would be to validate that the loop is not reached. + The test case should cause the CI to time out if starting with the + current code, ecp_check_pubkey_mx() was changed to call + ecp_check_pubkey_x25519() first and run the mbedtls_mpi_size(() test + afterwards, which would make no semantic difference in terms of memory + contents when the function returns, but would open the way for a DoS. + + Signed-off-by: Janos Follath + + Reject low-order points on Curve448 early + + We were already rejecting them at the end, due to the fact that with the + usual (x, z) formulas they lead to the result (0, 0) so when we want to + normalize at the end, trying to compute the modular inverse of z will + give an error. + + If we wanted to support those points, we'd a special case in + ecp_normalize_mxz(). But it's actually permitted by all sources (RFC + 7748 say we MAY reject 0 as a result) and recommended by some to reject + those points (either to ensure contributory behaviour, or to protect + against timing attack when the underlying field arithmetic is not + constant-time). + + Since our field arithmetic is indeed not constant-time, let's reject + those points before they get mixed with sensitive data (in + ecp_mul_mxz()), in order to avoid exploitable leaks caused by the + special cases they would trigger. (See the "May the Fourth" paper + https://eprint.iacr.org/2017/806.pdf) + + Signed-off-by: Janos Follath + + Add ecp_check_pub tests for Curve 448 + + Signed-off-by: Janos Follath + + Fix ecp_check_pub() test cases + + Negative x coordinate was tested with the value -1. It happens to be one + of the low order points both for Curve25519 and Curve448 and might be + rejected because of that and not because it is negative. Make sure that + x < 0 is the only plausible reason for the point to be rejected. + + Signed-off-by: Janos Follath + + Add prefix to BYTES_TO_T_UINT_* + + These macros were moved into a header and now check-names.sh is failing. + Add an MBEDTLS_ prefix to the macro names to make it pass. + + Signed-off-by: Janos Follath + +diff --git a/include/mbedtls/bn_mul.h b/include/mbedtls/bn_mul.h +index 17d057f3a..a0fa67740 100644 +--- a/include/mbedtls/bn_mul.h ++++ b/include/mbedtls/bn_mul.h +@@ -44,6 +44,46 @@ + + #include "mbedtls/bignum.h" + ++ ++/* ++ * Conversion macros for embedded constants: ++ * build lists of mbedtls_mpi_uint's from lists of unsigned char's grouped by 8, 4 or 2 ++ */ ++#if defined(MBEDTLS_HAVE_INT32) ++ ++#define MBEDTLS_BYTES_TO_T_UINT_4( a, b, c, d ) \ ++ ( (mbedtls_mpi_uint) (a) << 0 ) | \ ++ ( (mbedtls_mpi_uint) (b) << 8 ) | \ ++ ( (mbedtls_mpi_uint) (c) << 16 ) | \ ++ ( (mbedtls_mpi_uint) (d) << 24 ) ++ ++#define MBEDTLS_BYTES_TO_T_UINT_2( a, b ) \ ++ MBEDTLS_BYTES_TO_T_UINT_4( a, b, 0, 0 ) ++ ++#define MBEDTLS_BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ ++ MBEDTLS_BYTES_TO_T_UINT_4( a, b, c, d ), \ ++ MBEDTLS_BYTES_TO_T_UINT_4( e, f, g, h ) ++ ++#else /* 64-bits */ ++ ++#define MBEDTLS_BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ ++ ( (mbedtls_mpi_uint) (a) << 0 ) | \ ++ ( (mbedtls_mpi_uint) (b) << 8 ) | \ ++ ( (mbedtls_mpi_uint) (c) << 16 ) | \ ++ ( (mbedtls_mpi_uint) (d) << 24 ) | \ ++ ( (mbedtls_mpi_uint) (e) << 32 ) | \ ++ ( (mbedtls_mpi_uint) (f) << 40 ) | \ ++ ( (mbedtls_mpi_uint) (g) << 48 ) | \ ++ ( (mbedtls_mpi_uint) (h) << 56 ) ++ ++#define MBEDTLS_BYTES_TO_T_UINT_4( a, b, c, d ) \ ++ MBEDTLS_BYTES_TO_T_UINT_8( a, b, c, d, 0, 0, 0, 0 ) ++ ++#define MBEDTLS_BYTES_TO_T_UINT_2( a, b ) \ ++ MBEDTLS_BYTES_TO_T_UINT_8( a, b, 0, 0, 0, 0, 0, 0 ) ++ ++#endif /* bits in mbedtls_mpi_uint */ ++ + #if defined(MBEDTLS_HAVE_ASM) + + #ifndef asm +diff --git a/library/ecp.c b/library/ecp.c +index 5d00de5cf..f79a68f69 100644 +--- a/library/ecp.c ++++ b/library/ecp.c +@@ -76,6 +76,7 @@ + #include "mbedtls/threading.h" + #include "mbedtls/platform_util.h" + #include "mbedtls/error.h" ++#include "mbedtls/bn_mul.h" + + #include + +@@ -2912,6 +2913,95 @@ int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + #endif /* MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED */ + + #if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED) ++#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) ++#define ECP_MPI_INIT(s, n, p) {s, (n), (mbedtls_mpi_uint *)(p)} ++#define ECP_MPI_INIT_ARRAY(x) \ ++ ECP_MPI_INIT(1, sizeof(x) / sizeof(mbedtls_mpi_uint), x) ++/* ++ * Constants for the two points other than 0, 1, -1 (mod p) in ++ * https://cr.yp.to/ecdh.html#validate ++ * See ecp_check_pubkey_x25519(). ++ */ ++static const mbedtls_mpi_uint x25519_bad_point_1[] = { ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, 0xc4, 0x6a ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00 ), ++}; ++static const mbedtls_mpi_uint x25519_bad_point_2[] = { ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x5f, 0x9c, 0x95, 0xbc, 0xa3, 0x50, 0x8c, 0x24 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xb1, 0xd0, 0xb1, 0x55, 0x9c, 0x83, 0xef, 0x5b ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x04, 0x44, 0x5c, 0xc4, 0x58, 0x1c, 0x8e, 0x86 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xd8, 0x22, 0x4e, 0xdd, 0xd0, 0x9f, 0x11, 0x57 ), ++}; ++static const mbedtls_mpi ecp_x25519_bad_point_1 = ECP_MPI_INIT_ARRAY( ++ x25519_bad_point_1 ); ++static const mbedtls_mpi ecp_x25519_bad_point_2 = ECP_MPI_INIT_ARRAY( ++ x25519_bad_point_2 ); ++#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ ++ ++/* ++ * Check that the input point is not one of the low-order points. ++ * This is recommended by the "May the Fourth" paper: ++ * https://eprint.iacr.org/2017/806.pdf ++ * Those points are never sent by an honest peer. ++ */ ++static int ecp_check_bad_points_mx( const mbedtls_mpi *X, const mbedtls_mpi *P, ++ const mbedtls_ecp_group_id grp_id ) ++{ ++ int ret; ++ mbedtls_mpi XmP; ++ ++ mbedtls_mpi_init( &XmP ); ++ ++ /* Reduce X mod P so that we only need to check values less than P. ++ * We know X < 2^256 so we can proceed by subtraction. */ ++ MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &XmP, X ) ); ++ while( mbedtls_mpi_cmp_mpi( &XmP, P ) >= 0 ) ++ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &XmP, &XmP, P ) ); ++ ++ /* Check against the known bad values that are less than P. For Curve448 ++ * these are 0, 1 and -1. For Curve25519 we check the values less than P ++ * from the following list: https://cr.yp.to/ecdh.html#validate */ ++ if( mbedtls_mpi_cmp_int( &XmP, 1 ) <= 0 ) /* takes care of 0 and 1 */ ++ { ++ ret = MBEDTLS_ERR_ECP_INVALID_KEY; ++ goto cleanup; ++ } ++ ++#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) ++ if( grp_id == MBEDTLS_ECP_DP_CURVE25519 ) ++ { ++ if( mbedtls_mpi_cmp_mpi( &XmP, &ecp_x25519_bad_point_1 ) == 0 ) ++ { ++ ret = MBEDTLS_ERR_ECP_INVALID_KEY; ++ goto cleanup; ++ } ++ ++ if( mbedtls_mpi_cmp_mpi( &XmP, &ecp_x25519_bad_point_2 ) == 0 ) ++ { ++ ret = MBEDTLS_ERR_ECP_INVALID_KEY; ++ goto cleanup; ++ } ++ } ++#endif ++ ++ /* Final check: check if XmP + 1 is P (final because it changes XmP!) */ ++ MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &XmP, &XmP, 1 ) ); ++ if( mbedtls_mpi_cmp_mpi( &XmP, P ) == 0 ) ++ { ++ ret = MBEDTLS_ERR_ECP_INVALID_KEY; ++ goto cleanup; ++ } ++ ++ ret = 0; ++ ++cleanup: ++ mbedtls_mpi_free( &XmP ); ++ ++ return( ret ); ++} ++ + /* + * Check validity of a public key for Montgomery curves with x-only schemes + */ +@@ -2923,7 +3013,13 @@ static int ecp_check_pubkey_mx( const mbedtls_ecp_group *grp, const mbedtls_ecp_ + if( mbedtls_mpi_size( &pt->X ) > ( grp->nbits + 7 ) / 8 ) + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + +- return( 0 ); ++ /* Implicit in all standards (as they don't consider negative numbers): ++ * X must be non-negative. This is normally ensured by the way it's ++ * encoded for transmission, but let's be extra sure. */ ++ if( mbedtls_mpi_cmp_int( &pt->X, 0 ) < 0 ) ++ return( MBEDTLS_ERR_ECP_INVALID_KEY ); ++ ++ return( ecp_check_bad_points_mx( &pt->X, &grp->P, grp->id ) ); + } + #endif /* MBEDTLS_ECP_MONTGOMERY_ENABLED */ + +diff --git a/library/ecp_curves.c b/library/ecp_curves.c +index 05df307cb..136609b78 100644 +--- a/library/ecp_curves.c ++++ b/library/ecp_curves.c +@@ -24,6 +24,7 @@ + #include "mbedtls/ecp.h" + #include "mbedtls/platform_util.h" + #include "mbedtls/error.h" ++#include "mbedtls/bn_mul.h" + + #include + +@@ -40,44 +41,10 @@ + #define inline __inline + #endif + +-/* +- * Conversion macros for embedded constants: +- * build lists of mbedtls_mpi_uint's from lists of unsigned char's grouped by 8, 4 or 2 +- */ +-#if defined(MBEDTLS_HAVE_INT32) +- +-#define BYTES_TO_T_UINT_4( a, b, c, d ) \ +- ( (mbedtls_mpi_uint) (a) << 0 ) | \ +- ( (mbedtls_mpi_uint) (b) << 8 ) | \ +- ( (mbedtls_mpi_uint) (c) << 16 ) | \ +- ( (mbedtls_mpi_uint) (d) << 24 ) +- +-#define BYTES_TO_T_UINT_2( a, b ) \ +- BYTES_TO_T_UINT_4( a, b, 0, 0 ) +- +-#define BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ +- BYTES_TO_T_UINT_4( a, b, c, d ), \ +- BYTES_TO_T_UINT_4( e, f, g, h ) +- +-#else /* 64-bits */ +- +-#define BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ +- ( (mbedtls_mpi_uint) (a) << 0 ) | \ +- ( (mbedtls_mpi_uint) (b) << 8 ) | \ +- ( (mbedtls_mpi_uint) (c) << 16 ) | \ +- ( (mbedtls_mpi_uint) (d) << 24 ) | \ +- ( (mbedtls_mpi_uint) (e) << 32 ) | \ +- ( (mbedtls_mpi_uint) (f) << 40 ) | \ +- ( (mbedtls_mpi_uint) (g) << 48 ) | \ +- ( (mbedtls_mpi_uint) (h) << 56 ) ++#define ECP_MPI_INIT(s, n, p) {s, (n), (mbedtls_mpi_uint *)(p)} + +-#define BYTES_TO_T_UINT_4( a, b, c, d ) \ +- BYTES_TO_T_UINT_8( a, b, c, d, 0, 0, 0, 0 ) +- +-#define BYTES_TO_T_UINT_2( a, b ) \ +- BYTES_TO_T_UINT_8( a, b, 0, 0, 0, 0, 0, 0 ) +- +-#endif /* bits in mbedtls_mpi_uint */ ++#define ECP_MPI_INIT_ARRAY(x) \ ++ ECP_MPI_INIT(1, sizeof(x) / sizeof(mbedtls_mpi_uint), x) + + /* + * Note: the constants are in little-endian order +@@ -89,29 +56,29 @@ + */ + #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) + static const mbedtls_mpi_uint secp192r1_p[] = { +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + static const mbedtls_mpi_uint secp192r1_b[] = { +- BYTES_TO_T_UINT_8( 0xB1, 0xB9, 0x46, 0xC1, 0xEC, 0xDE, 0xB8, 0xFE ), +- BYTES_TO_T_UINT_8( 0x49, 0x30, 0x24, 0x72, 0xAB, 0xE9, 0xA7, 0x0F ), +- BYTES_TO_T_UINT_8( 0xE7, 0x80, 0x9C, 0xE5, 0x19, 0x05, 0x21, 0x64 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB1, 0xB9, 0x46, 0xC1, 0xEC, 0xDE, 0xB8, 0xFE ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x49, 0x30, 0x24, 0x72, 0xAB, 0xE9, 0xA7, 0x0F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE7, 0x80, 0x9C, 0xE5, 0x19, 0x05, 0x21, 0x64 ), + }; + static const mbedtls_mpi_uint secp192r1_gx[] = { +- BYTES_TO_T_UINT_8( 0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4 ), +- BYTES_TO_T_UINT_8( 0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C ), +- BYTES_TO_T_UINT_8( 0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18 ), + }; + static const mbedtls_mpi_uint secp192r1_gy[] = { +- BYTES_TO_T_UINT_8( 0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73 ), +- BYTES_TO_T_UINT_8( 0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63 ), +- BYTES_TO_T_UINT_8( 0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07 ), + }; + static const mbedtls_mpi_uint secp192r1_n[] = { +- BYTES_TO_T_UINT_8( 0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14 ), +- BYTES_TO_T_UINT_8( 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + #endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ + +@@ -120,34 +87,34 @@ static const mbedtls_mpi_uint secp192r1_n[] = { + */ + #if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) + static const mbedtls_mpi_uint secp224r1_p[] = { +- BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), +- BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), + }; + static const mbedtls_mpi_uint secp224r1_b[] = { +- BYTES_TO_T_UINT_8( 0xB4, 0xFF, 0x55, 0x23, 0x43, 0x39, 0x0B, 0x27 ), +- BYTES_TO_T_UINT_8( 0xBA, 0xD8, 0xBF, 0xD7, 0xB7, 0xB0, 0x44, 0x50 ), +- BYTES_TO_T_UINT_8( 0x56, 0x32, 0x41, 0xF5, 0xAB, 0xB3, 0x04, 0x0C ), +- BYTES_TO_T_UINT_4( 0x85, 0x0A, 0x05, 0xB4 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB4, 0xFF, 0x55, 0x23, 0x43, 0x39, 0x0B, 0x27 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xBA, 0xD8, 0xBF, 0xD7, 0xB7, 0xB0, 0x44, 0x50 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x56, 0x32, 0x41, 0xF5, 0xAB, 0xB3, 0x04, 0x0C ), ++ MBEDTLS_BYTES_TO_T_UINT_4( 0x85, 0x0A, 0x05, 0xB4 ), + }; + static const mbedtls_mpi_uint secp224r1_gx[] = { +- BYTES_TO_T_UINT_8( 0x21, 0x1D, 0x5C, 0x11, 0xD6, 0x80, 0x32, 0x34 ), +- BYTES_TO_T_UINT_8( 0x22, 0x11, 0xC2, 0x56, 0xD3, 0xC1, 0x03, 0x4A ), +- BYTES_TO_T_UINT_8( 0xB9, 0x90, 0x13, 0x32, 0x7F, 0xBF, 0xB4, 0x6B ), +- BYTES_TO_T_UINT_4( 0xBD, 0x0C, 0x0E, 0xB7 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x21, 0x1D, 0x5C, 0x11, 0xD6, 0x80, 0x32, 0x34 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x22, 0x11, 0xC2, 0x56, 0xD3, 0xC1, 0x03, 0x4A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB9, 0x90, 0x13, 0x32, 0x7F, 0xBF, 0xB4, 0x6B ), ++ MBEDTLS_BYTES_TO_T_UINT_4( 0xBD, 0x0C, 0x0E, 0xB7 ), + }; + static const mbedtls_mpi_uint secp224r1_gy[] = { +- BYTES_TO_T_UINT_8( 0x34, 0x7E, 0x00, 0x85, 0x99, 0x81, 0xD5, 0x44 ), +- BYTES_TO_T_UINT_8( 0x64, 0x47, 0x07, 0x5A, 0xA0, 0x75, 0x43, 0xCD ), +- BYTES_TO_T_UINT_8( 0xE6, 0xDF, 0x22, 0x4C, 0xFB, 0x23, 0xF7, 0xB5 ), +- BYTES_TO_T_UINT_4( 0x88, 0x63, 0x37, 0xBD ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x34, 0x7E, 0x00, 0x85, 0x99, 0x81, 0xD5, 0x44 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x64, 0x47, 0x07, 0x5A, 0xA0, 0x75, 0x43, 0xCD ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE6, 0xDF, 0x22, 0x4C, 0xFB, 0x23, 0xF7, 0xB5 ), ++ MBEDTLS_BYTES_TO_T_UINT_4( 0x88, 0x63, 0x37, 0xBD ), + }; + static const mbedtls_mpi_uint secp224r1_n[] = { +- BYTES_TO_T_UINT_8( 0x3D, 0x2A, 0x5C, 0x5C, 0x45, 0x29, 0xDD, 0x13 ), +- BYTES_TO_T_UINT_8( 0x3E, 0xF0, 0xB8, 0xE0, 0xA2, 0x16, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x3D, 0x2A, 0x5C, 0x5C, 0x45, 0x29, 0xDD, 0x13 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x3E, 0xF0, 0xB8, 0xE0, 0xA2, 0x16, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), + }; + #endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ + +@@ -156,34 +123,34 @@ static const mbedtls_mpi_uint secp224r1_n[] = { + */ + #if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + static const mbedtls_mpi_uint secp256r1_p[] = { +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), +- BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), +- BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + static const mbedtls_mpi_uint secp256r1_b[] = { +- BYTES_TO_T_UINT_8( 0x4B, 0x60, 0xD2, 0x27, 0x3E, 0x3C, 0xCE, 0x3B ), +- BYTES_TO_T_UINT_8( 0xF6, 0xB0, 0x53, 0xCC, 0xB0, 0x06, 0x1D, 0x65 ), +- BYTES_TO_T_UINT_8( 0xBC, 0x86, 0x98, 0x76, 0x55, 0xBD, 0xEB, 0xB3 ), +- BYTES_TO_T_UINT_8( 0xE7, 0x93, 0x3A, 0xAA, 0xD8, 0x35, 0xC6, 0x5A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x4B, 0x60, 0xD2, 0x27, 0x3E, 0x3C, 0xCE, 0x3B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF6, 0xB0, 0x53, 0xCC, 0xB0, 0x06, 0x1D, 0x65 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0x86, 0x98, 0x76, 0x55, 0xBD, 0xEB, 0xB3 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE7, 0x93, 0x3A, 0xAA, 0xD8, 0x35, 0xC6, 0x5A ), + }; + static const mbedtls_mpi_uint secp256r1_gx[] = { +- BYTES_TO_T_UINT_8( 0x96, 0xC2, 0x98, 0xD8, 0x45, 0x39, 0xA1, 0xF4 ), +- BYTES_TO_T_UINT_8( 0xA0, 0x33, 0xEB, 0x2D, 0x81, 0x7D, 0x03, 0x77 ), +- BYTES_TO_T_UINT_8( 0xF2, 0x40, 0xA4, 0x63, 0xE5, 0xE6, 0xBC, 0xF8 ), +- BYTES_TO_T_UINT_8( 0x47, 0x42, 0x2C, 0xE1, 0xF2, 0xD1, 0x17, 0x6B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x96, 0xC2, 0x98, 0xD8, 0x45, 0x39, 0xA1, 0xF4 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA0, 0x33, 0xEB, 0x2D, 0x81, 0x7D, 0x03, 0x77 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF2, 0x40, 0xA4, 0x63, 0xE5, 0xE6, 0xBC, 0xF8 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x47, 0x42, 0x2C, 0xE1, 0xF2, 0xD1, 0x17, 0x6B ), + }; + static const mbedtls_mpi_uint secp256r1_gy[] = { +- BYTES_TO_T_UINT_8( 0xF5, 0x51, 0xBF, 0x37, 0x68, 0x40, 0xB6, 0xCB ), +- BYTES_TO_T_UINT_8( 0xCE, 0x5E, 0x31, 0x6B, 0x57, 0x33, 0xCE, 0x2B ), +- BYTES_TO_T_UINT_8( 0x16, 0x9E, 0x0F, 0x7C, 0x4A, 0xEB, 0xE7, 0x8E ), +- BYTES_TO_T_UINT_8( 0x9B, 0x7F, 0x1A, 0xFE, 0xE2, 0x42, 0xE3, 0x4F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF5, 0x51, 0xBF, 0x37, 0x68, 0x40, 0xB6, 0xCB ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xCE, 0x5E, 0x31, 0x6B, 0x57, 0x33, 0xCE, 0x2B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x16, 0x9E, 0x0F, 0x7C, 0x4A, 0xEB, 0xE7, 0x8E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x9B, 0x7F, 0x1A, 0xFE, 0xE2, 0x42, 0xE3, 0x4F ), + }; + static const mbedtls_mpi_uint secp256r1_n[] = { +- BYTES_TO_T_UINT_8( 0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3 ), +- BYTES_TO_T_UINT_8( 0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + #endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ + +@@ -192,44 +159,44 @@ static const mbedtls_mpi_uint secp256r1_n[] = { + */ + #if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + static const mbedtls_mpi_uint secp384r1_p[] = { +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), +- BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + static const mbedtls_mpi_uint secp384r1_b[] = { +- BYTES_TO_T_UINT_8( 0xEF, 0x2A, 0xEC, 0xD3, 0xED, 0xC8, 0x85, 0x2A ), +- BYTES_TO_T_UINT_8( 0x9D, 0xD1, 0x2E, 0x8A, 0x8D, 0x39, 0x56, 0xC6 ), +- BYTES_TO_T_UINT_8( 0x5A, 0x87, 0x13, 0x50, 0x8F, 0x08, 0x14, 0x03 ), +- BYTES_TO_T_UINT_8( 0x12, 0x41, 0x81, 0xFE, 0x6E, 0x9C, 0x1D, 0x18 ), +- BYTES_TO_T_UINT_8( 0x19, 0x2D, 0xF8, 0xE3, 0x6B, 0x05, 0x8E, 0x98 ), +- BYTES_TO_T_UINT_8( 0xE4, 0xE7, 0x3E, 0xE2, 0xA7, 0x2F, 0x31, 0xB3 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xEF, 0x2A, 0xEC, 0xD3, 0xED, 0xC8, 0x85, 0x2A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x9D, 0xD1, 0x2E, 0x8A, 0x8D, 0x39, 0x56, 0xC6 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x5A, 0x87, 0x13, 0x50, 0x8F, 0x08, 0x14, 0x03 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x12, 0x41, 0x81, 0xFE, 0x6E, 0x9C, 0x1D, 0x18 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x19, 0x2D, 0xF8, 0xE3, 0x6B, 0x05, 0x8E, 0x98 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE4, 0xE7, 0x3E, 0xE2, 0xA7, 0x2F, 0x31, 0xB3 ), + }; + static const mbedtls_mpi_uint secp384r1_gx[] = { +- BYTES_TO_T_UINT_8( 0xB7, 0x0A, 0x76, 0x72, 0x38, 0x5E, 0x54, 0x3A ), +- BYTES_TO_T_UINT_8( 0x6C, 0x29, 0x55, 0xBF, 0x5D, 0xF2, 0x02, 0x55 ), +- BYTES_TO_T_UINT_8( 0x38, 0x2A, 0x54, 0x82, 0xE0, 0x41, 0xF7, 0x59 ), +- BYTES_TO_T_UINT_8( 0x98, 0x9B, 0xA7, 0x8B, 0x62, 0x3B, 0x1D, 0x6E ), +- BYTES_TO_T_UINT_8( 0x74, 0xAD, 0x20, 0xF3, 0x1E, 0xC7, 0xB1, 0x8E ), +- BYTES_TO_T_UINT_8( 0x37, 0x05, 0x8B, 0xBE, 0x22, 0xCA, 0x87, 0xAA ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB7, 0x0A, 0x76, 0x72, 0x38, 0x5E, 0x54, 0x3A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x6C, 0x29, 0x55, 0xBF, 0x5D, 0xF2, 0x02, 0x55 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x38, 0x2A, 0x54, 0x82, 0xE0, 0x41, 0xF7, 0x59 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x98, 0x9B, 0xA7, 0x8B, 0x62, 0x3B, 0x1D, 0x6E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x74, 0xAD, 0x20, 0xF3, 0x1E, 0xC7, 0xB1, 0x8E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x37, 0x05, 0x8B, 0xBE, 0x22, 0xCA, 0x87, 0xAA ), + }; + static const mbedtls_mpi_uint secp384r1_gy[] = { +- BYTES_TO_T_UINT_8( 0x5F, 0x0E, 0xEA, 0x90, 0x7C, 0x1D, 0x43, 0x7A ), +- BYTES_TO_T_UINT_8( 0x9D, 0x81, 0x7E, 0x1D, 0xCE, 0xB1, 0x60, 0x0A ), +- BYTES_TO_T_UINT_8( 0xC0, 0xB8, 0xF0, 0xB5, 0x13, 0x31, 0xDA, 0xE9 ), +- BYTES_TO_T_UINT_8( 0x7C, 0x14, 0x9A, 0x28, 0xBD, 0x1D, 0xF4, 0xF8 ), +- BYTES_TO_T_UINT_8( 0x29, 0xDC, 0x92, 0x92, 0xBF, 0x98, 0x9E, 0x5D ), +- BYTES_TO_T_UINT_8( 0x6F, 0x2C, 0x26, 0x96, 0x4A, 0xDE, 0x17, 0x36 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x5F, 0x0E, 0xEA, 0x90, 0x7C, 0x1D, 0x43, 0x7A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x9D, 0x81, 0x7E, 0x1D, 0xCE, 0xB1, 0x60, 0x0A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xC0, 0xB8, 0xF0, 0xB5, 0x13, 0x31, 0xDA, 0xE9 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x7C, 0x14, 0x9A, 0x28, 0xBD, 0x1D, 0xF4, 0xF8 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x29, 0xDC, 0x92, 0x92, 0xBF, 0x98, 0x9E, 0x5D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x6F, 0x2C, 0x26, 0x96, 0x4A, 0xDE, 0x17, 0x36 ), + }; + static const mbedtls_mpi_uint secp384r1_n[] = { +- BYTES_TO_T_UINT_8( 0x73, 0x29, 0xC5, 0xCC, 0x6A, 0x19, 0xEC, 0xEC ), +- BYTES_TO_T_UINT_8( 0x7A, 0xA7, 0xB0, 0x48, 0xB2, 0x0D, 0x1A, 0x58 ), +- BYTES_TO_T_UINT_8( 0xDF, 0x2D, 0x37, 0xF4, 0x81, 0x4D, 0x63, 0xC7 ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x73, 0x29, 0xC5, 0xCC, 0x6A, 0x19, 0xEC, 0xEC ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x7A, 0xA7, 0xB0, 0x48, 0xB2, 0x0D, 0x1A, 0x58 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xDF, 0x2D, 0x37, 0xF4, 0x81, 0x4D, 0x63, 0xC7 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + #endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ + +@@ -238,154 +205,154 @@ static const mbedtls_mpi_uint secp384r1_n[] = { + */ + #if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + static const mbedtls_mpi_uint secp521r1_p[] = { +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_2( 0xFF, 0x01 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0xFF, 0x01 ), + }; + static const mbedtls_mpi_uint secp521r1_b[] = { +- BYTES_TO_T_UINT_8( 0x00, 0x3F, 0x50, 0x6B, 0xD4, 0x1F, 0x45, 0xEF ), +- BYTES_TO_T_UINT_8( 0xF1, 0x34, 0x2C, 0x3D, 0x88, 0xDF, 0x73, 0x35 ), +- BYTES_TO_T_UINT_8( 0x07, 0xBF, 0xB1, 0x3B, 0xBD, 0xC0, 0x52, 0x16 ), +- BYTES_TO_T_UINT_8( 0x7B, 0x93, 0x7E, 0xEC, 0x51, 0x39, 0x19, 0x56 ), +- BYTES_TO_T_UINT_8( 0xE1, 0x09, 0xF1, 0x8E, 0x91, 0x89, 0xB4, 0xB8 ), +- BYTES_TO_T_UINT_8( 0xF3, 0x15, 0xB3, 0x99, 0x5B, 0x72, 0xDA, 0xA2 ), +- BYTES_TO_T_UINT_8( 0xEE, 0x40, 0x85, 0xB6, 0xA0, 0x21, 0x9A, 0x92 ), +- BYTES_TO_T_UINT_8( 0x1F, 0x9A, 0x1C, 0x8E, 0x61, 0xB9, 0x3E, 0x95 ), +- BYTES_TO_T_UINT_2( 0x51, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x3F, 0x50, 0x6B, 0xD4, 0x1F, 0x45, 0xEF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF1, 0x34, 0x2C, 0x3D, 0x88, 0xDF, 0x73, 0x35 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0xBF, 0xB1, 0x3B, 0xBD, 0xC0, 0x52, 0x16 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x7B, 0x93, 0x7E, 0xEC, 0x51, 0x39, 0x19, 0x56 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE1, 0x09, 0xF1, 0x8E, 0x91, 0x89, 0xB4, 0xB8 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF3, 0x15, 0xB3, 0x99, 0x5B, 0x72, 0xDA, 0xA2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xEE, 0x40, 0x85, 0xB6, 0xA0, 0x21, 0x9A, 0x92 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x1F, 0x9A, 0x1C, 0x8E, 0x61, 0xB9, 0x3E, 0x95 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x51, 0x00 ), + }; + static const mbedtls_mpi_uint secp521r1_gx[] = { +- BYTES_TO_T_UINT_8( 0x66, 0xBD, 0xE5, 0xC2, 0x31, 0x7E, 0x7E, 0xF9 ), +- BYTES_TO_T_UINT_8( 0x9B, 0x42, 0x6A, 0x85, 0xC1, 0xB3, 0x48, 0x33 ), +- BYTES_TO_T_UINT_8( 0xDE, 0xA8, 0xFF, 0xA2, 0x27, 0xC1, 0x1D, 0xFE ), +- BYTES_TO_T_UINT_8( 0x28, 0x59, 0xE7, 0xEF, 0x77, 0x5E, 0x4B, 0xA1 ), +- BYTES_TO_T_UINT_8( 0xBA, 0x3D, 0x4D, 0x6B, 0x60, 0xAF, 0x28, 0xF8 ), +- BYTES_TO_T_UINT_8( 0x21, 0xB5, 0x3F, 0x05, 0x39, 0x81, 0x64, 0x9C ), +- BYTES_TO_T_UINT_8( 0x42, 0xB4, 0x95, 0x23, 0x66, 0xCB, 0x3E, 0x9E ), +- BYTES_TO_T_UINT_8( 0xCD, 0xE9, 0x04, 0x04, 0xB7, 0x06, 0x8E, 0x85 ), +- BYTES_TO_T_UINT_2( 0xC6, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x66, 0xBD, 0xE5, 0xC2, 0x31, 0x7E, 0x7E, 0xF9 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x9B, 0x42, 0x6A, 0x85, 0xC1, 0xB3, 0x48, 0x33 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xDE, 0xA8, 0xFF, 0xA2, 0x27, 0xC1, 0x1D, 0xFE ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x59, 0xE7, 0xEF, 0x77, 0x5E, 0x4B, 0xA1 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xBA, 0x3D, 0x4D, 0x6B, 0x60, 0xAF, 0x28, 0xF8 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x21, 0xB5, 0x3F, 0x05, 0x39, 0x81, 0x64, 0x9C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x42, 0xB4, 0x95, 0x23, 0x66, 0xCB, 0x3E, 0x9E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xCD, 0xE9, 0x04, 0x04, 0xB7, 0x06, 0x8E, 0x85 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0xC6, 0x00 ), + }; + static const mbedtls_mpi_uint secp521r1_gy[] = { +- BYTES_TO_T_UINT_8( 0x50, 0x66, 0xD1, 0x9F, 0x76, 0x94, 0xBE, 0x88 ), +- BYTES_TO_T_UINT_8( 0x40, 0xC2, 0x72, 0xA2, 0x86, 0x70, 0x3C, 0x35 ), +- BYTES_TO_T_UINT_8( 0x61, 0x07, 0xAD, 0x3F, 0x01, 0xB9, 0x50, 0xC5 ), +- BYTES_TO_T_UINT_8( 0x40, 0x26, 0xF4, 0x5E, 0x99, 0x72, 0xEE, 0x97 ), +- BYTES_TO_T_UINT_8( 0x2C, 0x66, 0x3E, 0x27, 0x17, 0xBD, 0xAF, 0x17 ), +- BYTES_TO_T_UINT_8( 0x68, 0x44, 0x9B, 0x57, 0x49, 0x44, 0xF5, 0x98 ), +- BYTES_TO_T_UINT_8( 0xD9, 0x1B, 0x7D, 0x2C, 0xB4, 0x5F, 0x8A, 0x5C ), +- BYTES_TO_T_UINT_8( 0x04, 0xC0, 0x3B, 0x9A, 0x78, 0x6A, 0x29, 0x39 ), +- BYTES_TO_T_UINT_2( 0x18, 0x01 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x50, 0x66, 0xD1, 0x9F, 0x76, 0x94, 0xBE, 0x88 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x40, 0xC2, 0x72, 0xA2, 0x86, 0x70, 0x3C, 0x35 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x61, 0x07, 0xAD, 0x3F, 0x01, 0xB9, 0x50, 0xC5 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x40, 0x26, 0xF4, 0x5E, 0x99, 0x72, 0xEE, 0x97 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x2C, 0x66, 0x3E, 0x27, 0x17, 0xBD, 0xAF, 0x17 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x68, 0x44, 0x9B, 0x57, 0x49, 0x44, 0xF5, 0x98 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD9, 0x1B, 0x7D, 0x2C, 0xB4, 0x5F, 0x8A, 0x5C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x04, 0xC0, 0x3B, 0x9A, 0x78, 0x6A, 0x29, 0x39 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x18, 0x01 ), + }; + static const mbedtls_mpi_uint secp521r1_n[] = { +- BYTES_TO_T_UINT_8( 0x09, 0x64, 0x38, 0x91, 0x1E, 0xB7, 0x6F, 0xBB ), +- BYTES_TO_T_UINT_8( 0xAE, 0x47, 0x9C, 0x89, 0xB8, 0xC9, 0xB5, 0x3B ), +- BYTES_TO_T_UINT_8( 0xD0, 0xA5, 0x09, 0xF7, 0x48, 0x01, 0xCC, 0x7F ), +- BYTES_TO_T_UINT_8( 0x6B, 0x96, 0x2F, 0xBF, 0x83, 0x87, 0x86, 0x51 ), +- BYTES_TO_T_UINT_8( 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_2( 0xFF, 0x01 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x09, 0x64, 0x38, 0x91, 0x1E, 0xB7, 0x6F, 0xBB ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xAE, 0x47, 0x9C, 0x89, 0xB8, 0xC9, 0xB5, 0x3B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD0, 0xA5, 0x09, 0xF7, 0x48, 0x01, 0xCC, 0x7F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x6B, 0x96, 0x2F, 0xBF, 0x83, 0x87, 0x86, 0x51 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0xFF, 0x01 ), + }; + #endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ + + #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) + static const mbedtls_mpi_uint secp192k1_p[] = { +- BYTES_TO_T_UINT_8( 0x37, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x37, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + static const mbedtls_mpi_uint secp192k1_a[] = { +- BYTES_TO_T_UINT_2( 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x00, 0x00 ), + }; + static const mbedtls_mpi_uint secp192k1_b[] = { +- BYTES_TO_T_UINT_2( 0x03, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x03, 0x00 ), + }; + static const mbedtls_mpi_uint secp192k1_gx[] = { +- BYTES_TO_T_UINT_8( 0x7D, 0x6C, 0xE0, 0xEA, 0xB1, 0xD1, 0xA5, 0x1D ), +- BYTES_TO_T_UINT_8( 0x34, 0xF4, 0xB7, 0x80, 0x02, 0x7D, 0xB0, 0x26 ), +- BYTES_TO_T_UINT_8( 0xAE, 0xE9, 0x57, 0xC0, 0x0E, 0xF1, 0x4F, 0xDB ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x7D, 0x6C, 0xE0, 0xEA, 0xB1, 0xD1, 0xA5, 0x1D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x34, 0xF4, 0xB7, 0x80, 0x02, 0x7D, 0xB0, 0x26 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xAE, 0xE9, 0x57, 0xC0, 0x0E, 0xF1, 0x4F, 0xDB ), + }; + static const mbedtls_mpi_uint secp192k1_gy[] = { +- BYTES_TO_T_UINT_8( 0x9D, 0x2F, 0x5E, 0xD9, 0x88, 0xAA, 0x82, 0x40 ), +- BYTES_TO_T_UINT_8( 0x34, 0x86, 0xBE, 0x15, 0xD0, 0x63, 0x41, 0x84 ), +- BYTES_TO_T_UINT_8( 0xA7, 0x28, 0x56, 0x9C, 0x6D, 0x2F, 0x2F, 0x9B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x9D, 0x2F, 0x5E, 0xD9, 0x88, 0xAA, 0x82, 0x40 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x34, 0x86, 0xBE, 0x15, 0xD0, 0x63, 0x41, 0x84 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x28, 0x56, 0x9C, 0x6D, 0x2F, 0x2F, 0x9B ), + }; + static const mbedtls_mpi_uint secp192k1_n[] = { +- BYTES_TO_T_UINT_8( 0x8D, 0xFD, 0xDE, 0x74, 0x6A, 0x46, 0x69, 0x0F ), +- BYTES_TO_T_UINT_8( 0x17, 0xFC, 0xF2, 0x26, 0xFE, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x8D, 0xFD, 0xDE, 0x74, 0x6A, 0x46, 0x69, 0x0F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x17, 0xFC, 0xF2, 0x26, 0xFE, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + #endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ + + #if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) + static const mbedtls_mpi_uint secp224k1_p[] = { +- BYTES_TO_T_UINT_8( 0x6D, 0xE5, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x6D, 0xE5, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_4( 0xFF, 0xFF, 0xFF, 0xFF ), + }; + static const mbedtls_mpi_uint secp224k1_a[] = { +- BYTES_TO_T_UINT_2( 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x00, 0x00 ), + }; + static const mbedtls_mpi_uint secp224k1_b[] = { +- BYTES_TO_T_UINT_2( 0x05, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x05, 0x00 ), + }; + static const mbedtls_mpi_uint secp224k1_gx[] = { +- BYTES_TO_T_UINT_8( 0x5C, 0xA4, 0xB7, 0xB6, 0x0E, 0x65, 0x7E, 0x0F ), +- BYTES_TO_T_UINT_8( 0xA9, 0x75, 0x70, 0xE4, 0xE9, 0x67, 0xA4, 0x69 ), +- BYTES_TO_T_UINT_8( 0xA1, 0x28, 0xFC, 0x30, 0xDF, 0x99, 0xF0, 0x4D ), +- BYTES_TO_T_UINT_4( 0x33, 0x5B, 0x45, 0xA1 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x5C, 0xA4, 0xB7, 0xB6, 0x0E, 0x65, 0x7E, 0x0F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA9, 0x75, 0x70, 0xE4, 0xE9, 0x67, 0xA4, 0x69 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA1, 0x28, 0xFC, 0x30, 0xDF, 0x99, 0xF0, 0x4D ), ++ MBEDTLS_BYTES_TO_T_UINT_4( 0x33, 0x5B, 0x45, 0xA1 ), + }; + static const mbedtls_mpi_uint secp224k1_gy[] = { +- BYTES_TO_T_UINT_8( 0xA5, 0x61, 0x6D, 0x55, 0xDB, 0x4B, 0xCA, 0xE2 ), +- BYTES_TO_T_UINT_8( 0x59, 0xBD, 0xB0, 0xC0, 0xF7, 0x19, 0xE3, 0xF7 ), +- BYTES_TO_T_UINT_8( 0xD6, 0xFB, 0xCA, 0x82, 0x42, 0x34, 0xBA, 0x7F ), +- BYTES_TO_T_UINT_4( 0xED, 0x9F, 0x08, 0x7E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA5, 0x61, 0x6D, 0x55, 0xDB, 0x4B, 0xCA, 0xE2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x59, 0xBD, 0xB0, 0xC0, 0xF7, 0x19, 0xE3, 0xF7 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD6, 0xFB, 0xCA, 0x82, 0x42, 0x34, 0xBA, 0x7F ), ++ MBEDTLS_BYTES_TO_T_UINT_4( 0xED, 0x9F, 0x08, 0x7E ), + }; + static const mbedtls_mpi_uint secp224k1_n[] = { +- BYTES_TO_T_UINT_8( 0xF7, 0xB1, 0x9F, 0x76, 0x71, 0xA9, 0xF0, 0xCA ), +- BYTES_TO_T_UINT_8( 0x84, 0x61, 0xEC, 0xD2, 0xE8, 0xDC, 0x01, 0x00 ), +- BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), +- BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF7, 0xB1, 0x9F, 0x76, 0x71, 0xA9, 0xF0, 0xCA ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x84, 0x61, 0xEC, 0xD2, 0xE8, 0xDC, 0x01, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ), + }; + #endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ + + #if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) + static const mbedtls_mpi_uint secp256k1_p[] = { +- BYTES_TO_T_UINT_8( 0x2F, 0xFC, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x2F, 0xFC, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + static const mbedtls_mpi_uint secp256k1_a[] = { +- BYTES_TO_T_UINT_2( 0x00, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x00, 0x00 ), + }; + static const mbedtls_mpi_uint secp256k1_b[] = { +- BYTES_TO_T_UINT_2( 0x07, 0x00 ), ++ MBEDTLS_BYTES_TO_T_UINT_2( 0x07, 0x00 ), + }; + static const mbedtls_mpi_uint secp256k1_gx[] = { +- BYTES_TO_T_UINT_8( 0x98, 0x17, 0xF8, 0x16, 0x5B, 0x81, 0xF2, 0x59 ), +- BYTES_TO_T_UINT_8( 0xD9, 0x28, 0xCE, 0x2D, 0xDB, 0xFC, 0x9B, 0x02 ), +- BYTES_TO_T_UINT_8( 0x07, 0x0B, 0x87, 0xCE, 0x95, 0x62, 0xA0, 0x55 ), +- BYTES_TO_T_UINT_8( 0xAC, 0xBB, 0xDC, 0xF9, 0x7E, 0x66, 0xBE, 0x79 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x98, 0x17, 0xF8, 0x16, 0x5B, 0x81, 0xF2, 0x59 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD9, 0x28, 0xCE, 0x2D, 0xDB, 0xFC, 0x9B, 0x02 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0x0B, 0x87, 0xCE, 0x95, 0x62, 0xA0, 0x55 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xAC, 0xBB, 0xDC, 0xF9, 0x7E, 0x66, 0xBE, 0x79 ), + }; + static const mbedtls_mpi_uint secp256k1_gy[] = { +- BYTES_TO_T_UINT_8( 0xB8, 0xD4, 0x10, 0xFB, 0x8F, 0xD0, 0x47, 0x9C ), +- BYTES_TO_T_UINT_8( 0x19, 0x54, 0x85, 0xA6, 0x48, 0xB4, 0x17, 0xFD ), +- BYTES_TO_T_UINT_8( 0xA8, 0x08, 0x11, 0x0E, 0xFC, 0xFB, 0xA4, 0x5D ), +- BYTES_TO_T_UINT_8( 0x65, 0xC4, 0xA3, 0x26, 0x77, 0xDA, 0x3A, 0x48 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB8, 0xD4, 0x10, 0xFB, 0x8F, 0xD0, 0x47, 0x9C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x19, 0x54, 0x85, 0xA6, 0x48, 0xB4, 0x17, 0xFD ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA8, 0x08, 0x11, 0x0E, 0xFC, 0xFB, 0xA4, 0x5D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x65, 0xC4, 0xA3, 0x26, 0x77, 0xDA, 0x3A, 0x48 ), + }; + static const mbedtls_mpi_uint secp256k1_n[] = { +- BYTES_TO_T_UINT_8( 0x41, 0x41, 0x36, 0xD0, 0x8C, 0x5E, 0xD2, 0xBF ), +- BYTES_TO_T_UINT_8( 0x3B, 0xA0, 0x48, 0xAF, 0xE6, 0xDC, 0xAE, 0xBA ), +- BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), +- BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x41, 0x41, 0x36, 0xD0, 0x8C, 0x5E, 0xD2, 0xBF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x3B, 0xA0, 0x48, 0xAF, 0xE6, 0xDC, 0xAE, 0xBA ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ), + }; + #endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ + +@@ -394,40 +361,40 @@ static const mbedtls_mpi_uint secp256k1_n[] = { + */ + #if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) + static const mbedtls_mpi_uint brainpoolP256r1_p[] = { +- BYTES_TO_T_UINT_8( 0x77, 0x53, 0x6E, 0x1F, 0x1D, 0x48, 0x13, 0x20 ), +- BYTES_TO_T_UINT_8( 0x28, 0x20, 0x26, 0xD5, 0x23, 0xF6, 0x3B, 0x6E ), +- BYTES_TO_T_UINT_8( 0x72, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), +- BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x77, 0x53, 0x6E, 0x1F, 0x1D, 0x48, 0x13, 0x20 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x20, 0x26, 0xD5, 0x23, 0xF6, 0x3B, 0x6E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x72, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), + }; + static const mbedtls_mpi_uint brainpoolP256r1_a[] = { +- BYTES_TO_T_UINT_8( 0xD9, 0xB5, 0x30, 0xF3, 0x44, 0x4B, 0x4A, 0xE9 ), +- BYTES_TO_T_UINT_8( 0x6C, 0x5C, 0xDC, 0x26, 0xC1, 0x55, 0x80, 0xFB ), +- BYTES_TO_T_UINT_8( 0xE7, 0xFF, 0x7A, 0x41, 0x30, 0x75, 0xF6, 0xEE ), +- BYTES_TO_T_UINT_8( 0x57, 0x30, 0x2C, 0xFC, 0x75, 0x09, 0x5A, 0x7D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD9, 0xB5, 0x30, 0xF3, 0x44, 0x4B, 0x4A, 0xE9 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x6C, 0x5C, 0xDC, 0x26, 0xC1, 0x55, 0x80, 0xFB ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE7, 0xFF, 0x7A, 0x41, 0x30, 0x75, 0xF6, 0xEE ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x57, 0x30, 0x2C, 0xFC, 0x75, 0x09, 0x5A, 0x7D ), + }; + static const mbedtls_mpi_uint brainpoolP256r1_b[] = { +- BYTES_TO_T_UINT_8( 0xB6, 0x07, 0x8C, 0xFF, 0x18, 0xDC, 0xCC, 0x6B ), +- BYTES_TO_T_UINT_8( 0xCE, 0xE1, 0xF7, 0x5C, 0x29, 0x16, 0x84, 0x95 ), +- BYTES_TO_T_UINT_8( 0xBF, 0x7C, 0xD7, 0xBB, 0xD9, 0xB5, 0x30, 0xF3 ), +- BYTES_TO_T_UINT_8( 0x44, 0x4B, 0x4A, 0xE9, 0x6C, 0x5C, 0xDC, 0x26 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB6, 0x07, 0x8C, 0xFF, 0x18, 0xDC, 0xCC, 0x6B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xCE, 0xE1, 0xF7, 0x5C, 0x29, 0x16, 0x84, 0x95 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xBF, 0x7C, 0xD7, 0xBB, 0xD9, 0xB5, 0x30, 0xF3 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x44, 0x4B, 0x4A, 0xE9, 0x6C, 0x5C, 0xDC, 0x26 ), + }; + static const mbedtls_mpi_uint brainpoolP256r1_gx[] = { +- BYTES_TO_T_UINT_8( 0x62, 0x32, 0xCE, 0x9A, 0xBD, 0x53, 0x44, 0x3A ), +- BYTES_TO_T_UINT_8( 0xC2, 0x23, 0xBD, 0xE3, 0xE1, 0x27, 0xDE, 0xB9 ), +- BYTES_TO_T_UINT_8( 0xAF, 0xB7, 0x81, 0xFC, 0x2F, 0x48, 0x4B, 0x2C ), +- BYTES_TO_T_UINT_8( 0xCB, 0x57, 0x7E, 0xCB, 0xB9, 0xAE, 0xD2, 0x8B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x62, 0x32, 0xCE, 0x9A, 0xBD, 0x53, 0x44, 0x3A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xC2, 0x23, 0xBD, 0xE3, 0xE1, 0x27, 0xDE, 0xB9 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xAF, 0xB7, 0x81, 0xFC, 0x2F, 0x48, 0x4B, 0x2C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xCB, 0x57, 0x7E, 0xCB, 0xB9, 0xAE, 0xD2, 0x8B ), + }; + static const mbedtls_mpi_uint brainpoolP256r1_gy[] = { +- BYTES_TO_T_UINT_8( 0x97, 0x69, 0x04, 0x2F, 0xC7, 0x54, 0x1D, 0x5C ), +- BYTES_TO_T_UINT_8( 0x54, 0x8E, 0xED, 0x2D, 0x13, 0x45, 0x77, 0xC2 ), +- BYTES_TO_T_UINT_8( 0xC9, 0x1D, 0x61, 0x14, 0x1A, 0x46, 0xF8, 0x97 ), +- BYTES_TO_T_UINT_8( 0xFD, 0xC4, 0xDA, 0xC3, 0x35, 0xF8, 0x7E, 0x54 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x97, 0x69, 0x04, 0x2F, 0xC7, 0x54, 0x1D, 0x5C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x54, 0x8E, 0xED, 0x2D, 0x13, 0x45, 0x77, 0xC2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xC9, 0x1D, 0x61, 0x14, 0x1A, 0x46, 0xF8, 0x97 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFD, 0xC4, 0xDA, 0xC3, 0x35, 0xF8, 0x7E, 0x54 ), + }; + static const mbedtls_mpi_uint brainpoolP256r1_n[] = { +- BYTES_TO_T_UINT_8( 0xA7, 0x56, 0x48, 0x97, 0x82, 0x0E, 0x1E, 0x90 ), +- BYTES_TO_T_UINT_8( 0xF7, 0xA6, 0x61, 0xB5, 0xA3, 0x7A, 0x39, 0x8C ), +- BYTES_TO_T_UINT_8( 0x71, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), +- BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x56, 0x48, 0x97, 0x82, 0x0E, 0x1E, 0x90 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF7, 0xA6, 0x61, 0xB5, 0xA3, 0x7A, 0x39, 0x8C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x71, 0x8D, 0x83, 0x9D, 0x90, 0x0A, 0x66, 0x3E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0xA9, 0xEE, 0xA1, 0xDB, 0x57, 0xFB, 0xA9 ), + }; + #endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ + +@@ -436,52 +403,52 @@ static const mbedtls_mpi_uint brainpoolP256r1_n[] = { + */ + #if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) + static const mbedtls_mpi_uint brainpoolP384r1_p[] = { +- BYTES_TO_T_UINT_8( 0x53, 0xEC, 0x07, 0x31, 0x13, 0x00, 0x47, 0x87 ), +- BYTES_TO_T_UINT_8( 0x71, 0x1A, 0x1D, 0x90, 0x29, 0xA7, 0xD3, 0xAC ), +- BYTES_TO_T_UINT_8( 0x23, 0x11, 0xB7, 0x7F, 0x19, 0xDA, 0xB1, 0x12 ), +- BYTES_TO_T_UINT_8( 0xB4, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), +- BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), +- BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x53, 0xEC, 0x07, 0x31, 0x13, 0x00, 0x47, 0x87 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x71, 0x1A, 0x1D, 0x90, 0x29, 0xA7, 0xD3, 0xAC ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x23, 0x11, 0xB7, 0x7F, 0x19, 0xDA, 0xB1, 0x12 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB4, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), + }; + static const mbedtls_mpi_uint brainpoolP384r1_a[] = { +- BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), +- BYTES_TO_T_UINT_8( 0xEB, 0xD4, 0x3A, 0x50, 0x4A, 0x81, 0xA5, 0x8A ), +- BYTES_TO_T_UINT_8( 0x0F, 0xF9, 0x91, 0xBA, 0xEF, 0x65, 0x91, 0x13 ), +- BYTES_TO_T_UINT_8( 0x87, 0x27, 0xB2, 0x4F, 0x8E, 0xA2, 0xBE, 0xC2 ), +- BYTES_TO_T_UINT_8( 0xA0, 0xAF, 0x05, 0xCE, 0x0A, 0x08, 0x72, 0x3C ), +- BYTES_TO_T_UINT_8( 0x0C, 0x15, 0x8C, 0x3D, 0xC6, 0x82, 0xC3, 0x7B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xEB, 0xD4, 0x3A, 0x50, 0x4A, 0x81, 0xA5, 0x8A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x0F, 0xF9, 0x91, 0xBA, 0xEF, 0x65, 0x91, 0x13 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x87, 0x27, 0xB2, 0x4F, 0x8E, 0xA2, 0xBE, 0xC2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA0, 0xAF, 0x05, 0xCE, 0x0A, 0x08, 0x72, 0x3C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x0C, 0x15, 0x8C, 0x3D, 0xC6, 0x82, 0xC3, 0x7B ), + }; + static const mbedtls_mpi_uint brainpoolP384r1_b[] = { +- BYTES_TO_T_UINT_8( 0x11, 0x4C, 0x50, 0xFA, 0x96, 0x86, 0xB7, 0x3A ), +- BYTES_TO_T_UINT_8( 0x94, 0xC9, 0xDB, 0x95, 0x02, 0x39, 0xB4, 0x7C ), +- BYTES_TO_T_UINT_8( 0xD5, 0x62, 0xEB, 0x3E, 0xA5, 0x0E, 0x88, 0x2E ), +- BYTES_TO_T_UINT_8( 0xA6, 0xD2, 0xDC, 0x07, 0xE1, 0x7D, 0xB7, 0x2F ), +- BYTES_TO_T_UINT_8( 0x7C, 0x44, 0xF0, 0x16, 0x54, 0xB5, 0x39, 0x8B ), +- BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x4C, 0x50, 0xFA, 0x96, 0x86, 0xB7, 0x3A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x94, 0xC9, 0xDB, 0x95, 0x02, 0x39, 0xB4, 0x7C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD5, 0x62, 0xEB, 0x3E, 0xA5, 0x0E, 0x88, 0x2E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA6, 0xD2, 0xDC, 0x07, 0xE1, 0x7D, 0xB7, 0x2F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x7C, 0x44, 0xF0, 0x16, 0x54, 0xB5, 0x39, 0x8B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x26, 0x28, 0xCE, 0x22, 0xDD, 0xC7, 0xA8, 0x04 ), + }; + static const mbedtls_mpi_uint brainpoolP384r1_gx[] = { +- BYTES_TO_T_UINT_8( 0x1E, 0xAF, 0xD4, 0x47, 0xE2, 0xB2, 0x87, 0xEF ), +- BYTES_TO_T_UINT_8( 0xAA, 0x46, 0xD6, 0x36, 0x34, 0xE0, 0x26, 0xE8 ), +- BYTES_TO_T_UINT_8( 0xE8, 0x10, 0xBD, 0x0C, 0xFE, 0xCA, 0x7F, 0xDB ), +- BYTES_TO_T_UINT_8( 0xE3, 0x4F, 0xF1, 0x7E, 0xE7, 0xA3, 0x47, 0x88 ), +- BYTES_TO_T_UINT_8( 0x6B, 0x3F, 0xC1, 0xB7, 0x81, 0x3A, 0xA6, 0xA2 ), +- BYTES_TO_T_UINT_8( 0xFF, 0x45, 0xCF, 0x68, 0xF0, 0x64, 0x1C, 0x1D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x1E, 0xAF, 0xD4, 0x47, 0xE2, 0xB2, 0x87, 0xEF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xAA, 0x46, 0xD6, 0x36, 0x34, 0xE0, 0x26, 0xE8 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE8, 0x10, 0xBD, 0x0C, 0xFE, 0xCA, 0x7F, 0xDB ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE3, 0x4F, 0xF1, 0x7E, 0xE7, 0xA3, 0x47, 0x88 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x6B, 0x3F, 0xC1, 0xB7, 0x81, 0x3A, 0xA6, 0xA2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0x45, 0xCF, 0x68, 0xF0, 0x64, 0x1C, 0x1D ), + }; + static const mbedtls_mpi_uint brainpoolP384r1_gy[] = { +- BYTES_TO_T_UINT_8( 0x15, 0x53, 0x3C, 0x26, 0x41, 0x03, 0x82, 0x42 ), +- BYTES_TO_T_UINT_8( 0x11, 0x81, 0x91, 0x77, 0x21, 0x46, 0x46, 0x0E ), +- BYTES_TO_T_UINT_8( 0x28, 0x29, 0x91, 0xF9, 0x4F, 0x05, 0x9C, 0xE1 ), +- BYTES_TO_T_UINT_8( 0x64, 0x58, 0xEC, 0xFE, 0x29, 0x0B, 0xB7, 0x62 ), +- BYTES_TO_T_UINT_8( 0x52, 0xD5, 0xCF, 0x95, 0x8E, 0xEB, 0xB1, 0x5C ), +- BYTES_TO_T_UINT_8( 0xA4, 0xC2, 0xF9, 0x20, 0x75, 0x1D, 0xBE, 0x8A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x15, 0x53, 0x3C, 0x26, 0x41, 0x03, 0x82, 0x42 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x81, 0x91, 0x77, 0x21, 0x46, 0x46, 0x0E ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x29, 0x91, 0xF9, 0x4F, 0x05, 0x9C, 0xE1 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x64, 0x58, 0xEC, 0xFE, 0x29, 0x0B, 0xB7, 0x62 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x52, 0xD5, 0xCF, 0x95, 0x8E, 0xEB, 0xB1, 0x5C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA4, 0xC2, 0xF9, 0x20, 0x75, 0x1D, 0xBE, 0x8A ), + }; + static const mbedtls_mpi_uint brainpoolP384r1_n[] = { +- BYTES_TO_T_UINT_8( 0x65, 0x65, 0x04, 0xE9, 0x02, 0x32, 0x88, 0x3B ), +- BYTES_TO_T_UINT_8( 0x10, 0xC3, 0x7F, 0x6B, 0xAF, 0xB6, 0x3A, 0xCF ), +- BYTES_TO_T_UINT_8( 0xA7, 0x25, 0x04, 0xAC, 0x6C, 0x6E, 0x16, 0x1F ), +- BYTES_TO_T_UINT_8( 0xB3, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), +- BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), +- BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x65, 0x65, 0x04, 0xE9, 0x02, 0x32, 0x88, 0x3B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x10, 0xC3, 0x7F, 0x6B, 0xAF, 0xB6, 0x3A, 0xCF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x25, 0x04, 0xAC, 0x6C, 0x6E, 0x16, 0x1F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB3, 0x56, 0x54, 0xED, 0x09, 0x71, 0x2F, 0x15 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xDF, 0x41, 0xE6, 0x50, 0x7E, 0x6F, 0x5D, 0x0F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x28, 0x6D, 0x38, 0xA3, 0x82, 0x1E, 0xB9, 0x8C ), + }; + #endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ + +@@ -490,64 +457,64 @@ static const mbedtls_mpi_uint brainpoolP384r1_n[] = { + */ + #if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) + static const mbedtls_mpi_uint brainpoolP512r1_p[] = { +- BYTES_TO_T_UINT_8( 0xF3, 0x48, 0x3A, 0x58, 0x56, 0x60, 0xAA, 0x28 ), +- BYTES_TO_T_UINT_8( 0x85, 0xC6, 0x82, 0x2D, 0x2F, 0xFF, 0x81, 0x28 ), +- BYTES_TO_T_UINT_8( 0xE6, 0x80, 0xA3, 0xE6, 0x2A, 0xA1, 0xCD, 0xAE ), +- BYTES_TO_T_UINT_8( 0x42, 0x68, 0xC6, 0x9B, 0x00, 0x9B, 0x4D, 0x7D ), +- BYTES_TO_T_UINT_8( 0x71, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), +- BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), +- BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), +- BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xF3, 0x48, 0x3A, 0x58, 0x56, 0x60, 0xAA, 0x28 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x85, 0xC6, 0x82, 0x2D, 0x2F, 0xFF, 0x81, 0x28 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xE6, 0x80, 0xA3, 0xE6, 0x2A, 0xA1, 0xCD, 0xAE ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x42, 0x68, 0xC6, 0x9B, 0x00, 0x9B, 0x4D, 0x7D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x71, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), + }; + static const mbedtls_mpi_uint brainpoolP512r1_a[] = { +- BYTES_TO_T_UINT_8( 0xCA, 0x94, 0xFC, 0x77, 0x4D, 0xAC, 0xC1, 0xE7 ), +- BYTES_TO_T_UINT_8( 0xB9, 0xC7, 0xF2, 0x2B, 0xA7, 0x17, 0x11, 0x7F ), +- BYTES_TO_T_UINT_8( 0xB5, 0xC8, 0x9A, 0x8B, 0xC9, 0xF1, 0x2E, 0x0A ), +- BYTES_TO_T_UINT_8( 0xA1, 0x3A, 0x25, 0xA8, 0x5A, 0x5D, 0xED, 0x2D ), +- BYTES_TO_T_UINT_8( 0xBC, 0x63, 0x98, 0xEA, 0xCA, 0x41, 0x34, 0xA8 ), +- BYTES_TO_T_UINT_8( 0x10, 0x16, 0xF9, 0x3D, 0x8D, 0xDD, 0xCB, 0x94 ), +- BYTES_TO_T_UINT_8( 0xC5, 0x4C, 0x23, 0xAC, 0x45, 0x71, 0x32, 0xE2 ), +- BYTES_TO_T_UINT_8( 0x89, 0x3B, 0x60, 0x8B, 0x31, 0xA3, 0x30, 0x78 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xCA, 0x94, 0xFC, 0x77, 0x4D, 0xAC, 0xC1, 0xE7 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB9, 0xC7, 0xF2, 0x2B, 0xA7, 0x17, 0x11, 0x7F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xB5, 0xC8, 0x9A, 0x8B, 0xC9, 0xF1, 0x2E, 0x0A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA1, 0x3A, 0x25, 0xA8, 0x5A, 0x5D, 0xED, 0x2D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xBC, 0x63, 0x98, 0xEA, 0xCA, 0x41, 0x34, 0xA8 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x10, 0x16, 0xF9, 0x3D, 0x8D, 0xDD, 0xCB, 0x94 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xC5, 0x4C, 0x23, 0xAC, 0x45, 0x71, 0x32, 0xE2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x89, 0x3B, 0x60, 0x8B, 0x31, 0xA3, 0x30, 0x78 ), + }; + static const mbedtls_mpi_uint brainpoolP512r1_b[] = { +- BYTES_TO_T_UINT_8( 0x23, 0xF7, 0x16, 0x80, 0x63, 0xBD, 0x09, 0x28 ), +- BYTES_TO_T_UINT_8( 0xDD, 0xE5, 0xBA, 0x5E, 0xB7, 0x50, 0x40, 0x98 ), +- BYTES_TO_T_UINT_8( 0x67, 0x3E, 0x08, 0xDC, 0xCA, 0x94, 0xFC, 0x77 ), +- BYTES_TO_T_UINT_8( 0x4D, 0xAC, 0xC1, 0xE7, 0xB9, 0xC7, 0xF2, 0x2B ), +- BYTES_TO_T_UINT_8( 0xA7, 0x17, 0x11, 0x7F, 0xB5, 0xC8, 0x9A, 0x8B ), +- BYTES_TO_T_UINT_8( 0xC9, 0xF1, 0x2E, 0x0A, 0xA1, 0x3A, 0x25, 0xA8 ), +- BYTES_TO_T_UINT_8( 0x5A, 0x5D, 0xED, 0x2D, 0xBC, 0x63, 0x98, 0xEA ), +- BYTES_TO_T_UINT_8( 0xCA, 0x41, 0x34, 0xA8, 0x10, 0x16, 0xF9, 0x3D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x23, 0xF7, 0x16, 0x80, 0x63, 0xBD, 0x09, 0x28 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xDD, 0xE5, 0xBA, 0x5E, 0xB7, 0x50, 0x40, 0x98 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x67, 0x3E, 0x08, 0xDC, 0xCA, 0x94, 0xFC, 0x77 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x4D, 0xAC, 0xC1, 0xE7, 0xB9, 0xC7, 0xF2, 0x2B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xA7, 0x17, 0x11, 0x7F, 0xB5, 0xC8, 0x9A, 0x8B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xC9, 0xF1, 0x2E, 0x0A, 0xA1, 0x3A, 0x25, 0xA8 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x5A, 0x5D, 0xED, 0x2D, 0xBC, 0x63, 0x98, 0xEA ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xCA, 0x41, 0x34, 0xA8, 0x10, 0x16, 0xF9, 0x3D ), + }; + static const mbedtls_mpi_uint brainpoolP512r1_gx[] = { +- BYTES_TO_T_UINT_8( 0x22, 0xF8, 0xB9, 0xBC, 0x09, 0x22, 0x35, 0x8B ), +- BYTES_TO_T_UINT_8( 0x68, 0x5E, 0x6A, 0x40, 0x47, 0x50, 0x6D, 0x7C ), +- BYTES_TO_T_UINT_8( 0x5F, 0x7D, 0xB9, 0x93, 0x7B, 0x68, 0xD1, 0x50 ), +- BYTES_TO_T_UINT_8( 0x8D, 0xD4, 0xD0, 0xE2, 0x78, 0x1F, 0x3B, 0xFF ), +- BYTES_TO_T_UINT_8( 0x8E, 0x09, 0xD0, 0xF4, 0xEE, 0x62, 0x3B, 0xB4 ), +- BYTES_TO_T_UINT_8( 0xC1, 0x16, 0xD9, 0xB5, 0x70, 0x9F, 0xED, 0x85 ), +- BYTES_TO_T_UINT_8( 0x93, 0x6A, 0x4C, 0x9C, 0x2E, 0x32, 0x21, 0x5A ), +- BYTES_TO_T_UINT_8( 0x64, 0xD9, 0x2E, 0xD8, 0xBD, 0xE4, 0xAE, 0x81 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x22, 0xF8, 0xB9, 0xBC, 0x09, 0x22, 0x35, 0x8B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x68, 0x5E, 0x6A, 0x40, 0x47, 0x50, 0x6D, 0x7C ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x5F, 0x7D, 0xB9, 0x93, 0x7B, 0x68, 0xD1, 0x50 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x8D, 0xD4, 0xD0, 0xE2, 0x78, 0x1F, 0x3B, 0xFF ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x8E, 0x09, 0xD0, 0xF4, 0xEE, 0x62, 0x3B, 0xB4 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xC1, 0x16, 0xD9, 0xB5, 0x70, 0x9F, 0xED, 0x85 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x93, 0x6A, 0x4C, 0x9C, 0x2E, 0x32, 0x21, 0x5A ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x64, 0xD9, 0x2E, 0xD8, 0xBD, 0xE4, 0xAE, 0x81 ), + }; + static const mbedtls_mpi_uint brainpoolP512r1_gy[] = { +- BYTES_TO_T_UINT_8( 0x92, 0x08, 0xD8, 0x3A, 0x0F, 0x1E, 0xCD, 0x78 ), +- BYTES_TO_T_UINT_8( 0x06, 0x54, 0xF0, 0xA8, 0x2F, 0x2B, 0xCA, 0xD1 ), +- BYTES_TO_T_UINT_8( 0xAE, 0x63, 0x27, 0x8A, 0xD8, 0x4B, 0xCA, 0x5B ), +- BYTES_TO_T_UINT_8( 0x5E, 0x48, 0x5F, 0x4A, 0x49, 0xDE, 0xDC, 0xB2 ), +- BYTES_TO_T_UINT_8( 0x11, 0x81, 0x1F, 0x88, 0x5B, 0xC5, 0x00, 0xA0 ), +- BYTES_TO_T_UINT_8( 0x1A, 0x7B, 0xA5, 0x24, 0x00, 0xF7, 0x09, 0xF2 ), +- BYTES_TO_T_UINT_8( 0xFD, 0x22, 0x78, 0xCF, 0xA9, 0xBF, 0xEA, 0xC0 ), +- BYTES_TO_T_UINT_8( 0xEC, 0x32, 0x63, 0x56, 0x5D, 0x38, 0xDE, 0x7D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x92, 0x08, 0xD8, 0x3A, 0x0F, 0x1E, 0xCD, 0x78 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x06, 0x54, 0xF0, 0xA8, 0x2F, 0x2B, 0xCA, 0xD1 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xAE, 0x63, 0x27, 0x8A, 0xD8, 0x4B, 0xCA, 0x5B ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x5E, 0x48, 0x5F, 0x4A, 0x49, 0xDE, 0xDC, 0xB2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x81, 0x1F, 0x88, 0x5B, 0xC5, 0x00, 0xA0 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x1A, 0x7B, 0xA5, 0x24, 0x00, 0xF7, 0x09, 0xF2 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xFD, 0x22, 0x78, 0xCF, 0xA9, 0xBF, 0xEA, 0xC0 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xEC, 0x32, 0x63, 0x56, 0x5D, 0x38, 0xDE, 0x7D ), + }; + static const mbedtls_mpi_uint brainpoolP512r1_n[] = { +- BYTES_TO_T_UINT_8( 0x69, 0x00, 0xA9, 0x9C, 0x82, 0x96, 0x87, 0xB5 ), +- BYTES_TO_T_UINT_8( 0xDD, 0xDA, 0x5D, 0x08, 0x81, 0xD3, 0xB1, 0x1D ), +- BYTES_TO_T_UINT_8( 0x47, 0x10, 0xAC, 0x7F, 0x19, 0x61, 0x86, 0x41 ), +- BYTES_TO_T_UINT_8( 0x19, 0x26, 0xA9, 0x4C, 0x41, 0x5C, 0x3E, 0x55 ), +- BYTES_TO_T_UINT_8( 0x70, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), +- BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), +- BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), +- BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x69, 0x00, 0xA9, 0x9C, 0x82, 0x96, 0x87, 0xB5 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xDD, 0xDA, 0x5D, 0x08, 0x81, 0xD3, 0xB1, 0x1D ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x47, 0x10, 0xAC, 0x7F, 0x19, 0x61, 0x86, 0x41 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x19, 0x26, 0xA9, 0x4C, 0x41, 0x5C, 0x3E, 0x55 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x70, 0x08, 0x33, 0x70, 0xCA, 0x9C, 0x63, 0xD6 ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x0E, 0xD2, 0xC9, 0xB3, 0xB3, 0x8D, 0x30, 0xCB ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x07, 0xFC, 0xC9, 0x33, 0xAE, 0xE6, 0xD4, 0x3F ), ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x8B, 0xC4, 0xE9, 0xDB, 0xB8, 0x9D, 0xDD, 0xAA ), + }; + #endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ + +@@ -678,6 +645,13 @@ static int ecp_mod_p256k1( mbedtls_mpi * ); + #endif /* ECP_LOAD_GROUP */ + + #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) ++/* Constants used by ecp_use_curve25519() */ ++static const mbedtls_mpi_sint curve25519_a24 = 0x01DB42; ++static const unsigned char curve25519_part_of_n[] = { ++ 0x14, 0xDE, 0xF9, 0xDE, 0xA2, 0xF7, 0x9C, 0xD6, ++ 0x58, 0x12, 0x63, 0x1A, 0x5C, 0xF5, 0xD3, 0xED, ++}; ++ + /* + * Specialized function for creating the Curve25519 group + */ +@@ -686,7 +660,7 @@ static int ecp_use_curve25519( mbedtls_ecp_group *grp ) + int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; + + /* Actually ( A + 2 ) / 4 */ +- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->A, 16, "01DB42" ) ); ++ MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->A, curve25519_a24 ) ); + + /* P = 2^255 - 19 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->P, 1 ) ); +@@ -695,8 +669,8 @@ static int ecp_use_curve25519( mbedtls_ecp_group *grp ) + grp->pbits = mbedtls_mpi_bitlen( &grp->P ); + + /* N = 2^252 + 27742317777372353535851937790883648493 */ +- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->N, 16, +- "14DEF9DEA2F79CD65812631A5CF5D3ED" ) ); ++ MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &grp->N, ++ curve25519_part_of_n, sizeof( curve25519_part_of_n ) ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( &grp->N, 252, 1 ) ); + + /* Y intentionally not set, since we use x/z coordinates. +@@ -717,6 +691,15 @@ cleanup: + #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ + + #if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) ++/* Constants used by ecp_use_curve448() */ ++static const mbedtls_mpi_sint curve448_a24 = 0x98AA; ++static const unsigned char curve448_part_of_n[] = { ++ 0x83, 0x35, 0xDC, 0x16, 0x3B, 0xB1, 0x24, ++ 0xB6, 0x51, 0x29, 0xC9, 0x6F, 0xDE, 0x93, ++ 0x3D, 0x8D, 0x72, 0x3A, 0x70, 0xAA, 0xDC, ++ 0x87, 0x3D, 0x6D, 0x54, 0xA7, 0xBB, 0x0D, ++}; ++ + /* + * Specialized function for creating the Curve448 group + */ +@@ -728,7 +711,7 @@ static int ecp_use_curve448( mbedtls_ecp_group *grp ) + mbedtls_mpi_init( &Ns ); + + /* Actually ( A + 2 ) / 4 */ +- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->A, 16, "98AA" ) ); ++ MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->A, curve448_a24 ) ); + + /* P = 2^448 - 2^224 - 1 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->P, 1 ) ); +@@ -746,8 +729,8 @@ static int ecp_use_curve448( mbedtls_ecp_group *grp ) + + /* N = 2^446 - 13818066809895115352007386748515426880336692474882178609894547503885 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( &grp->N, 446, 1 ) ); +- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &Ns, 16, +- "8335DC163BB124B65129C96FDE933D8D723A70AADC873D6D54A7BB0D" ) ); ++ MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &Ns, ++ curve448_part_of_n, sizeof( curve448_part_of_n ) ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &grp->N, &grp->N, &Ns ) ); + + /* Actually, the required msb for private keys */ +@@ -1441,9 +1424,11 @@ cleanup: + static int ecp_mod_p192k1( mbedtls_mpi *N ) + { + static mbedtls_mpi_uint Rp[] = { +- BYTES_TO_T_UINT_8( 0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xC9, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, ++ 0x00 ) }; + +- return( ecp_mod_koblitz( N, Rp, 192 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); ++ return( ecp_mod_koblitz( N, Rp, 192 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, ++ 0 ) ); + } + #endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ + +@@ -1455,12 +1440,14 @@ static int ecp_mod_p192k1( mbedtls_mpi *N ) + static int ecp_mod_p224k1( mbedtls_mpi *N ) + { + static mbedtls_mpi_uint Rp[] = { +- BYTES_TO_T_UINT_8( 0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; ++ MBEDTLS_BYTES_TO_T_UINT_8( 0x93, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x00, ++ 0x00 ) }; + + #if defined(MBEDTLS_HAVE_INT64) + return( ecp_mod_koblitz( N, Rp, 4, 1, 32, 0xFFFFFFFF ) ); + #else +- return( ecp_mod_koblitz( N, Rp, 224 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); ++ return( ecp_mod_koblitz( N, Rp, 224 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, ++ 0 ) ); + #endif + } + +@@ -1474,8 +1461,10 @@ static int ecp_mod_p224k1( mbedtls_mpi *N ) + static int ecp_mod_p256k1( mbedtls_mpi *N ) + { + static mbedtls_mpi_uint Rp[] = { +- BYTES_TO_T_UINT_8( 0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ) }; +- return( ecp_mod_koblitz( N, Rp, 256 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, 0 ) ); ++ MBEDTLS_BYTES_TO_T_UINT_8( 0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, ++ 0x00 ) }; ++ return( ecp_mod_koblitz( N, Rp, 256 / 8 / sizeof( mbedtls_mpi_uint ), 0, 0, ++ 0 ) ); + } + #endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ + +diff --git a/tests/suites/test_suite_ecp.data b/tests/suites/test_suite_ecp.data +index 408a9b7fe..d9b46c8e6 100644 +--- a/tests/suites/test_suite_ecp.data ++++ b/tests/suites/test_suite_ecp.data +@@ -36,13 +36,133 @@ ECP curve info #8 + depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED + mbedtls_ecp_curve_info:MBEDTLS_ECP_DP_SECP192R1:19:192:"secp192r1" + +-ECP check pubkey Montgomery #1 (too big) ++ECP check pubkey Curve25519 #1 (biggest) ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":0 ++ ++ECP check pubkey Curve25519 #2 (too big) + depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED + ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"010000000000000000000000000000000000000000000000000000000000000000":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY + +-ECP check pubkey Montgomery #2 (biggest) ++ECP check pubkey Curve25519 #3 (DoS big) + depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED +-ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":0 ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"0100000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve25519 y ignored ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"2":"-1":"1":0 ++ ++ECP check pubkey Curve25519 z is not 1 ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"2":"0":"2":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve25519 x negative ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"-2":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #1 ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"0":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #2 ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"1":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #3 (let's call this u) ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"b8495f16056286fdb1329ceb8d09da6ac49ff1fae35616aeb8413b7c7aebe0":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #4 (let's call this v) ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"57119fd0dd4e22d8868e1c58c45c44045bef839c55b1d0b1248c50a3bc959c5f":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #5 p-1 ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #6 p ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #7 p+1 ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #8 p+u ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"80b8495f16056286fdb1329ceb8d09da6ac49ff1fae35616aeb8413b7c7aebcd":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #9 p+v ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"d7119fd0dd4e22d8868e1c58c45c44045bef839c55b1d0b1248c50a3bc959c4c":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #10 2p-1 ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd9":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #11 2p ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffda":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++# see https://cr.yp.to/ecdh.html#validate ++ECP check pubkey Curve25519 low-order point #12 2p+1 ++depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdb":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 #1 (biggest) ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":0 ++ ++ECP check pubkey Curve448 #2 (too big) ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 #3 (DoS big) ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"0100000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 y ignored ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"2":"-1":"1":0 ++ ++ECP check pubkey Curve448 z is not 1 ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"2":"0":"2":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 x negative ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"-2":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 low-order point #1 ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"0":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 low-order point #2 ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"1":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 low-order point #3 p-1 ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 low-order point #4 p ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY ++ ++ECP check pubkey Curve448 low-order point #5 p+1 ++depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED ++ecp_check_pub:MBEDTLS_ECP_DP_CURVE448:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY + + ECP check pubkey Koblitz #1 (point not on curve) + depends_on:MBEDTLS_ECP_DP_SECP224K1_ENABLED +@@ -440,15 +560,15 @@ ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2 + + ECP point multiplication Curve25519 (element of order 2: origin) #3 + depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED +-ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"00":"00":"01":"00":"01":"00":MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ++ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"00":"00":"01":"00":"01":"00":MBEDTLS_ERR_ECP_INVALID_KEY + + ECP point multiplication Curve25519 (element of order 4: 1) #4 + depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED +-ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"01":"00":"01":"00":"01":"00":MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ++ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"01":"00":"01":"00":"01":"00":MBEDTLS_ERR_ECP_INVALID_KEY + + ECP point multiplication Curve25519 (element of order 8) #5 + depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED +-ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"B8495F16056286FDB1329CEB8D09DA6AC49FF1FAE35616AEB8413B7C7AEBE0":"00":"01":"00":"01":"00":MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ++ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"B8495F16056286FDB1329CEB8D09DA6AC49FF1FAE35616AEB8413B7C7AEBE0":"00":"01":"00":"01":"00":MBEDTLS_ERR_ECP_INVALID_KEY + + ECP point multiplication rng fail secp256r1 + depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED diff --git a/deps/patches/mbedtls-security-advisory-2021-12.patch b/deps/patches/mbedtls-security-advisory-2021-12.patch new file mode 100644 index 0000000000000..52204bc987ee5 --- /dev/null +++ b/deps/patches/mbedtls-security-advisory-2021-12.patch @@ -0,0 +1,25 @@ +commit 6f0354fb7d3d04be928704eb2802fd5ba83213de +Author: 吴敬辉 <11137405@vivo.com> +Date: Mon Nov 29 10:46:35 2021 +0800 + + [session] fix a session copy bug + fix a possible double reference on 'ticket' + when peer_cert/peer_cert_digest calloc failed. + + Signed-off-by: 吴敬辉 <11137405@vivo.com> + +diff --git a/library/ssl_tls.c b/library/ssl_tls.c +index 7062d53b7..49cdbae66 100644 +--- a/library/ssl_tls.c ++++ b/library/ssl_tls.c +@@ -187,6 +187,10 @@ int mbedtls_ssl_session_copy( mbedtls_ssl_session *dst, + mbedtls_ssl_session_free( dst ); + memcpy( dst, src, sizeof( mbedtls_ssl_session ) ); + ++#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) ++ dst->ticket = NULL; ++#endif ++ + #if defined(MBEDTLS_X509_CRT_PARSE_C) + + #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) diff --git a/stdlib/MbedTLS_jll/Project.toml b/stdlib/MbedTLS_jll/Project.toml index 67a81e88bdd35..3afb8a545df05 100644 --- a/stdlib/MbedTLS_jll/Project.toml +++ b/stdlib/MbedTLS_jll/Project.toml @@ -1,6 +1,6 @@ name = "MbedTLS_jll" uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.24.0+1" +version = "2.24.0+4" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"