102 Commits

Author SHA1 Message Date
Will Fancher
d628b3bfe4 Do not cross compile mknames.go
`GOOS` and `GOARCH` can be set to cross compile the Go code. But
`good-names.go` is generated at build time using `mknames.go`, which
must be built for the build platform. `GOOS` and `GOARCH` can be unset
to do this. In many circumstances, Go will use its own internal linker
to build the binary, which means it won't need to use `$CC`. But in
some scenarios, e.g. when building PIE binaries, it will use `$CC` as
the linker, so this needs to be set to the build platform's compiler
for `go run`.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-11-10 18:21:52 -08:00
Andrew G. Morgan
3b2513a1ba Up the release version to 2.77
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-10-26 11:29:03 -07:00
Andrew G. Morgan
5f3e12ca39 Up the release version to 2.76
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-04-13 09:47:12 -07:00
Andrew G. Morgan
f02e46a44a Up the release version to 2.75
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-04 08:56:39 -08:00
Andrew G. Morgan
def8fab2a3 Up the release version to 2.74
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-02 16:09:34 -08:00
Andrew G. Morgan
025f28ca4f Avoid thread churn deadlock with PSX rewrite.
This bug, reported by David Runge, identifies another regression
vs. libpsx-2.71:

   https://bugzilla.kernel.org/show_bug.cgi?id=219687

A regression of the LWP threading support reintroduced an old bug
in the libpsx-2.72 rewrite, specifically this bug:

   https://github.com/golang/go/issues/42494

This present change includes x86_64, i386 and arm* (32-bit and 64-bit)
support. I've tested each of these with debian OSes, some running via QEMU.
Before releasing 2.74, I plan to extend the testing to all of the targets
supported by Debian (see https://wiki.debian.org/DebianInstaller/Qemu).

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-01 08:49:27 -08:00
Andrew G. Morgan
6ef6a9d1e4 Up the release version to 2.73
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-12-01 20:18:58 -08:00
Andrew G. Morgan
4726b0da33 Use go vet as part of testing the go/ packages.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-22 18:37:19 -08:00
Andrew G. Morgan
1a02e34cc4 Up the release version to 2.72
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-10 15:26:15 -08:00
Andrew G. Morgan
b017fcff26 Eliminating -wrap use.
This addresses the following bug:

   https://bugzilla.kernel.org/show_bug.cgi?id=219456

insofar as it eliminates the need for -wrap=pthread_create
linkage. Mostly, code that uses -lpsx functions can simply
link with -lpsx now. However, for legacy reasons the library
still works when linked wrapped or with the new content of
the libpsx.pc file:

   -Wl,--no-as-needed -Wl,--whole-archive -lpsx -Wl,--no-whole-archive -Wl,--as-needed -lpthread

These last options are required for getting -lcap to act at a
consistent process level and not a thread level.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-09 23:19:18 -08:00
Andrew G. Morgan
c7dbcf0bc9 Up the release version to 2.71
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 22:17:54 -07:00
Andrew G. Morgan
67b8bf1476 Tidy up some white space (tab -> space)
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 22:01:07 -07:00
Andrew G. Morgan
9e4b652f48 Lessen the situations where cap.SETPCAP is required for IAB setting.
Discussion and explanation of what is up here is in:

   https://bugzilla.kernel.org/show_bug.cgi?id=219169

This gets the Go cap package to parity with the recent changes to
libcap. This change will be live in cap/v1.2.71.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-19 16:37:56 -07:00
Andrew G. Morgan
30892a5d5b Add a test example.
First attempt to get the docs on go.dev to have ready to run examples.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-09-22 11:10:05 -07:00
Andrew G. Morgan
8fe536b53f Up the release version to 2.70
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-05-18 21:43:17 -07:00
Andrew G. Morgan
8bed80f9b5 Up the release version to 2.69
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-14 19:10:04 -07:00
Andrew G. Morgan
3c7dda330b Up the release version to 2.68
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-25 17:03:17 -07:00
Andrew G. Morgan
5496a0e385 Tidy up some text explaining cap.NamedCaps.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-19 20:18:44 -07:00
Andrew G. Morgan
ddbaa98412 Make the compare-cap binary clean up after itself.
When run via sudo, compare-cap exits with some file capabilities
left on its binary file. This is a test binary, so that's not a
big problem, however, it does mean that a 2nd run of the program
is started with, potentially, a different initial state.

This commit fixes that exit condition and addresses:

  https://bugzilla.kernel.org/show_bug.cgi?id=217018

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-09 20:13:25 -08:00
Andrew G. Morgan
34b0329dc7 Up the release version to 2.67
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-02 20:10:27 -08:00
Andrew G. Morgan
4f96e6788d Up the release version to 2.66
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-09-24 13:37:39 -07:00
Andrew G. Morgan
281b6e47e1 Add captrace to .gitignore file
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-09-22 06:45:32 -07:00
Andrew G. Morgan
09a2c1dbb8 Add an example of using BPF kprobing to trace capability use.
$ make
$ sudo go/captrace your-program

will attempt to explore what capabilities are needed to run
your program by observing when cap_capable() inside the kernel
is associated with your-program.

Other ways to invoke this are

$ sudo go/captrace --pid=<pid>
$ sudo go/captrace

The last of these traces everything running on a system.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-09-18 16:56:40 -07:00
Andrew G. Morgan
7db9589038 Some more simplifications for building
I'm not 100% sure this is needed, but I'm not yet convinced
'make distclean && make -j48 test' works reliably, but I find this
easier to reason about.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-07-22 07:22:57 -07:00
Andrew G. Morgan
27e801bcbc Fix for "make clean ; make -j48 test"
Missed a vendor dependency for the ok.go file. More recent go releases
seem more picky about module or vendoring being used, and for the in-tree
builds we consistently use vendoring. So make sure the vendoring
directory set up has completed before trying to build ok.go.

The failure was reported by Tomasz Kłoczko.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-07-21 11:52:47 -07:00
Andrew G. Morgan
a47d86dfb9 Up the release version to 2.65
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-07-17 15:33:06 -07:00
Andrew G. Morgan
52288ccc0b Close out this comment in the go/Makefile
The deadlock issue is fixed in go1.18.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-05-17 07:10:19 -07:00
Andrew G. Morgan
38cfa2e958 Up the release version to 2.64
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-04-10 15:39:39 -07:00
Andrew G. Morgan
aae937481a Be explicit about CGO_ENABLED=1 for compare-cap build.
It looks like go1.18 is going to default to CGO_ENABLED=0, so force
CGO_ENABLED=1 when building this cap-libcap comparison program.

Fixes:

  https://bugzilla.kernel.org/show_bug.cgi?id=215603

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-02-13 19:58:05 -08:00
Andrew G. Morgan
1d88048c31 Up the release version to 2.63
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-01-23 16:36:22 -08:00
Andrew G. Morgan
bbabfb4cf4 Add a test case for a deadlock.
The CGO_ENABLED=0 failure mode is discussed in:

  https://github.com/golang/go/issues/50113

At the present time, this only passes when the psx package is compiled
CGO_ENABLED=1. The problem being that a blocking read cannot be
interrupted by the CGO_ENABLED=0 build of package "psx". It does not
deadlock when compiled CGO_ENABLED=1 because the psx signal wakes the
reading thread up back into user space.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-01-23 16:35:23 -08:00
Andrew G. Morgan
af2bf057ed Make cgo psx_syscall variant crash like runtime.AllThreadsSyscall
When a syscall that yields different return values is called from
the Go psx.Syscall*() API, we want to mirror the behavior of the
native golang runtime.AllThreadsSyscall() function.

The previous inconsistency was pointed out by Lorenz Bauer in:

  https://bugzilla.kernel.org/show_bug.cgi?id=215283#c8

[I decided to defer this change until 2.63, and not include this
in the bug-fix for 215283, on the grounds it is a slight
incompatibility in runtime behavior, and wanted to give folk an
opportunity to plan for it. This new behavior enforcement will
crash an unprepared go program.]

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-12 11:52:16 -08:00
Andrew G. Morgan
cc91f55960 Up the release version to 2.62
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-11 18:06:34 -08:00
Andrew G. Morgan
806b53d13a Take more care post launch
Lorenz Bauer found a race condition in the cap.Launcher teardown
process and reported it here:

   https://bugzilla.kernel.org/show_bug.cgi?id=215283

This seems to significantly improve the situation. I'm going to
study the test case some more, but this is definitely part of the
solution.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-10 20:59:19 -08:00
Andrew G. Morgan
42555598bf Recognize default secbits of 0 as "HYBRID" mode.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-11-21 09:39:02 -08:00
Andrew G. Morgan
d63835d491 Up the release version to 2.61
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-11-20 22:20:04 -08:00
Andrew G. Morgan
5306fa23ff Up the release version to 2.60
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 21:29:14 -07:00
Andrew G. Morgan
9eb56596ee Up the release version to 2.59
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-26 18:20:33 -07:00
Andrew G. Morgan
01627eae86 Up the release version to 2.58
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-17 19:35:42 -07:00
Andrew G. Morgan
1dd3fb4312 Add in something the builder can override to augment the GO builds
I've been looking at reasons packagers are not building the Go binaries
and found this with respect to RPMs:

  https://github.com/rpm-software-management/rpm/issues/367

There has been no easy way to inject the otherwise unneeded workaround:
-ldflags=-linkmode=external for building (which, strangely, generates
some sort of warning and gratuitously links glibc to an otherwise
static build), but seems to work.

Until RPM supports Go's native '.note.go.buildid', and RPM requires
'.note.gnu.build-id' on binaries, I guess this can work around it:

   GO_BUILD_FLAGS='-ldflags=-linkmode=external'

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-11 16:13:56 -07:00
Andrew G. Morgan
3906730197 Up the release version to 2.57
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-09 13:57:36 -07:00
Andrew G. Morgan
8b3ffc23b6 Fixed parallel make issues
Tried make -j12 and these fixes were needed.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-05 20:07:48 -07:00
Andrew G. Morgan
5ef14d0742 Refactor top level Makefile to reduce redundant building
Make build a bit quicker for folk that don't want to run tests.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-04 14:05:11 -07:00
Andrew G. Morgan
0f286b584e Up the release version to 2.56
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-02 20:03:32 -07:00
Andrew G. Morgan
f5ae31ebd3 Be more consistent with make variables.
Noticed that we weren't applying the same amount of flag discipline
to local BUILD_* tool rules. Fixing that, I see we've been carrying
a source code issue in libcap/_makenames.c for a while. (FIXED).

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-30 20:02:22 -07:00
Andrew G. Morgan
2bfe36c999 Up the release version to 2.55
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-29 18:54:03 -07:00
Andrew G. Morgan
61b2fcc451 Make sudotest more robust against untestable environments
I'm setting up some testing environments and they are not all
created equal.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-28 16:50:35 -07:00
Andrew G. Morgan
386af0edbc Stop installing the cap and psx packages, but do install captree.
We also add the cap.ProcRoot() API to let the user redirect to their
local /proc/ directory - in case anyone runs with an unusual setup
like that.

I've been studying the downstream package definitions and no one
it doesn't seem popular to build the Go packages. Indeed, Go folk
themselves prefer to install via modules anyway, so we're getting
with the program.

However, if folk want to build test the Go stuff as part of a package
build and run an install as well, we reward them with the 'captree'
binary.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-26 22:26:56 -07:00
Andrew G. Morgan
07cdff9ac9 Up the release version to 2.54
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-25 21:09:19 -07:00
Andrew G. Morgan
935ab8f7cd Support overriding choice of 'sudo'.
Use something like:

  make SUDO=my_sudo sudotest

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-25 19:48:12 -07:00