-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
route: treat short sockaddr lengths as unspecified #231
Conversation
This PR (HEAD: 90f9dd9) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/646556. Important tips:
|
Message from Ian Lance Taylor: Patch Set 1: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Go LUCI: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-02-04T23:46:16Z","revision":"b41e97f5344addd77d867722ea68bd205adcc8ab"} Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Ian Lance Taylor: Patch Set 1: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Go LUCI: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Go LUCI: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
90f9dd9
to
085b4ee
Compare
Message from Ian Lance Taylor: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
This PR (HEAD: 085b4ee) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/646556. Important tips:
|
Previously, we enforced minimum length requirements for sockaddr, but the route command can legitimately parse shorter lengths. This change treats any sockaddr with length less than the address offset as an unspecified address (0.0.0.0 for IPv4 or :: for IPv6), as discern by monitoring the route command. To replicate the issue, prior to the fix, execute the following: First, ```console route -n monitor ``` Next, ```console sudo route -n add -inet6 -ifscope en11 -net :: \ -netmask :: fe80::2d0:4cff:fe10:15d2 ``` The route command that is actively monitor will print something such as, ```console RTM_ADD: Add Route: len 152, pid: 81198, seq 1, errno 0, ifscope 13, flags:<UP,GATEWAY,DONE,STATIC,IFSCOPE> locks: inits: sockaddrs: <DST,GATEWAY,NETMASK> :: fe80::2d0:4cff:fe10:15d2 :: ``` Prior to the fix, if you had parse the above message, PareRIB would have returned errInvalidAddr which is clearly false. Fixes golang/go#71557
Message from Carlos Hernandez: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
085b4ee
to
396d8a2
Compare
This PR (HEAD: 396d8a2) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/646556. Important tips:
|
Message from Damien Neil: Patch Set 2: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Ian Lance Taylor: Patch Set 3: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Carlos Hernandez: Patch Set 3: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
On Darwin, the AF_FAMILY byte of a sockaddr for a netmask or genmask can be ignored if unreasonable. In such cases, it is the family of the DST address that should instead be used. Depends on golang#231. Fixes golang/go#71578.
Message from Ian Lance Taylor: Patch Set 5: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Go LUCI: Patch Set 5: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-02-06T18:17:08Z","revision":"d18399381daf5e8d6ef5d5e1b807b9c0cb3b6524"} Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Ian Lance Taylor: Patch Set 5: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Go LUCI: Patch Set 5: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Message from Go LUCI: Patch Set 5: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/646556. |
Previously, we enforced minimum length requirements for sockaddr, but the route command can legitimately parse shorter lengths. This change treats any sockaddr with length less than the address offset as an unspecified address (0.0.0.0 for IPv4 or :: for IPv6), as discern by monitoring the route command. To replicate the issue, prior to the fix, execute the following: First: route -n monitor Next: sudo route -n add -inet6 -ifscope en11 -net :: \ -netmask :: fe80::2d0:4cff:fe10:15d2 The route command that is actively monitoring will print something such as: RTM_ADD: Add Route: len 152, pid: 81198, seq 1, errno 0, ifscope 13, flags:<UP,GATEWAY,DONE,STATIC,IFSCOPE> locks: inits: sockaddrs: <DST,GATEWAY,NETMASK> :: fe80::2d0:4cff:fe10:15d2 :: Prior to the fix, if you had attempted parse the above message, PareRIB would have returned errInvalidAddr which is clearly false. Fixes golang/go#71557 Change-Id: Iec86cc9b05a765b6e67e95a4e30ff31f66f3d17e GitHub-Last-Rev: 396d8a2 GitHub-Pull-Request: #231 Reviewed-on: https://go-review.googlesource.com/c/net/+/646556 Commit-Queue: Ian Lance Taylor <[email protected]> Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
This PR is being closed because golang.org/cl/646556 has been merged. |
Previously, we enforced minimum length requirements for sockaddr, but
the route command can legitimately parse shorter lengths. This change
treats any sockaddr with length less than the address offset as an
unspecified address (0.0.0.0 for IPv4 or :: for IPv6), as discern by
monitoring the route command.
To replicate the issue, prior to the fix, execute the following:
First:
route -n monitor
Next:
sudo route -n add -inet6 -ifscope en11 -net ::
-netmask :: fe80::2d0:4cff:fe10:15d2
The route command that is actively monitoring will print something such
as:
RTM_ADD: Add Route: len 152, pid: 81198, seq 1, errno 0, ifscope 13, flags:<UP,GATEWAY,DONE,STATIC,IFSCOPE>
locks: inits:
sockaddrs: <DST,GATEWAY,NETMASK>
:: fe80::2d0:4cff:fe10:15d2 ::
Prior to the fix, if you had attempted parse the above message, PareRIB
would have returned errInvalidAddr which is clearly false.
Fixes golang/go#71557