]> Cypherpunks repositories - gostls13.git/commit
net: pass MSG_CMSG_CLOEXEC flag in ReadMsgUnix
authorHowJMay <vulxj0j8j8@gmail.com>
Mon, 19 Apr 2021 18:06:54 +0000 (18:06 +0000)
committerIan Lance Taylor <iant@golang.org>
Mon, 19 Apr 2021 21:27:43 +0000 (21:27 +0000)
commite97d8eb027c0067f757860b6f766644de15941f2
tree0293d4cafe26127f9563f56a8e11bbe1554046c0
parentbbb510ccc96e2ca1d0d1c91d244fba4e735d5a80
net: pass MSG_CMSG_CLOEXEC flag in ReadMsgUnix

As mentioned in #42765, calling "recvmsg" syscall on Linux should come
with "MSG_CMSG_CLOEXEC" flag.

For other systems which not supports "MSG_CMSG_CLOEXEC". ReadMsgUnix()
would check the header. If the header type is "syscall.SCM_RIGHTS",
then ReadMsgUnix() would parse the SocketControlMessage and call each
fd with "syscall.CloseOnExec"

Fixes #42765

Change-Id: I74347db72b465685d7684bf0f32415d285845ebb
GitHub-Last-Rev: ca59e2c9e0e8de1ae590e9b6dc165cb768a574f5
GitHub-Pull-Request: golang/go#42768
Reviewed-on: https://go-review.googlesource.com/c/go/+/272226
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
12 files changed:
src/internal/poll/fd_unix.go
src/internal/poll/fd_windows.go
src/net/fd_posix.go
src/net/iprawsock_posix.go
src/net/net_fake.go
src/net/udpsock_posix.go
src/net/unixsock_posix.go
src/net/unixsock_readmsg_linux.go [new file with mode: 0644]
src/net/unixsock_readmsg_other.go [new file with mode: 0644]
src/net/unixsock_readmsg_posix.go [new file with mode: 0644]
src/net/unixsock_readmsg_test.go [new file with mode: 0644]
src/syscall/creds_test.go