Repository navigation
Fix nil pointer dereference in IOInfoService.UpdateIngressState on concurrent DeleteIngress - #4806
Conversation
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
LoadIngress reads the ingress info and its state from two separate Redis keys non-atomically, while DeleteIngress removes both keys in a single transaction. If the delete lands between the two reads, LoadIngress returns an IngressInfo with a nil State and no error, and UpdateIngressState panics dereferencing info.State.Status — taking down the whole server with every room it hosts. The race fires in practice when an ingress session is being torn down by DeleteIngress and the ingress service reports the session state change concurrently: with short-lived per-room WHIP ingresses this crashed production servers within minutes (observed on v1.13.5 and v1.13.6, SIGSEGV at ioservice_ingress.go:82, addr=0x8). Guard the nil State by treating it as an empty state, matching how the store's UpdateIngressState already tolerates a missing state key.
32effcd to
568e561
Compare
biglittlebigben
left a comment
There was a problem hiding this comment.
This will recreate a (partial/corrupted) orphan ingress state for a deleted ingress, which isn't desirable.
|
We hit this independently on v1.13.6 (self-hosted, single node, Redis): same trace, same Our trigger is slightly different from the WHIP case above, which suggests the race isn't specific to one ingress type: a URL ingress plays hold audio in a SIP call room, and when the call is answered we Worth noting the aftermath, since it outlives the crash:
So a single |
…9 ➔ v1.13.10) (#2338) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` | --- ### Release Notes <details> <summary>livekit/livekit (docker.io/livekit/livekit-server)</summary> ### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10) [Compare Source](livekit/livekit@v1.13.9...v1.13.10) ##### Changed - sfu: forward the dependency descriptor for VP8 simulcast ([#​4987](livekit/livekit#4987)) - sfu: keep VP8 descriptor frame numbers across migration ([#​4989](livekit/livekit#4989)) - sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#​4991](livekit/livekit#4991)) - sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#​4976](livekit/livekit#4976)) - sfu: switch VP8 temporal layers up with the dependency descriptor ([#​4974](livekit/livekit#4974)) - sfu: pad the slot of a filtered packet that follows a sequence number gap ([#​4983](livekit/livekit#4983)) - sfu: send padding in the slot of a dropped out-of-order packet ([#​4979](livekit/livekit#4979)) - sfu: parse VP8 and VP9 payload descriptors without an allocation ([#​4981](livekit/livekit#4981)) - DownTrack: arm key frame requester timer only while a layer lock is pending ([#​4980](livekit/livekit#4980)) - turn: refuse TCP relays and limit relays to this host to media ports ([#​4992](livekit/livekit#4992)) - agent endpoints: address an unnamed deployment as "\_" ([#​4997](livekit/livekit#4997)) - Add OSS Scanner build image and threat model ([#​4995](livekit/livekit#4995)) - Update golang Docker tag to v1.27.1 ([#​4985](livekit/livekit#4985)) - Update alpine Docker tag to v3.24.2 ([#​4984](livekit/livekit#4984)) - Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#​4915](livekit/livekit#4915)) ##### Fixed - Send NACKs when processing RTX packets ([#​5000](livekit/livekit#5000)) - sfu: send padding-only packets with no payload ([#​4993](livekit/livekit#4993)) - rtc: release timed out pending tracks at the pending track limit ([#​4998](livekit/livekit#4998)) - Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#​4806](livekit/livekit#4806)) - rtc: keep update cache eviction order when listing recent disconnects ([#​4975](livekit/livekit#4975)) - fix(cli): return non-zero exit status on command errors ([#​4888](livekit/livekit#4888)) - Disable AV1 for Firefox clients before 157 ([#​4962](livekit/livekit#4962)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNTEuMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE1MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/2338
…v1.13.10) (#884) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` | --- ### Release Notes <details> <summary>livekit/livekit (docker.io/livekit/livekit-server)</summary> ### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10) [Compare Source](livekit/livekit@v1.13.9...v1.13.10) ##### Changed - sfu: forward the dependency descriptor for VP8 simulcast ([#​4987](livekit/livekit#4987)) - sfu: keep VP8 descriptor frame numbers across migration ([#​4989](livekit/livekit#4989)) - sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#​4991](livekit/livekit#4991)) - sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#​4976](livekit/livekit#4976)) - sfu: switch VP8 temporal layers up with the dependency descriptor ([#​4974](livekit/livekit#4974)) - sfu: pad the slot of a filtered packet that follows a sequence number gap ([#​4983](livekit/livekit#4983)) - sfu: send padding in the slot of a dropped out-of-order packet ([#​4979](livekit/livekit#4979)) - sfu: parse VP8 and VP9 payload descriptors without an allocation ([#​4981](livekit/livekit#4981)) - DownTrack: arm key frame requester timer only while a layer lock is pending ([#​4980](livekit/livekit#4980)) - turn: refuse TCP relays and limit relays to this host to media ports ([#​4992](livekit/livekit#4992)) - agent endpoints: address an unnamed deployment as "\_" ([#​4997](livekit/livekit#4997)) - Add OSS Scanner build image and threat model ([#​4995](livekit/livekit#4995)) - Update golang Docker tag to v1.27.1 ([#​4985](livekit/livekit#4985)) - Update alpine Docker tag to v3.24.2 ([#​4984](livekit/livekit#4984)) - Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#​4915](livekit/livekit#4915)) ##### Fixed - Send NACKs when processing RTX packets ([#​5000](livekit/livekit#5000)) - sfu: send padding-only packets with no payload ([#​4993](livekit/livekit#4993)) - rtc: release timed out pending tracks at the pending track limit ([#​4998](livekit/livekit#4998)) - Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#​4806](livekit/livekit#4806)) - rtc: keep update cache eviction order when listing recent disconnects ([#​4975](livekit/livekit#4975)) - fix(cli): return non-zero exit status on command errors ([#​4888](livekit/livekit#4888)) - Disable AV1 for Firefox clients before 157 ([#​4962](livekit/livekit#4962)) </details> --- ### Configuration 📅 **Schedule**: (in timezone Europe/London) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNjcuNSIsInVwZGF0ZWRJblZlciI6IjQ0LjE2Ny41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.hayden.moe/hayden/phoebe/pulls/884
… missing state in UpdateIngress/DeleteIngress (#5049) - pkg/service/redisstore.go: after the retry loop, return an error wrapping redis.TxFailedErr instead of nil. CreateIngress now fails instead of returning an ingress that was never written, StoreIngress stops before creating the orphan state key, and a dropped UpdateIngressState reaches the caller's existing error log. - pkg/service/ingress.go: the Fix nil pointer dereference in IOInfoService.UpdateIngressState on concurrent DeleteIngress #4806 guard applied to the two Twirp handlers, treating a nil State as empty. UpdateIngress then applies and stores the request; DeleteIngress deletes without calling the ingress service. - pkg/service/redisstore.go: UpdateIngress now fails with ErrIngressNotFound when the ingress no longer exists, checked inside the WATCH on the ingress hash so a later delete fails the EXEC. Without it an update racing a DeleteIngress recreated the deleted ingress and its stream key; this was possible before this PR whenever the delete landed after LoadIngress, and the guard in 2 widened the window to the gap between its two reads. The guard stays at the call sites to match #4806 and keep API responses unchanged.
LoadIngressreads the ingress info and its state from two separate Redis keys non-atomically, whileDeleteIngressremoves both keys in one transaction. If the delete lands between the two reads,LoadIngressreturns anIngressInfowith a nilStateand no error, andUpdateIngressStatepanics at theinfo.State.Statuscomparison — killing the server and every room it hosts:In practice the race fires when an ingress session is torn down by
DeleteIngresswhile the ingress service reports that session's state change. With short-lived per-room WHIP ingresses (created when a call is enqueued, deleted when it is answered or hung up) we crashed servers within minutes: two independent crashes on v1.13.6, both within 30ms of aDeleteIngresscall, one of them landing inside the delete's 16ms execution window on another node. The vulnerable code is identical on v1.13.5 and current master.The fix treats the missing state as an empty state, matching how the store's own
UpdateIngressStatealready tolerates a missing state key (it recreates it). Includes a regression test that reproduces the exact panic (SIGSEGV addr=0x8) without the fix and passes with it; the fullpkg/servicesuite stays green.