Commit Graph

1096 Commits

Author SHA1 Message Date
Mark Ryan
104d4017fa unix: add riscv_hwprobe for riscv64
The riscv_hwprobe system call was introduced in Linux 6.4 and allows
the caller to determine a number of interesting pieces of information
about the underlying RISC-V CPUs, e.g., which extensions they support
and whether they allow fast unaligned memory accesses.  For more information
please see:

https://docs.kernel.org/riscv/hwprobe.html

We also update linux/mksysnum.go to ensure that the generated syscall constants
written to the zsysnum_linux_*.go files are always sorted by their syscall numbers
in ascending order.

Updates golang/go#61416

Change-Id: Iedb0a86adb65faac9061b9a5969ffa09eb5b303a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/510795
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-07-26 11:14:25 +00:00
Ed Schouten
70f4e408de unix: retry fetching of lists through sysctl if the size changes
On macOS, the SysctlKinfoProcSlice() function may be used to fetch the contents of the process table. As the process table may grow between the first and second call to sysctl(), the second call may fail with ENOMEM. In that case we simply need to retry.

Change-Id: I40229653ed383603c33762f37b0dc2e7de47bcb6
GitHub-Last-Rev: b63b6b8471
GitHub-Pull-Request: golang/sys#169
Reviewed-on: https://go-review.googlesource.com/c/sys/+/513036
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-07-26 11:12:51 +00:00
Lorenz Brun
ad7130c58d unix: add more block device ioctl numbers
This adds a few additional ioctl numbers for performing various block
device operations.

Change-Id: I1dc836f4017bbc175b2dee759fece728f1caa010
Reviewed-on: https://go-review.googlesource.com/c/sys/+/511597
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-20 23:00:54 +00:00
cui fliter
c406141231 all: fix some typos
Change-Id: Id4bf4ce8aee8b98baa2f1a9c62a72a9554f7d557
Reviewed-on: https://go-review.googlesource.com/c/sys/+/510595
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-07-19 19:13:37 +00:00
Mauri de Souza Meneguzzo
25d0004552 unix: fix last argument of pselect6 on linux
On Linux, the last argument of pselect6 system call is **not** a
sigseg_t * pointer, but instead it is a structure of the form:

    struct {
        const sigset_t *ss;     /* Pointer to signal set */
        size_t          ss_len; /* Size (in bytes) of object pointed
    };

See man 2 pselect6.

Fixes #61251

Change-Id: Id0aa122a77796713bc6d624dc395d396fbc0c5e2
GitHub-Last-Rev: cb3c6d7da9
GitHub-Pull-Request: golang/sys#167
Reviewed-on: https://go-review.googlesource.com/c/sys/+/510195
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-07-19 00:01:56 +00:00
Tobias Klauser
3fead03e7d unix: add Mremap for netbsd
Fixes golang/go#60409

Change-Id: I2d872a1a6fb63c27ab3753deff370e1c2f752bdd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/508397
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-07-13 05:43:33 +00:00
Tobias Klauser
a1a9c4b846 unix/linux: update to Linux kernel 6.4 and Go 1.21rc2
Also fix the glibc 2.37 release date in a comment.

Change-Id: Ibd972a2846f0085bacf67c847ce4726bf130d5ba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/506017
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2023-06-27 17:19:37 +00:00
Jordan Whited
d1abdad3a4 unix/linux: update TUN flags and virtio_net_hdr constants
TUN_F_USO{4,6} and VIRTIO_NET_HDR_GSO_UDP_L4 are new in Linux v6.2.

Change-Id: I7e3dc34118d1c03afeb87fb8699d8167a6e49b7f
GitHub-Last-Rev: c658b9bf0f
GitHub-Pull-Request: golang/sys#165
Reviewed-on: https://go-review.googlesource.com/c/sys/+/506455
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-06-27 15:33:31 +00:00
Anton Kuklin
e0c3b6e6ae unix: add Mremap for linux
For golang/go#60409

Change-Id: I75a9732ee996f0aeb91599d80803f96ada468c27
GitHub-Last-Rev: c348b6194d
GitHub-Pull-Request: golang/sys#164
Reviewed-on: https://go-review.googlesource.com/c/sys/+/502715
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-06-16 19:37:35 +00:00
Tobias Klauser
ca096e46e8 unix: add missing IFLA_* consts on linux
Change-Id: Ib221d98f8d7e5aac7ff2db207cdd92145fe1dc60
Reviewed-on: https://go-review.googlesource.com/c/sys/+/503715
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-06-16 18:27:27 +00:00
Tobias Klauser
df9fef2097 unix/linux: update to Linux kernel 6.3 and Go 1.20.5
Change-Id: I347341ae0e45e73477e9a310a3749d37bafa8da7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/503255
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-16 18:27:25 +00:00
Brad Fitzpatrick
55b11dcdae unix: remove recently introduced debug/elf dependency
CL 501795 added a dependency on debug/elf (and thus compress/gzip,
debug/dwarf, hash/adler32)

Add a copy of the const instead.

Change-Id: I2c86094ef7de61b8dd0bdd727f6e547ac7f58527
Reviewed-on: https://go-review.googlesource.com/c/sys/+/502356
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-12 14:18:21 +00:00
Guoqi Chen
5059a07aa4 unix: implement Ptrace{Set,Get}Regs using PTRACE_{GET,SET}REGSET for Linux
The same change was already done in CL 501756.

Fixes #60679.

Change-Id: I5d1f4ad89cabb0ac120b3d72876944fb3283ec6f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/501795
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-06-09 14:43:47 +00:00
Josh Rickmar
304f187cdb unix: replace use of strcpy in mkerrors.sh
On OpenBSD-current, clang emits a warning message to standard output for the use of strcpy, e.g.:

_errors.c(/tmp/_errors-673190.o:(main)): warning: strcpy() is almost always misused, please use strlcpy()

This message makes it into the Go source being created, causing gofmt to error on the invalid syntax, and leaving the zerrors file empty.

Using strlcpy would be preferred here, but strncpy is enough to silence this message, and is more portable.

Change-Id: I16404d74c4406dadda87f211fc0ba062de0d11ac
GitHub-Last-Rev: a43b6fbc1b
GitHub-Pull-Request: golang/sys#147
Reviewed-on: https://go-review.googlesource.com/c/sys/+/468399
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
2023-06-06 21:43:30 +00:00
Alvar Penning
81c8a6c06d unix: add Getresuid and Getresgid for OpenBSD
Addresses golang/go#60483 for OpenBSD.

This change was successfully tested on amd64 and adjusted accordingly for the other architectures.

Change-Id: Id63cca342d81d2cc5854eb2923ca7e66bfaa91bf
GitHub-Last-Rev: cff1170143
GitHub-Pull-Request: golang/sys#160
Reviewed-on: https://go-review.googlesource.com/c/sys/+/500655
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-05 16:39:39 +00:00
Alvar Penning
ff98eae2a0 unix: remove absolute path of pwd from mkall.sh
The pwd command does not always reside under /bin for all Linux
distributions. As a $PATH is otherwise always assumed, here too.

Change-Id: I8a9b65fedc0bdd6b963f30e69d5c98b1550326cd
GitHub-Last-Rev: ff9227dbe6
GitHub-Pull-Request: golang/sys#161
Reviewed-on: https://go-review.googlesource.com/c/sys/+/500656
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-04 15:21:17 +00:00
Mateusz Poliwczak
b52f5441ce unix: add Getresuid, Getresgid for linux
Fixes golang/go#60483

Change-Id: Id4c1bf8367066485a16bedeea337c384a3555942
GitHub-Last-Rev: 61f0fe6f6a
GitHub-Pull-Request: golang/sys#159
Reviewed-on: https://go-review.googlesource.com/c/sys/+/499055
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-05-31 15:03:40 +00:00
Florian Lehner
b5c7a0975d unix: update BPF constants with Linux kernel 6.2
Change-Id: Iaa92ec9e8ff6e337457ea4f57b4c046221128d43
Reviewed-on: https://go-review.googlesource.com/c/sys/+/496675
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-05-23 19:43:07 +00:00
Tobias Klauser
39c2d6a01d unix: add UDP socket option constants on linux
Change-Id: I4c947319f98754a5135b306d8ff042a986ab5440
Reviewed-on: https://go-review.googlesource.com/c/sys/+/484637
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2023-04-14 20:11:08 +00:00
Tobias Klauser
1fb6828e5b unix: convert Iovec.Base to *byte in mkpost.go on solaris
Instead of defining a dedicated type goIovec with the correct *byte type
for its Base field like CL 412496 did, modify the Base field of the
original type Iovec (generated from struct iovec) in mkpost.go. This is
akin to how we already change []int8 to []byte for several other types.

Fixes golang/go#55997

Change-Id: If30799bb2bfe6d17678370b45348ff0b7c5de2e9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/484635
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-04-14 16:57:27 +00:00
Tobias Klauser
3125361ba6 unix: allow overriding GOOS using GOOS_TARGET in mkpost.go
mkpost.go is platform independent and can in principle be run on a GOOS
other than the one we're generating the syscall wrappers for. Allow
overriding GOOS by setting GOOS_TARGET, similar to other generator
programs in the repo. This e.g. allows testing mkpost.go changes on a
different GOOS.

Follows CL 256278 which did the same for mksyscall.go

Change-Id: Ib99aa5cd266f7d27543cf9433cfb028f367eef63
Reviewed-on: https://go-review.googlesource.com/c/sys/+/484636
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
2023-04-14 16:29:20 +00:00
Ed Schouten
64840c112d unix: add bindings for setattrlist() on macOS
The setattrlist() function can be used to mutate the attributes of files through a single call. For example, one can perform a chmod(), chown(), chflags(), [...] all at once.

This change also adds bindings for the UF_* and SF_* flags that are accepted by chflags(). This makes it possible to use setattrlist() to perform the equivalent of lchflags(), for which we currently have no binding.

Change-Id: Ib5a604503a984b95a02b65ad1a437246cd170584
GitHub-Last-Rev: 45dd9d475a
GitHub-Pull-Request: golang/sys#155
Reviewed-on: https://go-review.googlesource.com/c/sys/+/481815
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-04-04 14:21:21 +00:00
Mikołaj Kuranowski
90abad3705 unix: add AT_EACCESS on Darwin
The AT_EACCESS constant, used by faccessat syscall is present on Linux, Solaris and other BSD platforms. This commit also adds this constant on Darwin.

The constant (and the associated faccessat syscall) is part of POSIX.1-2008.

Fixes golang/go#59265.

Change-Id: Iae0ac35107cc291eba523cc88e68d3a9ddb7d01e
GitHub-Last-Rev: a6a16c4471
GitHub-Pull-Request: golang/sys#153
Reviewed-on: https://go-review.googlesource.com/c/sys/+/480115
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-03 14:25:53 +00:00
Jason A. Donenfeld
00d8004a14 unix: match ioctl req argument type to libc type
On Solaris, AIX, and zOS, the req argument of ioctl() is a signed int,
not an unsigned long like on other platforms, which means many constants
are negative, causing friction when passing them to a uint argument.
Correct the signature of these functions to pass the req argument as
signed, just like libc.

Fixes golang/go#59030.

Change-Id: Ia14e92a150f4b5fb9488c5032ca296cb786e9811
Reviewed-on: https://go-review.googlesource.com/c/sys/+/476515
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Nahum Shalman <nahamu@gmail.com>
2023-03-17 00:07:53 +00:00
Nahum Shalman
d0781cc69b unix: make solaris syscall tests less flaky
Fixes golang/go#58259

Change-Id: I1e8a83ed6ee3be8165c771b81a3cbdd474216c02
Reviewed-on: https://go-review.googlesource.com/c/sys/+/465055
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-16 22:08:31 +00:00
Ian Lance Taylor
ff18efa0a3 unix: change Setrlimit/Prlimit to always call syscall functions
As of Go 1.21 syscall.Setrlimit and syscall.prlimit can affect
starting a new process, by restoring the original NOFILE rlimit.
That is recorded locally in the syscall package, so just always
call the syscall functions.

For golang/go#46279

Change-Id: I2f3dafe5562a7dde1297bad6f5d34a80af5d620b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/476695
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-03-15 21:12:13 +00:00
Meng Zhuo
494aa493cc unix: skip ip related tests if EAFNOSUPPORT raised
Skipping EADDRNOTAVAIL is not enough for system doesn't support
ipv4/ipv6 family.
This CL skips TestPktInfo and TestParseOrigDstAddr if EAFNOSUPPORT
raised.

Fixes golang/go#58832

Change-Id: Icf74749f9cc0f9a6d60646f92f7ddf53ae2de8ab
Reviewed-on: https://go-review.googlesource.com/c/sys/+/473257
Run-TryBot: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-04 19:08:18 +00:00
Francis Laniel
c7a1bf9a0b unix: define PerfBitWriteBackward
Change-Id: I0b95006039b4efcd0094ba96281100abeafc993e
GitHub-Last-Rev: 43383aac90
GitHub-Pull-Request: golang/sys#149
Reviewed-on: https://go-review.googlesource.com/c/sys/+/473135
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-03-04 03:20:52 +00:00
Tobias Klauser
147085206c unix: add SetsockoptTCPMD5Sig on linux
This allows to set the TCP MD5 signature (see
https://www.rfc-editor.org/rfc/rfc2385) using TCPMD5Sig introduced in CL
106656.

Also export the storage data field in SockaddrStorage and convert it to
a byte array so the address in TCPMD5Sig.Addr can be set from an net.IP
without conversion.

Change-Id: I6bccfab57c188fcef857a6a3c514c943ca00b670
Reviewed-on: https://go-review.googlesource.com/c/sys/+/472835
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2023-03-02 17:30:46 +00:00
Tobias Klauser
a6bfb89d2f unix: use unsafe.Slice in anyToSockaddr
Same as CL 471436 did in package syscall.

Change-Id: Ic3f3a5ebb7ebe0cc7b6bbf377dd993cdbeaaa961
Reviewed-on: https://go-review.googlesource.com/c/sys/+/472015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-02-28 18:48:22 +00:00
Will Hawkins
6f250766ac unix: define extended TCPInfo on Linux
On Linux platforms, the kernel can fill out an extended version of
the tcp_info struct. Allow users of the sys package to have access to
that information.

Change-Id: Ib42ad572dd56c774c6d9e8b17fe3bdd8126147bb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/471275
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-02-28 17:07:46 +00:00
Dmitri Goutnik
10499f4574 unix: add ioctlPtr with unsafe.Pointer arg on other unices (cont)
CL 469315 missed a few conversions, this CL adds them. While
here, also update syscall wrapper generators.

For golang/go#44834

Change-Id: I4418a8c177ee6d1a269c1cc2c806b199dc7ccf0b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/471119
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-24 21:46:34 +00:00
Dmitri Goutnik
92c4c39f76 unix: add Dup3 on FreeBSD
Other BSDs provide dup3(2) syscall, on FreeBSD it is implemented as libc
function using fcntl(2). This CL adds similar Go implementation.

Fixes golang/go#55935

Change-Id: I9c6d762415c7bed5442966a7fcbf9a6f8dfdaf2a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/470675
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-02-24 13:20:54 +00:00
Tobias Klauser
748af6eb5d unix: pass PROT_MPROTECT(PROT_READ|PROT_WRITE) to initial Mmap on netbsd
On NetBSD PAX mprotect prohibits setting protection bits
missing from the original mmap call unless explicitly
requested with PROT_MPROTECT.

Fixes golang/go#58660

Change-Id: I1e97e920bc617ed1674855adaae5047638a30394
Reviewed-on: https://go-review.googlesource.com/c/sys/+/470775
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-23 17:06:30 +00:00
Tobias Klauser
972870e3e1 unix/linux: update to Linux kernel 6.2, glibc 2.37 and Go 1.20.1
Also remove some manually defined AT_* contstants which are now defined
in the libc headers.

Change-Id: I342976a22948e9b05e38dc7503d9dd356cee6c7b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/470176
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-23 15:22:10 +00:00
Dmitri Goutnik
cc0b67d799 unix: use C.ioctl in generated ioctlPtr
Changes made in CL 469315 broke aix syscall wrapper generaton by
generating a wrapper for a non-existent C.ioctl_ptr() function.

Change-Id: Iaeee3056480637c62a09ea61e2ec14793c59790a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/470235
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
2023-02-22 19:20:54 +00:00
Tobias Klauser
a3b23cc77e unix: use SYS_PTRACE in generated ptracePtr
CL 469835 broke the syscall wrapper generation on linux and freebsd by
generating a wrapper for the inexistent SYS_PTRACE_PTR syscall. The
ptracePtr added by CL 469835 correctly uses SYS_PTRACE, likely because
it was manually edited in that CL. However, the incorrect SYS_PTRACE_PTR
syscall is used when regenerating the syscall wrappers.

Change-Id: I270d66511f926d30a9d347930e977a026e033998
Reviewed-on: https://go-review.googlesource.com/c/sys/+/470175
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-22 18:57:16 +00:00
Jordan Whited
71a906ea0c unix/linux: add TUN flags and virtio_net_hdr constants
Change-Id: I10c86c100f4db77740eff6f07d91d6489b21b6f8
GitHub-Last-Rev: 3e8d7343cd
GitHub-Pull-Request: golang/sys#148
Reviewed-on: https://go-review.googlesource.com/c/sys/+/468656
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-22 15:47:51 +00:00
Dmitri Goutnik
2977c7732d unix: add ptracePtr that accepts pointer arg as unsafe.Pointer
The existing ptrace wrapper accepts pointer argument as an uintptr which
often points to the memory allocated in Go. This violates unsafe.Pointer safety
rules.

For golang/go#58387

Change-Id: Ib3b4c50368725191f0862c6c7c6d46b0568523c7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/469835
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-02-21 23:06:39 +00:00
Dmitri Goutnik
b13f40e221 unix: add ioctlPtr with unsafe.Pointer arg on other unices
This is a followup for CL 340915 that adds ioctlPtr for all other
UNIX-like platforms.

For golang/go#44834

Change-Id: I0ecf84e53f13e5a8da736b3ba7f643262596d23c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/469315
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-21 11:26:31 +00:00
Kir Kolyshkin
3b9b58b717 unix: Faccess: check CAP_DAC_OVERRIDE on Linux
CL 126516 added support for flags argument, implemented in the same way
as glibc does (it tries to guess what the kernel would do).

CL 246537 added using faccess2(2) Linux syscall which supports the flags
directly. For older kernels, though, the syscall is not available, and
the code uses glibc-like fallback.

There is one very specific scenario in which the fallback fails.
The scenario involves all these conditions:
 - no faccessat2 support available (i.e. either Linux kernel < 5.8,
   or a seccomp set up to disable faccessat2);
 - the current user is not root (i.e. geteuid() != 0);
 - CAP_DAC_OVERRIDE capability is set for the current process;
 - the file to be executed does not have executable permission
   bit set for either the current EUID or EGID;
 - the file to be executed have at least one executable bit set.

Unfortunately, this set of conditions was observed in the wild -- a
container run as a non-root user with the binary file owned by root with
executable permission set for a user only [1]. Essentially it means it
is not as rare as it may seem.

Now, CAP_DAC_OVERRIDE essentially makes the kernel bypass most of the
checks, so execve(2) and friends work the same was as for root user,
i.e. if at least one executable bit it set, the permission to execute
is granted (see generic_permission() function in the Linux kernel).

Modify the code to check for CAP_DAC_OVERRIDE and mimic the kernel
behavior for permission checks.

This is essentially the same fix as CL 468735 for Go syscall package.

Tested on CentOS 7 with the repro similar to the one from [2].

[1] https://github.com/opencontainers/runc/issues/3715
[2] https://github.com/golang/go/issues/58552#issuecomment-1432505621

Change-Id: I726b6acab6a6e6d0358ef98e6a582b405c347614
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/sys/+/468877
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-02-17 22:21:29 +00:00
Bryan C. Mills
c79a742fd1 unix: fix a use-after-free bug in PtraceIO on freebsd
In CL 419915, both pointer fields of the PtraceIoDesc struct were
converted to type uintptr to address golang/go#54113.

However, that change was overzealous: the fix needed to convert fields
that refer to addresses in the child process, but the Addr field of
PtraceIoDesc is not even in the child process! It is instead an
address in the parent (Go) process.

Go's unsafe.Pointer rules prohibit converting a Go pointer to a
uintptr except when immediately converting back to an unsafe.Pointer
or calling a system call. Populating a PtraceIoDesc struct is neither
of those things, so converting the Addr field to uintptr introduced a
use-after-free bug.

This change reverts the change to the Addr field from CL 419915 and
consolidates the implementation of PtraceIO to reduce the the amount
of code that varies with GOARCH.

This change does not address the remaining ptrace uintptr bug
(golang/go#58387), which is also present in the Linux implementation.

Fixes golang/go#58351.
Updates golang/go#54113.
For golang/go#41205.

Change-Id: I14bdb4af42130aa7b4375e3f53fd1a0435f14307
Reviewed-on: https://go-review.googlesource.com/c/sys/+/465676
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-08 01:11:03 +00:00
Bryan C. Mills
90c8f94a05 unix: avoid converting non-pointers to unsafe.Pointer in PtraceIO
Despite having the misleading type "void*" in the C API, the "offs"
field of the ptrace_io_desc struct is an offset within the child
process, and thus is not necessarily a valid pointer at all in the
parent process. The Go unsafe.Pointer type must refer only to valid
pointers, so converting this field through unsafe.Pointer is incorrect
and (in some cases) dangerous.

While we're here, let's also rename the "addr" function argument to
"offs", since that's the corresponding ptrace_io_desc field. It's very
confusing to have a function argument named "attr" that doesn't map to
the struct field of the same name!

For golang/go#58351.

Change-Id: Id899f823e8d398b51fb0c42f466d7ae2f957c26b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/465675
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-02-07 00:05:19 +00:00
Bryan C. Mills
4e121b1efb unix: add missing address operator in initxattrdest
The purpose of the _zero variable is to provide a valid address for a
pointer to an array of length zero. All other uses of the variable
take its address, but one reference to it (added in CL 147850043)
converts the variable (which has type uintptr) directly to an
unsafe.Pointer, producing a nil pointer instead of a non-nil pointer
to a zero-length array.

This typo is caught by 'go vet', but was masked for a long time by the
numerous false-positive warnings for the same check (#41205).

For golang/go#41205.

Change-Id: Ib3bebfadc6fc5574db19630169ff3f65da857bdd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/465597
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-02-06 18:23:25 +00:00
Tom Thorogood
0e1262c88a unix: add ptrace(PT_DENY_ATTACH) wrapper for darwin
Change-Id: I13e4426e6e411ceb449539479d9bcee15a518cf6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/464655
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2023-02-03 18:20:27 +00:00
James Clark
6938dae65e unix: add missing constants used with struct Timex on Linux
This provides definitions for Linux of two groups of constants,
which are used with struct Timex (used with the adjtimex and
clock_adjtime system calls): the ADJ_* constants are used
for the modes field; the STA_* constants are used for the status
field. The constants are documented in the adjtimex(2) man page.

Fixes golang/go#58012

Change-Id: I054f0c40f9cfd9360a0bb10716a08e19584c0fff
Reviewed-on: https://go-review.googlesource.com/c/sys/+/464241
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2023-02-02 22:29:28 +00:00
Nahum Shalman
01b330b26f unix: improve flaky solaris test logging
relates to golang/go#58259

Change-Id: I47bbf4afb59b6e98571297ba53d7f9370712e030
Reviewed-on: https://go-review.googlesource.com/c/sys/+/465015
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-02 22:24:17 +00:00
cui fliter
e7d7f63158 all: fix some comments
Change-Id: I7d5bfd4caac63820b26fc3408118c13e74e6448c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/464238
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-31 16:01:37 +00:00
chenguoqi
7a75290698 unix/linux: update to glibc 2.36
Support for LoongArch has been merged upstream. This allows to
drop the loong64 specific glibc patches.

Because the header file sys/mount.h of glibc 2.36 includes fcntl.h
(commit 78a408ee7ba041fc8d5dbd5f67065b4a982c11e5), this will leads to
duplicate definition of structure stat on MIPS64.  In order to solve
this error, use the custom type my_stat to generate the Go Stat_t.

Change-Id: I888280d777d1c7089548acf1b3821762011d79b0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/453555
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-01-31 14:54:23 +00:00
chenguoqi
b829a39df5 unix/linux: update to gcc 13.0.0, qemu 7.1.0 for loong64
No changes in generated files.

Update loongarch64-linux-gcc to 13.0.0
- The kernel header file version is upgraded to 5.19

Update qemu-loongarch64 to 7.1.0
- Support for LoongArch has been merged upstream.

Change-Id: I637925fd9e5575dfb4ce91ece98951d5bf3053e6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/453458
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-30 18:37:20 +00:00