Commit Graph

1336 Commits

Author SHA1 Message Date
Florian Lehner
a24fb2fb8a unix: add constants for netlink/routing rules
Change-Id: Ic68b65e71125b755418f9d8d01a9500aa1e9ffc1
Reviewed-on: https://go-review.googlesource.com/c/sys/+/399194
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Auto-Submit: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2022-04-08 20:14:24 +00:00
Tobias Klauser
3f8b81556e unix/linux: update to Linux kernel 5.17
Change-Id: I8e982e355d6058198f5b555c2f33e18301872909
Reviewed-on: https://go-review.googlesource.com/c/sys/+/398435
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-06 16:36:25 +00:00
Alexey Perevalov
289d7a0edf unix: add MoveMount syscall on linux
This syscall is not yet described in linux man pages
(https://github.com/mkerrisk/man-pages.git),
but it was submitted to lkml https://lwn.net/Articles/802095/
This syscall appeared in linux v5.2.

Change-Id: I0708bfceda8d7a7608d0d0e75e36c3d81302dedb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/397095
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-04-06 15:52:45 +00:00
Eric Lagergren
1e041c57c4 unix: revert MemfdSecret changes to riscv64
Linux apparently supports the memfd_secret syscall on riscv, but
SYS_MEMFD_SECRET isn't defined by zsysnum_linux_riscv64.go.

Updates #51547

Change-Id: I138ce679bf742a7ff4ce1d5e10db84a00df0e271
Reviewed-on: https://go-review.googlesource.com/c/sys/+/398514
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-04-05 21:05:40 +00:00
Eric Lagergren
b1e9470b6e unix: add MemfdSecret
Fixes #51547

Change-Id: I07a02e8e6ac8baaa72f1c214621fbaca6a6ed707
Reviewed-on: https://go-review.googlesource.com/c/sys/+/397774
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-04-05 05:20:23 +00:00
Eric Lagergren
6acee93ad0 unix: regenerate OPEN_TREE_CLONE
Constant was incorrectly generated in CL 397094.

Change-Id: I3aeef51e1ad2ec43332fbcdff6afc705b098f57d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/397814
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-04-03 20:57:10 +00:00
Alexey Perevalov
483a9cbc67 unix: add OpenTree on linux
This syscall is not yet described in linux man pages
(https://github.com/mkerrisk/man-pages.git)
but it was attempts to do it (https://lwn.net/Articles/829496/)
This syscall appeared in linux kernel v5.2

Change-Id: If44aa74c4ddd200831011c6c4bf4bd4fee440785
Reviewed-on: https://go-review.googlesource.com/c/sys/+/397094
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-03 02:05:50 +00:00
Matt Layher
e17cdc4130 unix: fix staticcheck issues
Change-Id: If7abd7a743c4359a9780401cec7c874d530ee268
Reviewed-on: https://go-review.googlesource.com/c/sys/+/396674
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-30 03:32:06 +00:00
Matt Layher
43be30ef30 unix: skip Linux TestPidfd if Waitid returns EINVAL
The updated test in CL 395936 appears to break GOARCH mips* builders.

Updates golang/go#52014

Change-Id: I42bb71d6afda2112a524257fd1b42306dd22689c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/396154
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-29 15:23:56 +00:00
Tobias Klauser
d36c6a25d8 unix/linux: update to Go 1.18
Change-Id: I663b4e6346cec4a51f4423a38cc1315c5b51956d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/396114
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2022-03-28 11:51:05 +00:00
Tobias Klauser
530d0810a4 unix: add utimensat libc wrapper on darwin
Direct syscalls are no longer supported on darwin (CL 250437), so
utimensat can be implemented as a wrapper around the libc function.
The utimensat function was added in macOS 10.13 and Go 1.17 dropped
support for macOS 10.12.

This also allows to drop the fallback to setattrlistTimes which was
used to set timestamps with nanosecond resolution before utimensat could
be used, see golang/go#22528 and CL 74952.

Change-Id: I206291277e6f7200ca7a659e29075968647779a6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/251737
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2022-03-27 21:02:14 +00:00
Matt Layher
36772127a2 unix: implement Waitid on Linux
waitid(2) can be used to wait on pidfds. Update TestPidfd to test this new
functionality as well.

Change-Id: I5f26140b9afd5a6ec3f04217fb1c91542936a2c3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/395936
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-03-25 20:38:50 +00:00
Nahum Shalman
594fa53f00 unix: solaris/illumos Event Ports ENOENT cleanup
When we receive ENOENT from port_dissociate,
we should clean up our map reference.
To do so safely, we need a place to track
the user cookies.

This work is in support of fsnotify/fsnotify#371

Change-Id: Iae53ccc508d533941ad19df9051ca046262095ef
Reviewed-on: https://go-review.googlesource.com/c/sys/+/380034
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-25 20:22:31 +00:00
Matt Layher
a9b59b0215 unix: add PidfdSendSignal on Linux
This completes the pidfd_* family of syscalls and adds a test to verify that a
child process can be terminated using the new PidfdSendSignal function.

Change-Id: I71f6a1e26518f513731e20afef02030462e9a2c0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/393794
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-19 13:42:39 +00:00
Tobias Klauser
2edf467146 windows: optimize UTF16{,Ptr}FromString
Use strings.IndexByte in UTF16FromString instead of an open-coded loop.

Change-Id: Iac4374d9a58e40659147d35c9ab21bb89f5da629
Reviewed-on: https://go-review.googlesource.com/c/sys/+/393594
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-18 05:55:25 +00:00
Tobias Klauser
51cd9980da unix: unify Recvmsg epilogues
Follow CL 361258 which did the same in package syscall.

Change-Id: I721406286d84ec999978e7e1ea25b6a2b3e195e6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/393294
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-17 06:15:10 +00:00
Tobias Klauser
22a226b3d1 unix: unify Sendmsg prologues
Follow CL 361256 which did the same in package syscall.

Change-Id: Ifd22e515c220806f02400baded821ec583959d78
Reviewed-on: https://go-review.googlesource.com/c/sys/+/393274
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-17 06:14:57 +00:00
Mathieu Aubin
2c4bbad7e9 unix/internal/mkmerge: correct typo
Change-Id: Icaa541758d4077aa3c5755e16effa0ce173a2335
GitHub-Last-Rev: 2fcf892e3e
GitHub-Pull-Request: golang/sys#121
Reviewed-on: https://go-review.googlesource.com/c/sys/+/392234
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-17 02:21:23 +00:00
Tobias Klauser
039c03cc5b unix: add race annotations to Pread and Pwrite
Follow CL 391954 which changed Pread/Pwrite in package syscall.

For golang/go#51618

Change-Id: Icc587c61f083886bb66ca96717f686f56b398e34
Reviewed-on: https://go-review.googlesource.com/c/sys/+/392794
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 19:43:20 +00:00
Tobias Klauser
27bbf83dae windows: add race annotations to Windows ReadFile and WriteFile
Follow CL 392774 which changed Windows ReadFile and WriteFile in package
syscall.

For golang/go#51618

Change-Id: I0f8046adb0f8145bd0775a3b5399647897cf19ce
Reviewed-on: https://go-review.googlesource.com/c/sys/+/392814
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 18:05:22 +00:00
Johan Van de Wauw
b874c991c1 cpu: fix typo in comments
Change-Id: Icb2bacefd7d8656e0a5867cb90fe0ca06252ad0b
GitHub-Last-Rev: c6d3b42e1b
GitHub-Pull-Request: golang/sys#120
Reviewed-on: https://go-review.googlesource.com/c/sys/+/390934
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-10 02:08:20 +00:00
Matt Layher
22a9840ba4 unix: add nl80211 generic netlink constants for Linux
Change-Id: Ic39f350bd0b4e3942ba576ee12b44b182178527c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/388935
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-03-07 20:37:07 +00:00
Dmytro Shynkevych
4e6760a101 unix: add SPEED_UNKNOWN
The rest of the SPEED_* constants are redundant: SPEED_x is defined to simply x for x in 10, 100, ...

Change-Id: I8b29a90ea1b914a65fa165a6801fcf77c667ebb0
GitHub-Last-Rev: 1428dcc517
GitHub-Pull-Request: golang/sys#119
Reviewed-on: https://go-review.googlesource.com/c/sys/+/388214
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-27 23:45:10 +00:00
Matt Layher
95c6836cb0 unix: add Kernel Connection Multiplexor ioctl helpers
Builds upon the structures added in CL 348449.

Change-Id: Ia8c95f52930ac90d1a37aedcda8cc46894630bf4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/387794
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-02-24 12:02:31 +00:00
Matt Layher
dbe011f71a unix: add Linux Kernel Connection Multiplexor types and constants
For details on KCM, see:
https://www.kernel.org/doc/Documentation/networking/kcm.txt.

Change-Id: I14ebf0aaad17f5a9078f027bd50e050c69b08981
Reviewed-on: https://go-review.googlesource.com/c/sys/+/348449
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-24 00:32:55 +00:00
Oscar Söderlund
96fed51e14 unix: add can netlink types and constants
Change-Id: Ie234f26c38a9ced6407f2970fa97b49d18119f06
Reviewed-on: https://go-review.googlesource.com/c/sys/+/387474
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2022-02-23 15:53:57 +00:00
Tobias Klauser
f2425489ef unix/linux: update to Go 1.18rc1
The change in ztypes_linux_s390x.go is likely due to CL 350159.

Change-Id: Ib7080255f357d484ee708e128ac9a7ab408a6dc5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/386955
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-22 20:09:37 +00:00
Kir Kolyshkin
0005352912 unix: Getwd: ensure returned path is absolute
Since Linux kernel 2.6.36, the pathname returned by the getcwd() system
call can be prefixed with the string "(unreachable)" in some cases [1].

Getcwd should return an absolute path, and doing otherwise is a
conformance issue; it also can be dangerous, since the path returned
can be an existing relative path.

Fix by returning ENOENT in case the path is not absolute. This is
essentially the same as what glibc does (since [2]).

[1] https://man7.org/linux/man-pages/man2/getcwd.2.html#BUGS
[2] https://sourceware.org/git/?p=glibc.git;a=commit;h=52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94

Change-Id: I6c48e7ec9b53be348138e3d974d3f11401c7bea6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/387194
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2022-02-22 17:22:38 +00:00
Tobias Klauser
b146bcec3b unix: remove accept on Linux
Same as CL 386415 does for package syscall.

accept is no longer used on Linux since CL 347329 changed Accept to use
accept4 only.

For golang/go#45964

Change-Id: I9f431044c03e7f28c08152390ad71f45eddfe9dd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/386954
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-22 16:06:53 +00:00
Matt Layher
3681064d51 unix: implement getitimer(2) and setitimer(2) on Linux
Wrap the low-level system calls with a more idiomatic Go API and a set of
constants to indicate which timer should be queried or modified.

man 2 getitimer indicates that these system calls are obsolete as of
POSIX.1-2008, but the code I am working on has not been ported to the modern
timer_gettime(2) and timer_settime(2) APIs as of yet.

Change-Id: I91482e141047846cadf47aa2417b8770955986bf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/384054
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Matt Layher <mdlayher@gmail.com>
2022-02-09 21:45:40 +00:00
Matt Layher
5739886226 unix: implement alarm(2) on Linux on all GOARCH except arm* and riscv.
SYS_ALARM is not defined for arm* or riscv, but is available for all other
Linux GOARCH values. Ian suggested I create a new file with build tags
matching these constraints.

In order to handle special case files such as this one (which don't match the
existing syscall_linux_goarch.go scheme), I've added logic to the Linux build
system which can evaluate the build constraints in a given file to determine
whether that file should be appended to the arguments for a given target.

Change-Id: I0136534522a26a0ce495308f63953546ea6bb8e5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/383734
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-02-07 23:40:03 +00:00
Tobias Klauser
1c1b9b1eba unix/linux: update to glibc 2.35, Go 1.17.6
Change-Id: I90b7eee499d6ed6ea431d2c8539aae5afa25cfab
Reviewed-on: https://go-review.googlesource.com/c/sys/+/383134
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2022-02-04 13:58:22 +00:00
Tobias Klauser
99c3d69c2c unix: enable sysctl tests on netbsd
Except for Getfsstat, all functions tested in syscall_bsd_test.go also
exist on netbsd. Move TestGetfsstat to a separate file so the other
tests can run on netbsd.

Change-Id: I63973e9c15a7f64c52b4edff034c03650658c4f6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/381714
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-28 21:58:02 +00:00
Bryan C. Mills
da31bd327a unix: lock the thread for TestPrctlRetInt
The prctl system calls used in this test modify and examine the
properties of the current thread. For the test to work correctly (and
to avoid interfering with other tests), the thread must be locked for
those calls and should not be reused when the test completes.

Fixes golang/go#50607

Change-Id: I2b14e6c0440155f4287d97f0bb72099af291ba0d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/378555
Trust: 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@golang.org>
2022-01-14 19:58:35 +00:00
Tobias Klauser
5a964db013 windows: add Get{Active,Maximum}ProcesorCount
Reference:
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getactiveprocessorcount
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getmaximumprocessorcount

Change-Id: Ifca711b82f112b395eac3b96266f63b5623881fc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/374435
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
2022-01-11 09:28:08 +00:00
Tobias Klauser
a018aaa089 unix/linux: update to Linux Kernel 5.16
Change-Id: I83f84e8aa6f75fc2a6fd1744546e8dc3d5bc3a55
Reviewed-on: https://go-review.googlesource.com/c/sys/+/377134
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2022-01-10 18:14:12 +00:00
Jason A. Donenfeld
1d35b9e2eb windows/svc: use NtQuerySystemInformation in IsWindowsService
This brings the algorithm more exactly in line with what .NET does for
the identically named function. Specifically, instead of using
OpenProcess, which requires rights that restricted services might not
have, we use NtQuerySystemInformation(SYSTEM_PROCESS_INFORMATION) to
find the parent process image name and session ID.

Fixes golang/go#44921.

Change-Id: Ie2ad7521cf4c530037d086e61dbc2413e4e7777c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/372554
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
2021-12-16 02:10:12 +00:00
Matt Layher
4abf325e02 unix: add netlink attribute type and policy type constants
Change-Id: I343785b938461c94c32d52fb632514293564311a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/372295
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-12-15 21:12:19 +00:00
Matt Layher
4825e8c387 unix: add WireGuard generic netlink interface constants on Linux
Change-Id: I619c49f745da8cfd17bc2aae28d97aff73daf4d5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371674
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-14 23:44:02 +00:00
Jason A. Donenfeld
3b038e5940 windows: set pipe explicitly inheritable in test for go 1.16
Go 1.16 didn't create inheritable pipes yet, because we didn't have safe
process inheritance semantics worked out then. So, for this test,
explicitly mark the pipe as inheritable, in case this is running on Go
1.16.

Fixes golang/go#50160.

Change-Id: I2e59cf430ff35e7f59315b11b73e79b9aaf3e6ce
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371694
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2021-12-14 17:07:44 +00:00
Matt Layher
024a26f5d6 unix: regenerate generic netlink controller constants
This adds support for generic netlink policy commands, and also regenerates the
constants using a shell one-liner for reproducibility in the future.

Change-Id: I868965c2a5abe2ff384e81223e03373465462f52
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371654
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-12-14 15:06:14 +00:00
Jason A. Donenfeld
03aa0b5f68 windows: allocate attribute list with LocalAlloc, not individual items
We didn't want to wind up with Go pointers mangled by win32, so we were
previously copying the contents into a LocalAlloc'd blob, and then
adding that to the attribute list. The problem is that recent changes to
the API broke this design convention, to the point where it expects 0x18
byte objects to be added using size 0x8. This seems like an unfortunate
oversight from Microsoft, but there's nothing we can do about it. So we
can work around it by instead LocalAlloc'ing the actual container, and
then using the exact pointer value that's passed into Update.

This commit also adds a test that both makes sure that these functions
actually work, and provokes a UaF that's successfully caught, were you
to comment out the line of this commit that reads `al.pointers =
append(al.pointers, value)`.

Fixes golang/go#50134.

Change-Id: Ib73346d2d6ca3db601cd236596cefb564d9dc8f1
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371276
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
2021-12-13 22:30:07 +00:00
Tobias Klauser
af8b642124 unix: use pipe2 syscall in Pipe on NetBSD
The pipe2 syscall is part of NetBSD since version 6.0 and thus exists in
all officially supported versions (6.0 through 6.1 and 7.0+).

Follows CL 94035 which did the same for package syscall.

Change-Id: Icfa7dfb13788c9a7425c641d0233b109e8c79e7f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/370794
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
2021-12-10 11:16:14 +00:00
Russ Cox
798191bca9 unix, plan9: avoid writing to p when Pipe(p) fails
Generally speaking Go functions make no guarantees
about what has happened to result parameters on error,
and Pipe is no exception: callers should avoid looking at
p if Pipe returns an error.

However, we had a bug in which ForkExec was using the
content of p after a failed Pipe, and others may too.
As a robustness fix, make Pipe avoid writing to p on failure.

windows.Pipe already avoided writing to p on failure.

For golang/go#50057.

Change-Id: I93ed06b06a9981793c119c1d7df689fbe79b4116
Reviewed-on: https://go-review.googlesource.com/c/sys/+/370614
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-09 17:19:07 +00:00
zhouguangyuan
97ca703d54 cpu: remove the declaration of function darwinSupportsAVX512
The implement of darwinSupportsAVX512 has been removed in CL 361255.
But the command "go install -buildmode=shared std" failed because the
declaration of it is remained in cpu/cpu_gc_x86.go. It should be removed.

Update golang/go#49233
For golang/go#49942

Change-Id: I8fa7c61c20457e49414930029b9f026c335aa421
Reviewed-on: https://go-review.googlesource.com/c/sys/+/368994
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2021-12-05 18:29:25 +00:00
Tobias Klauser
94396e4217 windows: add ModuleEntry32 type and Module32{First,Next} wrappers
Reference:
https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/ns-tlhelp32-moduleentry32w
https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32firstw
https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32nextw

Change-Id: I5455cabdbaa8e7e25490f869ca349e3c6f67a0cf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/369174
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
2021-12-04 12:00:58 +00:00
Jason A. Donenfeld
fe61309f88 windows: add SetupAPI and CfgMgr32 functions
Simon and I have worked on these on and off for a number of projects
over the last 3 years and by now it's quite stable and mature. Rather
than carrying this around privately, these have now been updated to be
in the style of x/sys/windows, in this case matching how the
security_windows.go file does things. Specifically, because these APIs
are kind of hard to work with, and quite lengthy, we split them off into
a setupapi_windows.go file, just like security_windows.go.  We already
had the setupapierrors_windows.go file, so that's been folded into the
new one that contains the additional definitions nad functions.

These APIs are among the most obtuse to work with in all of Win32, so
considerable attention has been spent trying to make these wrappers both
quite "raw" so that they match the win32, but also accessible from Go.
The fact that they're so old in Windows history makes for a few tricky
things, like struct padding that doesn't quite match Go's rules, but
we've been able to accommodate basically everything after quite a bit of
work.

Change-Id: I0c2dd85e4bb40eee10186ffc92558a858bdf8c6a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/366654
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Simon Rozman <simon@rozman.si>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
2021-11-24 21:15:45 +00:00
Jason A. Donenfeld
ef496fb156 windows: re-enable TestWinVerifyTrust with newly signed file
Rather than disabling this test, let's just not make it rely on
Microsoft files, whose signing validity period we can't depend on.
Instead, we include our own EV-signed artifact, with a Digicert
timestamp using a certificate valid for a decade.

Fixes golang/go#49651.
Fixes golang/go#49266.
For golang/go#46906.

Change-Id: Idadba346810017b8f769d6fac1ddd357d4dee93c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/366655
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-23 17:31:58 +00:00
Bryan C. Mills
dee7805ff2 windows: skip TestWinVerifyTrust
This test is failing (with different failure modes) on two different
builders. Adding a skip until it can be made more robust.

For golang/go#49651
For golang/go#49266
Updates golang/go#46906

Change-Id: I0fdd0e6f729c37e234b62b65abc53003eb8834f0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/364794
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-17 18:06:35 +00:00
Kir Kolyshkin
0a5406a544 unix: add mount_setattr support for linux
This brings in mount_setattr(2) support, added to Linux 5.12 kernel and
documented at https://man7.org/linux/man-pages/man2/mount_setattr.2.html

Change-Id: I5609980c18aef80f9429a8c8cec8c1e129f74ab7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363444
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2021-11-16 06:13:58 +00:00