`idToGuestCID` generates frequent vsock CID collisions due to limited output space

Aperta
#688 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

  • #895 di @Cicada1107 — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Inizia con idToGuestCID in pkg/unikontainers/vaccel.go, quindi segui il suo utilizzo da Exec in pkg/unikontainers/unikontainers.go fino a qemu.go, firecracker.go e cloud_hypervisor.go. Esamina i vincoli attuali del CID di vhost-vsock e individua come verificare il comportamento di hashing o di ritentativo scelto. Il lavoro è completato quando i container concorrenti non falliscono più a causa di collisioni CID prevedibili, con copertura per il caso di anagramma segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

HW accel Monitors Stale

Description

The idToGuestCID function in pkg/unikontainers/vaccel.go generates vhost-vsock Context Identifiers (CIDs) by summing the ASCII values of a container ID and applying mod 97. This restricts the entire output space to just 97 possible CIDs (range [3, 99]).

Since standard container IDs (e.g., from containerd) are 64-character hex strings, this constrained output space leads to frequent collisions. In a multi-container vAccel deployment, the probability of a CID collision exceeds 50% with just 13 concurrent containers.

When a collision occurs, the hypervisor passes the duplicate guest-cid to the kernel, which rejects the binding with EADDRINUSE. Because urunc does not currently implement collision detection or retry logic during the Exec phase, the container initialization fails.

Furthermore, because the hashing mechanism relies on a simple character sum, container IDs that are anagrams of each other (which is common with hex-encoded strings) will deterministically collide.

Root Cause

  • pkg/unikontainers/vaccel.go does the (sum % 97) + 3 math.
  • pkg/unikontainers/unikontainers.go calls it during container Exec().
  • The hypervisors (qemu.go, firecracker.go, cloud_hypervisor.go) then pass this blindly to the kernel.

Reproducer for Anagram Collisions

def id_to_guest_cid(id_str):
    return (sum(ord(c) for c in id_str) % 97) + 3

id1 = "abcdef0123456789" * 4
id2 = "9876543210fedcba" * 4

# Both IDs share the same character distribution
assert id_to_guest_cid(id1) == id_to_guest_cid(id2) # Evaluates to 29

Proposed Solution

Replace the character sum with a non-cryptographic hash (e.g., hash/fnv) over the container ID, and map it to the full available vhost-vsock CID range ([3, 1<<32 - 1]).

Alternatively, if CIDs must be strictly deterministic and collision-free across arbitrary host states, implement a probe-and-retry mechanism to verify CID availability before executing the VMM.

Lingua principale
Go
Stelle
308
Fork
222
Merge medio
2g 13h
PR unite (30g)
43

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di urunc-dev/urunc

Tutte le issue di urunc-dev/urunc

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.