Skip to content

Commit 08e6cdc

Browse files
committed
crypto/rand: add syscall number fallbacks in seccomp_linux
seccomp_linux.go is only used for Go's own tests (commit 6446285), but the package is included when building programs with CGO_ENABLED=1. When using an older glibc (e.g. 2.17), SYS_getrandom and SYS_seccomp are not defined, causing cgo compilation to fail. Note that there are already several types and defines copied from linux headers into seccomp_linux.go to support compilation on older systems.
1 parent fc88e18 commit 08e6cdc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/crypto/internal/sysrand/internal/seccomp/seccomp_linux.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ struct seccomp_data {
4949
#define SECCOMP_RET_ALLOW 0x7fff0000U
5050
#define SECCOMP_SET_MODE_FILTER 1
5151
52+
#ifndef SYS_getrandom
53+
#define SYS_getrandom -1
54+
#endif
55+
56+
#ifndef SYS_seccomp
57+
#define SYS_seccomp -1
58+
#endif
59+
5260
int disable_getrandom() {
5361
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
5462
return 1;

0 commit comments

Comments
 (0)