Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV when kubefwd is provided with malformed reserve parameter #213

Open
mccaig opened this issue Nov 23, 2021 · 1 comment
Open

SIGSEGV when kubefwd is provided with malformed reserve parameter #213

mccaig opened this issue Nov 23, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@mccaig
Copy link

mccaig commented Nov 23, 2021

When using the -r command line option, kubefwd will SIGSEGV if the reserve string is malformed - specifically if a parameter is provided, but the colon is omitted. It fails gracefully if the parameter is not provided, or if it is provided, but with an invalid ip address.

Reproduce with:
kubefwd svc -r foo

INFO[18:28:52]  _          _           __             _
INFO[18:28:52] | | ___   _| |__   ___ / _|_      ____| |
INFO[18:28:52] | |/ / | | | '_ \ / _ \ |_\ \ /\ / / _  |
INFO[18:28:52] |   <| |_| | |_) |  __/  _|\ V  V / (_| |
INFO[18:28:52] |_|\_\\__,_|_.__/ \___|_|   \_/\_/ \__,_|
INFO[18:28:52]
INFO[18:28:52] Version 1.22.0
INFO[18:28:52] https://github.com/txn2/kubefwd
INFO[18:28:52]
INFO[18:28:52] Press [Ctrl-C] to stop forwarding.
INFO[18:28:52] 'cat /etc/hosts' to see all host entries.
INFO[18:28:52] Loaded hosts file /etc/hosts
INFO[18:28:52] HostFile management: Original hosts backup already exists at /Users/<snip>/hosts.original
INFO[18:28:52] Using namespace <...snip> from current context <...snip>.
INFO[18:28:52] Successfully connected context: <...snip>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1dbb177]

goroutine 97 [running]:
github.com/txn2/kubefwd/pkg/fwdIp.blockNonLoopbackIPs(0x2c894c0)
	github.com/txn2/kubefwd/pkg/fwdIp/fwdIp.go:197 +0x97
github.com/txn2/kubefwd/pkg/fwdIp.validateForwardConfiguration(0x1f27880)
	github.com/txn2/kubefwd/pkg/fwdIp/fwdIp.go:215 +0x1e
github.com/txn2/kubefwd/pkg/fwdIp.applyCLIPassedReservations({{0xc0008654d4, 0x9}, {0xc000d426c0, 0x2e}, {0xc000615a30, 0xf}, 0x0, 0x0, {0xc0000419c0, 0x1c}, ...}, ...)
	github.com/txn2/kubefwd/pkg/fwdIp/fwdIp.go:235 +0x53
github.com/txn2/kubefwd/pkg/fwdIp.getForwardConfiguration({{0xc0008654d4, 0x9}, {0xc000d426c0, 0x2e}, {0xc000615a30, 0xf}, 0x0, 0x0, {0xc0000419c0, 0x1c}, ...})
	github.com/txn2/kubefwd/pkg/fwdIp/fwdIp.go:246 +0xa5
github.com/txn2/kubefwd/pkg/fwdIp.getBaseUnreservedIP({{0xc0008654d4, 0x9}, {0xc000d426c0, 0x2e}, {0xc000615a30, 0xf}, 0x0, 0x0, {0xc0000419c0, 0x1c}, ...})
	github.com/txn2/kubefwd/pkg/fwdIp/fwdIp.go:174 +0x58
github.com/txn2/kubefwd/pkg/fwdIp.determineIP({0xc00038a380, 0x3c}, {{0xc0008654d4, 0x9}, {0xc000d426c0, 0x2e}, {0xc000615a30, 0xf}, 0x0, 0x0, ...})
	github.com/txn2/kubefwd/pkg/fwdIp/fwdIp.go:76 +0x78
github.com/txn2/kubefwd/pkg/fwdIp.GetIp({{0xc0008654d4, 0x9}, {0xc000d426c0, 0x2e}, {0xc000615a30, 0xf}, 0x0, 0x0, {0xc0000419c0, 0x1c}, ...})
	github.com/txn2/kubefwd/pkg/fwdIp/fwdIp.go:72 +0x2ab
github.com/txn2/kubefwd/pkg/fwdnet.ReadyInterface({{0xc0008654d4, 0x9}, {0xc000d426c0, 0x2e}, {0xc000615a30, 0xf}, 0x0, 0x0, {0xc0000419c0, 0x1c}, ...})
	github.com/txn2/kubefwd/pkg/fwdnet/fwdnet.go:18 +0x5a
github.com/txn2/kubefwd/pkg/fwdservice.(*ServiceFWD).LoopPodsToForward(0xc0002d3180, {0xc00052db90, 0x1, 0x2133920}, 0x0)
	github.com/txn2/kubefwd/pkg/fwdservice/fwdservice.go:250 +0x3f8
github.com/txn2/kubefwd/pkg/fwdservice.(*ServiceFWD).SyncPodForwards.func1()
	github.com/txn2/kubefwd/pkg/fwdservice/fwdservice.go:190 +0x312
github.com/txn2/kubefwd/pkg/fwdservice.(*ServiceFWD).SyncPodForwards(0xc0002d3180, 0x0)
	github.com/txn2/kubefwd/pkg/fwdservice/fwdservice.go:203 +0xb6
created by github.com/txn2/kubefwd/pkg/fwdsvcregistry.Add
	github.com/txn2/kubefwd/pkg/fwdsvcregistry/fwdsvcregistry.go:71 +0x285

kubefwd svc -r and kubefwd svc -r foo: will both fail gracefully.

@cjimti cjimti added the bug Something isn't working label Nov 24, 2021
@cjimti
Copy link
Member

cjimti commented Nov 24, 2021

@mccaig looks like it needs a little more validation. Thanks for the report

cjimti added a commit that referenced this issue Apr 28, 2022
validation for addressing issue #213
D3-LucaPiombino pushed a commit to CodeCoil/kubefwd that referenced this issue Jun 13, 2024
D3-LucaPiombino pushed a commit to CodeCoil/kubefwd that referenced this issue Jun 13, 2024
validation for addressing issue txn2#213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants