cmd/tailcat: fix genkey --embed-derp-map panic without a fixed region - #91
Merged
Merged
Conversation
genkey --embed-derp-map looked up dm.Regions[ci.RegionID] and used the result without checking it. With --region left at its "auto" default, ci.RegionID is -1, meaning "probe for the nearest region at each server startup", so the lookup missed and the nil *tailcfg.DERPRegion crashed on the next line. Nothing can be embedded in that case: embedding bakes one region's nodes into the address, which is the opposite of choosing the region later. Reject an explicit --region=auto as contradictory, and treat the "auto" default as a request to pick the nearest region now, exactly as --fixed-region does, since --embed-derp-map already implies a fixed region. Two adjacent forms reached the same nil lookup. A --region naming DERP hostnames leaves RegionID 0 while already embedding those nodes, so it is now a usage error; a numeric region absent from the DERP map now names the missing region instead of panicking. Thanks to Ray Chan for the report! Fixes tailscale#90 Reported-by: Ray Chan (https://github.com/chanchiwai-ray) Signed-off-by: Ben B <gmkbenjamin@hotmail.com>
bradfitz
approved these changes
Sep 4, 2026
Member
|
Thanks. The tests are pretty heavy, but I can lighten those up later if they start to annoy me :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
genkey --embed-derp-map looked up dm.Regions[ci.RegionID] and used the
result without checking it. With --region left at its "auto" default,
ci.RegionID is -1, meaning "probe for the nearest region at each server
startup", so the lookup missed and the nil *tailcfg.DERPRegion crashed
on the next line.
Nothing can be embedded in that case: embedding bakes one region's
nodes into the address, which is the opposite of choosing the region
later. Reject an explicit --region=auto as contradictory, and treat the
"auto" default as a request to pick the nearest region now, exactly as
--fixed-region does, since --embed-derp-map already implies a fixed
region.
Two adjacent forms reached the same nil lookup. A --region naming DERP
hostnames leaves RegionID 0 while already embedding those nodes, so it
is now a usage error; a numeric region absent from the DERP map now
names the missing region instead of panicking.
Thanks to Ray Chan for the report!
Fixes #90