Skip to content

Commit 7ce3617

Browse files
jrickianlancetaylor
authored andcommitted
net: only perform IPv4 map check for AF_INET6 sockets
This change avoids executing syscalls testing if IPv4 address mapping is possible unless the socket being opened belongs to the AF_INET6 family. In a pledged OpenBSD process, this test is only allowed when the "inet" pledge is granted; however this check was also being performed for AF_UNIX sockets (separately permitted under the "unix" pledge), and would cause the process to be killed by the kernel. By avoiding the IPv4 address mapping check until the socket is checked to be AF_INET6, a pledged OpenBSD process using AF_UNIX sockets without the "inet" pledge won't be killed for this misbehavior. The OpenBSD kernel is not currently ready to support using UNIX domain sockets with only the "unix" pledge (and without "inet"), but this is one change necessary to support this. Change-Id: If6962a7ad999b71bcfc9fd8e10d9c4067fa3f338 GitHub-Last-Rev: 3c5541b GitHub-Pull-Request: #45155 Reviewed-on: https://go-review.googlesource.com/c/go/+/303276 Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Tobias Klauser <[email protected]> Reviewed-by: Aaron Bieber <[email protected]> Trust: Ian Lance Taylor <[email protected]>
1 parent 569c86d commit 7ce3617

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/net/sockopt_bsd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func setDefaultSockopts(s, family, sotype int, ipv6only bool) error {
2626
syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_PORTRANGE, syscall.IPV6_PORTRANGE_HIGH)
2727
}
2828
}
29-
if supportsIPv4map() && family == syscall.AF_INET6 && sotype != syscall.SOCK_RAW {
29+
if family == syscall.AF_INET6 && sotype != syscall.SOCK_RAW && supportsIPv4map() {
3030
// Allow both IP versions even if the OS default
3131
// is otherwise. Note that some operating systems
3232
// never admit this option.

0 commit comments

Comments
 (0)