-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In Android version 11 and earlier, pidfd-related system calls are not allowed by the seccomp policy, which causes crashes due to SIGSYS signals. Fixes golang#69065
- Loading branch information
Showing
11 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package os | ||
|
||
import _ "unsafe" // for go:linkname | ||
|
||
//go:linkname androidVersion runtime.androidVersion | ||
func androidVersion() int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build !android | ||
|
||
package os | ||
|
||
func androidVersion() int { | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package runtime | ||
|
||
import ( | ||
"internal/abi" | ||
"unsafe" | ||
) | ||
|
||
// The *_trampoline functions convert from the Go calling convention to the C calling convention | ||
// and then call the underlying libc function. These are defined in sys_android_$ARCH.s. | ||
|
||
//go:nosplit | ||
//go:cgo_unsafe_args | ||
func __system_property_get(name *byte, value *byte) int32 { | ||
ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(__system_property_get_trampoline)), unsafe.Pointer(&name)) | ||
KeepAlive(name) | ||
KeepAlive(value) | ||
return ret | ||
} | ||
func __system_property_get_trampoline() | ||
|
||
// Tell the linker that the libc_* functions are to be found | ||
// in a system library, with the libc_ prefix missing. | ||
|
||
//go:cgo_import_dynamic libc___system_property_get __system_property_get "libc.so" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#include "go_asm.h" | ||
#include "textflag.h" | ||
|
||
// These trampolines help convert from Go calling convention to C calling convention. | ||
// They should be called with asmcgocall - note that while asmcgocall does | ||
// stack alignment, creation of a frame undoes it again. | ||
// A pointer to the arguments is passed on the stack. | ||
// A single int32 result is returned in AX. | ||
// (For more results, make an args/results structure.) | ||
TEXT runtime·__system_property_get_trampoline(SB),NOSPLIT,$0 | ||
PUSHL BP | ||
MOVL SP, BP | ||
SUBL $8, SP | ||
MOVL 16(SP), DX // pointer to args | ||
MOVL 0(DX), AX | ||
MOVL 4(DX), DX | ||
MOVL AX, 0(SP) // arg 1 - name | ||
MOVL DX, 4(SP) // arg 2 - value | ||
MOVL $_GLOBAL_OFFSET_TABLE_(SB), BX | ||
CALL libc___system_property_get(SB) | ||
MOVL BP, SP | ||
POPL BP | ||
RET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#include "go_asm.h" | ||
#include "textflag.h" | ||
|
||
// These trampolines help convert from Go calling convention to C calling convention. | ||
// They should be called with asmcgocall. | ||
// A pointer to the arguments is passed in DI. | ||
// A single int32 result is returned in AX. | ||
// (For more results, make an args/results structure.) | ||
TEXT runtime·__system_property_get_trampoline(SB),NOSPLIT,$0 | ||
MOVQ 8(DI), SI // arg 2 - value | ||
MOVQ 0(DI), DI // arg 1 - name | ||
CALL libc___system_property_get(SB) | ||
RET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#include "go_asm.h" | ||
#include "textflag.h" | ||
|
||
// These trampolines help convert from Go calling convention to C calling convention. | ||
// They should be called with asmcgocall - note that while asmcgocall does | ||
// stack alignment, creation of a frame undoes it again. | ||
// A pointer to the arguments is passed in R0. | ||
// A single int32 result is returned in R0. | ||
// (For more results, make an args/results structure.) | ||
TEXT runtime·__system_property_get_trampoline(SB),NOSPLIT,$0 | ||
MOVW R13, R9 | ||
BIC $0x7, R13 // align for ELF ABI | ||
MOVW 4(R0), R1 // arg 2 - value | ||
MOVW 0(R0), R0 // arg 1 - name | ||
CALL libc___system_property_get(SB) | ||
MOVW R9, R13 | ||
RET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#include "go_asm.h" | ||
#include "textflag.h" | ||
|
||
// These trampolines help convert from Go calling convention to C calling convention. | ||
// They should be called with asmcgocall. | ||
// A pointer to the arguments is passed in R0. | ||
// A single int32 result is returned in R0. | ||
// (For more results, make an args/results structure.) | ||
TEXT runtime·__system_property_get_trampoline(SB),NOSPLIT,$0 | ||
MOVD 8(R0), R1 // arg 2 - value | ||
MOVD 0(R0), R0 // arg 1 - name | ||
CALL libc___system_property_get(SB) | ||
RET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters