snapshot: sagernet/gvisor v0.0.0-20260727.0-sing-box-mod.1 + SPEC 048 guard

Обновление снапшота с v0.0.0-20250811.0 на пин, которого требует
sing-box после мержа 235 коммитов (upstream d620bbbf2 "Update gvisor to
20260727.0"). Прежний снапшот был взят 2026-08-04 ровно с той версии,
на которой тогда стоял апстрим; разрыв возник 2026-08-05 вместе с его
бампом.

За год апстрим-gvisor изменил ~14 000 строк в 292 файлах. Значимое для
нас — сетевой стек: tcp/connect.go (PMTU-discovery + исправление
начального RTT/RTO: раньше задержка ACK внутри стека завышала стартовый
таймаут на несколько RTT), tcp/snd.go, tcp/rcv.go, stack/conntrack.go,
stack/packet_buffer.go. Всего 30 файлов в TCP и 37 в stack.

Баг SPEC 048 апстрим НЕ исправил — проверено по коду новой версии:
handleConnecting по-прежнему проверяет состояние endpoint'а, но не ep.h,
а performHandshake так же зануляет h и отпускает мьютекс до Close().
Поэтому guard перенесён (12 строк) вместе со своим тестом (45 строк).

Red/green проверен на новой базе: без guard'а тест падает с той же
nil-паникой, что в полевом крашдампе; с ним зелёный.
This commit is contained in:
Leadaxe 2026-08-05 14:53:31 +03:00
parent ffebe42860
commit 117243aa02
293 changed files with 16413 additions and 2842 deletions

View file

@ -101,6 +101,18 @@ func (v Addr) ToRange(length uint64) (AddrRange, bool) {
return AddrRange{v, end}, ok
}
// MustToRange is equivalent to ToRange, but panics if the end of the range
// wraps around.
//
//go:nosplit
func (v Addr) MustToRange(length uint64) AddrRange {
ar, ok := v.ToRange(length)
if !ok {
panic("hostarch.Addr.ToRange() wraps")
}
return ar
}
// IsPageAligned returns true if ar.Start.IsPageAligned() and
// ar.End.IsPageAligned().
func (ar AddrRange) IsPageAligned() bool {

View file

@ -4,5 +4,23 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd.
// Package hostarch contains host arch address operations for user memory.
// Package hostarch contains machine architecture parameters.
package hostarch
import (
"encoding/binary"
"fmt"
)
// EndianString returns "little" if the invoking process is little-endian and
// "big" if the invoking process is big-endian.
func EndianString() string {
switch val := binary.NativeEndian.Uint32([]byte{0x01, 0x02, 0x03, 0x04}); val {
case 0x01020304:
return "big"
case 0x04030201:
return "little"
default:
panic(fmt.Sprintf("unknown endianness: [01 02 03 04] => %#x", val))
}
}

View file

@ -13,36 +13,30 @@
// limitations under the License.
//go:build arm64
// +build arm64
package hostarch
import (
"encoding/binary"
"golang.org/x/sys/unix"
)
import "encoding/binary"
const (
// PageSize is the system page size.
// arm64 support 4K/16K/64K page size,
// which can be get by unix.Getpagesize().
// Currently, only 4K page size is supported.
// Currently, only 4K page size is supported by default,
// or 64K pages by using the pagesize_64k build tag.
PageSize = 1 << PageShift
// HugePageSize is the system huge page size.
HugePageSize = 1 << HugePageShift
// JumboPageSize is the 1GB jumbo page size.
JumboPageSize = 1 << JumboPageShift
// CacheLineSize is the size of the cache line.
CacheLineSize = 1 << CacheLineShift
// PageShift is the binary log of the system page size.
PageShift = 12
// HugePageShift is the binary log of the system huge page size.
// Should be calculated by "PageShift + (PageShift - 3)"
// when multiple page size support is ready.
HugePageShift = 21
// JumboPageShift is the binary log of jumbo page whose size is 1GB.
JumboPageShift = 30
// CacheLineShift is the binary log of the cache line size.
CacheLineShift = 6
@ -89,10 +83,3 @@ func ESRAccessType(code uint64) AccessType {
func UntaggedUserAddr(addr Addr) Addr {
return Addr(int64(addr<<8) >> 8)
}
func init() {
// Make sure the page size is 4K on arm64 platform.
if size := unix.Getpagesize(); size != PageSize {
panic("Only 4K page size is supported on arm64!")
}
}

View file

@ -0,0 +1,36 @@
// Copyright 2026 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build arm64 && !pagesize_64k
package hostarch
import "golang.org/x/sys/unix"
const (
// PageShift is the binary log of the system page size.
// 4K pages: 2^12 = 4096
PageShift = 12
// HugePageShift is the binary log of the system huge page size.
// For 4K pages: PageShift + (PageShift - 3) = 12 + 9 = 21
// This gives 2MB huge pages.
HugePageShift = 21
)
func init() {
if size := unix.Getpagesize(); size != PageSize {
println("WARNING: host page size mismatch - running on non-4K host")
}
}

View file

@ -0,0 +1,6 @@
// automatically generated by stateify.
//go:build arm64 && !pagesize_64k
// +build arm64,!pagesize_64k
package hostarch

View file

@ -0,0 +1,36 @@
// Copyright 2026 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build arm64 && pagesize_64k
package hostarch
import "golang.org/x/sys/unix"
const (
// PageShift is the binary log of the system page size.
// 64K pages: 2^16 = 65536
PageShift = 16
// HugePageShift is the binary log of the system huge page size.
// For 64K pages: PageShift + (PageShift - 3) = 16 + 13 = 29
// This gives 512MB huge pages.
HugePageShift = 29
)
func init() {
if size := unix.Getpagesize(); size != PageSize {
println("WARNING: host page size mismatch - running on non-64K host")
}
}

View file

@ -0,0 +1,6 @@
// automatically generated by stateify.
//go:build arm64 && pagesize_64k
// +build arm64,pagesize_64k
package hostarch

View file

@ -26,6 +26,9 @@ const (
// HugePageSize is the system huge page size.
HugePageSize = 1 << HugePageShift
// JumboPageSize is the 1GB jumbo page size.
JumboPageSize = 1 << JumboPageShift
// CacheLineSize is the size of the cache line.
CacheLineSize = 1 << CacheLineShift
@ -35,6 +38,9 @@ const (
// HugePageShift is the binary log of the system huge page size.
HugePageShift = 21
// JumboPageShift is the binary log of jumbo page whose size is 1GB.
JumboPageShift = 30
// CacheLineShift is the binary log of the cache line size.
CacheLineShift = 6
)

View file

@ -11,10 +11,11 @@ const (
PageMask = PageSize - 1
HugePageMask = HugePageSize - 1
CacheLineMask = CacheLineSize - 1
JumboPageMask = ^uintptr(JumboPageSize - 1)
)
type bytecount interface {
~uint | ~uint16 | ~uint32 | ~uint64 | ~uintptr
~uint | ~uint32 | ~uint64 | ~uintptr
}
type hugebytecount interface {
@ -112,3 +113,13 @@ func CacheLineRoundUp[T bytecount](x T) (val T, ok bool) {
ok = val >= x
return
}
// MustCacheLineRoundUp is equivalent to CacheLineRoundUp, but panics if
// rounding up overflows.
func MustCacheLineRoundUp[T bytecount](x T) T {
val, ok := CacheLineRoundUp(x)
if !ok {
panic("CacheLineRoundUp overflows")
}
return val
}