From b8c4cc63e77bd457dffa6ec83a3ff65382dac94b Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Tue, 16 Dec 2025 13:50:57 +0000 Subject: runtime: keep track of secret allocation size During a naive attempt to test the new runtime/secret package, I tried wrapping the entire handshake in a secret.Do call. This lead to a panic because some of the allocator logic had been previously untested. freeSpecial takes p and size, but they can be misleading. They don't refer to the pointer and size of the object with the special attached, but a pointer to the enclosing object and the size of the span element. The previous code did not take this into account and when passing the size to memclr would overwrite nearby objects. Fix by storing the size of the object being cleared inside the special. Fixes #76865. Change-Id: Ifae31f1c8d0609a562a37f37c45aec2f369dc6a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/730361 Reviewed-by: Michael Knyszek LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase --- src/runtime/malloc_generated.go | 152 ++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'src/runtime/malloc_generated.go') diff --git a/src/runtime/malloc_generated.go b/src/runtime/malloc_generated.go index cf329d2696..2be6a5b6f5 100644 --- a/src/runtime/malloc_generated.go +++ b/src/runtime/malloc_generated.go @@ -156,7 +156,7 @@ func mallocgcSmallScanNoHeaderSC1(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -321,7 +321,7 @@ func mallocgcSmallScanNoHeaderSC2(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -486,7 +486,7 @@ func mallocgcSmallScanNoHeaderSC3(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -651,7 +651,7 @@ func mallocgcSmallScanNoHeaderSC4(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -816,7 +816,7 @@ func mallocgcSmallScanNoHeaderSC5(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -981,7 +981,7 @@ func mallocgcSmallScanNoHeaderSC6(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -1146,7 +1146,7 @@ func mallocgcSmallScanNoHeaderSC7(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -1311,7 +1311,7 @@ func mallocgcSmallScanNoHeaderSC8(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -1476,7 +1476,7 @@ func mallocgcSmallScanNoHeaderSC9(size uintptr, typ *_type, needzero bool) unsaf gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -1641,7 +1641,7 @@ func mallocgcSmallScanNoHeaderSC10(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -1806,7 +1806,7 @@ func mallocgcSmallScanNoHeaderSC11(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -1971,7 +1971,7 @@ func mallocgcSmallScanNoHeaderSC12(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -2136,7 +2136,7 @@ func mallocgcSmallScanNoHeaderSC13(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -2301,7 +2301,7 @@ func mallocgcSmallScanNoHeaderSC14(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -2466,7 +2466,7 @@ func mallocgcSmallScanNoHeaderSC15(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -2631,7 +2631,7 @@ func mallocgcSmallScanNoHeaderSC16(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -2796,7 +2796,7 @@ func mallocgcSmallScanNoHeaderSC17(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -2961,7 +2961,7 @@ func mallocgcSmallScanNoHeaderSC18(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -3126,7 +3126,7 @@ func mallocgcSmallScanNoHeaderSC19(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -3291,7 +3291,7 @@ func mallocgcSmallScanNoHeaderSC20(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -3456,7 +3456,7 @@ func mallocgcSmallScanNoHeaderSC21(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -3621,7 +3621,7 @@ func mallocgcSmallScanNoHeaderSC22(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -3786,7 +3786,7 @@ func mallocgcSmallScanNoHeaderSC23(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -3951,7 +3951,7 @@ func mallocgcSmallScanNoHeaderSC24(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -4116,7 +4116,7 @@ func mallocgcSmallScanNoHeaderSC25(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -4281,7 +4281,7 @@ func mallocgcSmallScanNoHeaderSC26(size uintptr, typ *_type, needzero bool) unsa gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -6686,7 +6686,7 @@ func mallocgcSmallNoScanSC2(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -6757,7 +6757,7 @@ func mallocgcSmallNoScanSC2(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -6822,7 +6822,7 @@ func mallocgcSmallNoScanSC3(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -6893,7 +6893,7 @@ func mallocgcSmallNoScanSC3(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -6958,7 +6958,7 @@ func mallocgcSmallNoScanSC4(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7029,7 +7029,7 @@ func mallocgcSmallNoScanSC4(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7094,7 +7094,7 @@ func mallocgcSmallNoScanSC5(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7165,7 +7165,7 @@ func mallocgcSmallNoScanSC5(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7230,7 +7230,7 @@ func mallocgcSmallNoScanSC6(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7301,7 +7301,7 @@ func mallocgcSmallNoScanSC6(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7366,7 +7366,7 @@ func mallocgcSmallNoScanSC7(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7437,7 +7437,7 @@ func mallocgcSmallNoScanSC7(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7502,7 +7502,7 @@ func mallocgcSmallNoScanSC8(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7573,7 +7573,7 @@ func mallocgcSmallNoScanSC8(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7638,7 +7638,7 @@ func mallocgcSmallNoScanSC9(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7709,7 +7709,7 @@ func mallocgcSmallNoScanSC9(size uintptr, typ *_type, needzero bool) unsafe.Poin gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7774,7 +7774,7 @@ func mallocgcSmallNoScanSC10(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7845,7 +7845,7 @@ func mallocgcSmallNoScanSC10(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7910,7 +7910,7 @@ func mallocgcSmallNoScanSC11(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -7981,7 +7981,7 @@ func mallocgcSmallNoScanSC11(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8046,7 +8046,7 @@ func mallocgcSmallNoScanSC12(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8117,7 +8117,7 @@ func mallocgcSmallNoScanSC12(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8182,7 +8182,7 @@ func mallocgcSmallNoScanSC13(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8253,7 +8253,7 @@ func mallocgcSmallNoScanSC13(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8318,7 +8318,7 @@ func mallocgcSmallNoScanSC14(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8389,7 +8389,7 @@ func mallocgcSmallNoScanSC14(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8454,7 +8454,7 @@ func mallocgcSmallNoScanSC15(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8525,7 +8525,7 @@ func mallocgcSmallNoScanSC15(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8590,7 +8590,7 @@ func mallocgcSmallNoScanSC16(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8661,7 +8661,7 @@ func mallocgcSmallNoScanSC16(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8726,7 +8726,7 @@ func mallocgcSmallNoScanSC17(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8797,7 +8797,7 @@ func mallocgcSmallNoScanSC17(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8862,7 +8862,7 @@ func mallocgcSmallNoScanSC18(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8933,7 +8933,7 @@ func mallocgcSmallNoScanSC18(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -8998,7 +8998,7 @@ func mallocgcSmallNoScanSC19(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9069,7 +9069,7 @@ func mallocgcSmallNoScanSC19(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9134,7 +9134,7 @@ func mallocgcSmallNoScanSC20(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9205,7 +9205,7 @@ func mallocgcSmallNoScanSC20(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9270,7 +9270,7 @@ func mallocgcSmallNoScanSC21(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9341,7 +9341,7 @@ func mallocgcSmallNoScanSC21(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9406,7 +9406,7 @@ func mallocgcSmallNoScanSC22(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9477,7 +9477,7 @@ func mallocgcSmallNoScanSC22(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9542,7 +9542,7 @@ func mallocgcSmallNoScanSC23(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9613,7 +9613,7 @@ func mallocgcSmallNoScanSC23(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9678,7 +9678,7 @@ func mallocgcSmallNoScanSC24(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9749,7 +9749,7 @@ func mallocgcSmallNoScanSC24(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9814,7 +9814,7 @@ func mallocgcSmallNoScanSC25(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9885,7 +9885,7 @@ func mallocgcSmallNoScanSC25(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -9950,7 +9950,7 @@ func mallocgcSmallNoScanSC26(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { @@ -10021,7 +10021,7 @@ func mallocgcSmallNoScanSC26(size uintptr, typ *_type, needzero bool) unsafe.Poi gp := getg() if goexperiment.RuntimeSecret && gp.secret > 0 { - addSecret(x) + addSecret(x, size) } if valgrindenabled { -- cgit v1.3