snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1

Содержимое пина, зафиксированного в go.mod sing-box-lx, одним коммитом
без истории. Полная история SagerNet/gvisor — 1.45 ГБ и клонируется в
каждой CI-джобе; наша дельта — одна вставка в одну функцию, история для
неё не нужна.

Module path github.com/sagernet/gvisor сохранён намеренно: на него
опирается replace-директива суперпроекта.

Патч поверх — отдельным коммитом, чтобы дельта читалась одним git show
и переносилась на новый пин копированием.

SPECS/TASKS/048-GVISOR_HANDSHAKE_NIL_CRASH
This commit is contained in:
Leadaxe 2026-08-04 15:50:08 +03:00
commit 2c4ae3b0a4
712 changed files with 185689 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,62 @@
// Copyright 2021 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.
package network
import (
"fmt"
"github.com/sagernet/gvisor/pkg/tcpip"
"github.com/sagernet/gvisor/pkg/tcpip/stack"
"github.com/sagernet/gvisor/pkg/tcpip/transport"
)
// Resume implements tcpip.ResumableEndpoint.Resume.
func (e *Endpoint) Resume(s *stack.Stack) error {
e.mu.Lock()
defer e.mu.Unlock()
e.stack = s
for m := range e.multicastMemberships {
if err := e.stack.JoinGroup(e.netProto, m.nicID, m.multicastAddr); err != nil {
return fmt.Errorf("e.stack.JoinGroup(%d, %d, %s): %s", e.netProto, m.nicID, m.multicastAddr, err)
}
}
info := e.Info()
switch state := e.State(); state {
case transport.DatagramEndpointStateInitial, transport.DatagramEndpointStateClosed:
case transport.DatagramEndpointStateBound:
if info.ID.LocalAddress.BitLen() != 0 && !e.isBroadcastOrMulticast(info.RegisterNICID, e.effectiveNetProto, info.ID.LocalAddress) {
if e.stack.CheckLocalAddress(info.RegisterNICID, e.effectiveNetProto, info.ID.LocalAddress) == 0 {
return fmt.Errorf("got e.stack.CheckLocalAddress(%d, %d, %s) = 0, want != 0", info.RegisterNICID, e.effectiveNetProto, info.ID.LocalAddress)
}
}
case transport.DatagramEndpointStateConnected:
var err tcpip.Error
multicastLoop := e.ops.GetMulticastLoop()
// Release the connectedRoute if present.
if e.connectedRoute != nil {
e.connectedRoute.Release()
}
e.connectedRoute, err = e.stack.FindRoute(info.RegisterNICID, info.ID.LocalAddress, info.ID.RemoteAddress, e.effectiveNetProto, multicastLoop)
if err != nil {
return fmt.Errorf("e.stack.FindRoute(%d, %s, %s, %d, %t): %s", info.RegisterNICID, info.ID.LocalAddress, info.ID.RemoteAddress, e.effectiveNetProto, multicastLoop, err)
}
default:
panic(fmt.Sprintf("unhandled state = %s", state))
}
return nil
}

View file

@ -0,0 +1,121 @@
// automatically generated by stateify.
package network
import (
"context"
"github.com/sagernet/gvisor/pkg/state"
)
func (e *Endpoint) StateTypeName() string {
return "pkg/tcpip/transport/internal/network.Endpoint"
}
func (e *Endpoint) StateFields() []string {
return []string{
"stack",
"ops",
"netProto",
"transProto",
"waiterQueue",
"wasBound",
"owner",
"writeShutdown",
"effectiveNetProto",
"multicastMemberships",
"ipv4TTL",
"ipv6HopLimit",
"multicastTTL",
"multicastAddr",
"multicastNICID",
"ipv4TOS",
"ipv6TClass",
"info",
"state",
}
}
func (e *Endpoint) beforeSave() {}
// +checklocksignore
func (e *Endpoint) StateSave(stateSinkObject state.Sink) {
e.beforeSave()
stateSinkObject.Save(0, &e.stack)
stateSinkObject.Save(1, &e.ops)
stateSinkObject.Save(2, &e.netProto)
stateSinkObject.Save(3, &e.transProto)
stateSinkObject.Save(4, &e.waiterQueue)
stateSinkObject.Save(5, &e.wasBound)
stateSinkObject.Save(6, &e.owner)
stateSinkObject.Save(7, &e.writeShutdown)
stateSinkObject.Save(8, &e.effectiveNetProto)
stateSinkObject.Save(9, &e.multicastMemberships)
stateSinkObject.Save(10, &e.ipv4TTL)
stateSinkObject.Save(11, &e.ipv6HopLimit)
stateSinkObject.Save(12, &e.multicastTTL)
stateSinkObject.Save(13, &e.multicastAddr)
stateSinkObject.Save(14, &e.multicastNICID)
stateSinkObject.Save(15, &e.ipv4TOS)
stateSinkObject.Save(16, &e.ipv6TClass)
stateSinkObject.Save(17, &e.info)
stateSinkObject.Save(18, &e.state)
}
func (e *Endpoint) afterLoad(context.Context) {}
// +checklocksignore
func (e *Endpoint) StateLoad(ctx context.Context, stateSourceObject state.Source) {
stateSourceObject.Load(0, &e.stack)
stateSourceObject.Load(1, &e.ops)
stateSourceObject.Load(2, &e.netProto)
stateSourceObject.Load(3, &e.transProto)
stateSourceObject.Load(4, &e.waiterQueue)
stateSourceObject.Load(5, &e.wasBound)
stateSourceObject.Load(6, &e.owner)
stateSourceObject.Load(7, &e.writeShutdown)
stateSourceObject.Load(8, &e.effectiveNetProto)
stateSourceObject.Load(9, &e.multicastMemberships)
stateSourceObject.Load(10, &e.ipv4TTL)
stateSourceObject.Load(11, &e.ipv6HopLimit)
stateSourceObject.Load(12, &e.multicastTTL)
stateSourceObject.Load(13, &e.multicastAddr)
stateSourceObject.Load(14, &e.multicastNICID)
stateSourceObject.Load(15, &e.ipv4TOS)
stateSourceObject.Load(16, &e.ipv6TClass)
stateSourceObject.Load(17, &e.info)
stateSourceObject.Load(18, &e.state)
}
func (m *multicastMembership) StateTypeName() string {
return "pkg/tcpip/transport/internal/network.multicastMembership"
}
func (m *multicastMembership) StateFields() []string {
return []string{
"nicID",
"multicastAddr",
}
}
func (m *multicastMembership) beforeSave() {}
// +checklocksignore
func (m *multicastMembership) StateSave(stateSinkObject state.Sink) {
m.beforeSave()
stateSinkObject.Save(0, &m.nicID)
stateSinkObject.Save(1, &m.multicastAddr)
}
func (m *multicastMembership) afterLoad(context.Context) {}
// +checklocksignore
func (m *multicastMembership) StateLoad(ctx context.Context, stateSourceObject state.Source) {
stateSourceObject.Load(0, &m.nicID)
stateSourceObject.Load(1, &m.multicastAddr)
}
func init() {
state.Register((*Endpoint)(nil))
state.Register((*multicastMembership)(nil))
}

View file

@ -0,0 +1,177 @@
// Copyright 2021 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.
// Package noop contains an endpoint that implements all tcpip.Endpoint
// functions as noops.
package noop
import (
"fmt"
"io"
"github.com/sagernet/gvisor/pkg/tcpip"
"github.com/sagernet/gvisor/pkg/tcpip/stack"
"github.com/sagernet/gvisor/pkg/waiter"
)
// endpoint can be created, but all interactions have no effect or
// return errors.
//
// +stateify savable
type endpoint struct {
tcpip.DefaultSocketOptionsHandler
ops tcpip.SocketOptions
}
// New returns an initialized noop endpoint.
func New(stk *stack.Stack) tcpip.Endpoint {
// ep.ops must be in a valid, initialized state for callers of
// ep.SocketOptions.
var ep endpoint
ep.ops.InitHandler(&ep, stk, tcpip.GetStackSendBufferLimits, tcpip.GetStackReceiveBufferLimits)
return &ep
}
// Abort implements stack.TransportEndpoint.Abort.
func (*endpoint) Abort() {
// No-op.
}
// Close implements tcpip.Endpoint.Close.
func (*endpoint) Close() {
// No-op.
}
// ModerateRecvBuf implements tcpip.Endpoint.ModerateRecvBuf.
func (*endpoint) ModerateRecvBuf(int) {
// No-op.
}
func (*endpoint) SetOwner(tcpip.PacketOwner) {
// No-op.
}
// Read implements tcpip.Endpoint.Read.
func (*endpoint) Read(io.Writer, tcpip.ReadOptions) (tcpip.ReadResult, tcpip.Error) {
return tcpip.ReadResult{}, &tcpip.ErrNotPermitted{}
}
// Write implements tcpip.Endpoint.Write.
func (*endpoint) Write(tcpip.Payloader, tcpip.WriteOptions) (int64, tcpip.Error) {
return 0, &tcpip.ErrNotPermitted{}
}
// Disconnect implements tcpip.Endpoint.Disconnect.
func (*endpoint) Disconnect() tcpip.Error {
return &tcpip.ErrNotSupported{}
}
// Connect implements tcpip.Endpoint.Connect.
func (*endpoint) Connect(tcpip.FullAddress) tcpip.Error {
return &tcpip.ErrNotPermitted{}
}
// Shutdown implements tcpip.Endpoint.Shutdown.
func (*endpoint) Shutdown(tcpip.ShutdownFlags) tcpip.Error {
return &tcpip.ErrNotPermitted{}
}
// Listen implements tcpip.Endpoint.Listen.
func (*endpoint) Listen(int) tcpip.Error {
return &tcpip.ErrNotSupported{}
}
// Accept implements tcpip.Endpoint.Accept.
func (*endpoint) Accept(*tcpip.FullAddress) (tcpip.Endpoint, *waiter.Queue, tcpip.Error) {
return nil, nil, &tcpip.ErrNotSupported{}
}
// Bind implements tcpip.Endpoint.Bind.
func (*endpoint) Bind(tcpip.FullAddress) tcpip.Error {
return &tcpip.ErrNotPermitted{}
}
// GetLocalAddress implements tcpip.Endpoint.GetLocalAddress.
func (*endpoint) GetLocalAddress() (tcpip.FullAddress, tcpip.Error) {
return tcpip.FullAddress{}, &tcpip.ErrNotSupported{}
}
// GetRemoteAddress implements tcpip.Endpoint.GetRemoteAddress.
func (*endpoint) GetRemoteAddress() (tcpip.FullAddress, tcpip.Error) {
return tcpip.FullAddress{}, &tcpip.ErrNotConnected{}
}
// Readiness implements tcpip.Endpoint.Readiness.
func (*endpoint) Readiness(waiter.EventMask) waiter.EventMask {
return 0
}
// SetSockOpt implements tcpip.Endpoint.SetSockOpt.
func (*endpoint) SetSockOpt(tcpip.SettableSocketOption) tcpip.Error {
return &tcpip.ErrUnknownProtocolOption{}
}
func (*endpoint) SetSockOptInt(tcpip.SockOptInt, int) tcpip.Error {
return &tcpip.ErrUnknownProtocolOption{}
}
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
func (*endpoint) GetSockOpt(tcpip.GettableSocketOption) tcpip.Error {
return &tcpip.ErrUnknownProtocolOption{}
}
// GetSockOptInt implements tcpip.Endpoint.GetSockOptInt.
func (*endpoint) GetSockOptInt(tcpip.SockOptInt) (int, tcpip.Error) {
return 0, &tcpip.ErrUnknownProtocolOption{}
}
// HandlePacket implements stack.RawTransportEndpoint.HandlePacket.
func (*endpoint) HandlePacket(pkt *stack.PacketBuffer) {
panic(fmt.Sprintf("unreachable: noop.endpoint should never be registered, but got packet: %+v", pkt))
}
// State implements socket.Socket.State.
func (*endpoint) State() uint32 {
return 0
}
// Wait implements stack.TransportEndpoint.Wait.
func (*endpoint) Wait() {
// No-op.
}
// Release implements stack.TransportEndpoint.Release.
func (*endpoint) Release() {
// No-op.
}
// LastError implements tcpip.Endpoint.LastError.
func (*endpoint) LastError() tcpip.Error {
return nil
}
// SocketOptions implements tcpip.Endpoint.SocketOptions.
func (ep *endpoint) SocketOptions() *tcpip.SocketOptions {
return &ep.ops
}
// Info implements tcpip.Endpoint.Info.
func (*endpoint) Info() tcpip.EndpointInfo {
return &stack.TransportEndpointInfo{}
}
// Stats returns a pointer to the endpoint stats.
func (*endpoint) Stats() tcpip.EndpointStats {
return &tcpip.TransportEndpointStats{}
}

View file

@ -0,0 +1,41 @@
// automatically generated by stateify.
package noop
import (
"context"
"github.com/sagernet/gvisor/pkg/state"
)
func (ep *endpoint) StateTypeName() string {
return "pkg/tcpip/transport/internal/noop.endpoint"
}
func (ep *endpoint) StateFields() []string {
return []string{
"DefaultSocketOptionsHandler",
"ops",
}
}
func (ep *endpoint) beforeSave() {}
// +checklocksignore
func (ep *endpoint) StateSave(stateSinkObject state.Sink) {
ep.beforeSave()
stateSinkObject.Save(0, &ep.DefaultSocketOptionsHandler)
stateSinkObject.Save(1, &ep.ops)
}
func (ep *endpoint) afterLoad(context.Context) {}
// +checklocksignore
func (ep *endpoint) StateLoad(ctx context.Context, stateSourceObject state.Source) {
stateSourceObject.Load(0, &ep.DefaultSocketOptionsHandler)
stateSourceObject.Load(1, &ep.ops)
}
func init() {
state.Register((*endpoint)(nil))
}