Skip to content

[client] Disable pidfd check on Android 11 and below #4127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 9, 2025

Conversation

pappz
Copy link
Contributor

@pappz pappz commented Jul 9, 2025

Describe your changes

On Android 11 (SDK <= 30) and earlier, pidfd-related system calls are blocked by seccomp policies, causing SIGSYS crashes.

This change overrides checkPidfdOnce to return an error on affected versions, preventing the use of unsupported pidfd features.

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

On Android 11 (SDK <= 30) and earlier, pidfd-related system calls
are blocked by seccomp policies, causing SIGSYS crashes.

This change overrides `checkPidfdOnce` to return an error on
affected versions, preventing the use of unsupported pidfd features.
@Copilot Copilot AI review requested due to automatic review settings July 9, 2025 19:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR disables pidfd checks on Android SDK 30 and below to prevent SIGSYS crashes and updates the client constructor to apply this workaround.

  • Introduce execWorkaround in exec.go to override checkPidfdOnce for Android SDK ≤30
  • Update NewClient signature in client.go to accept an androidVersion parameter and invoke execWorkaround

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
client/android/exec.go Added execWorkaround to stub out pidfd checks on Android SDK ≤30
client/android/client.go Modified NewClient signature to take androidVersion and call the workaround
Comments suppressed due to low confidence (4)

client/android/client.go:67

  • Changing the NewClient signature is a breaking API change and will affect all callers. Consider providing an overload or defaulting to the existing behavior to maintain backward compatibility.
func NewClient(cfgFile string, androidVersion int, deviceName string, uiVersion string, tunAdapter TunAdapter, iFaceDiscover IFaceDiscover, networkChangeListener NetworkChangeListener) *Client {

client/android/client.go:67

  • [nitpick] The parameter androidVersion could be renamed to androidSDKVersion to match the naming in execWorkaround and clarify that it expects the SDK level, not OS version code name.
func NewClient(cfgFile string, androidVersion int, deviceName string, uiVersion string, tunAdapter TunAdapter, iFaceDiscover IFaceDiscover, networkChangeListener NetworkChangeListener) *Client {

client/android/exec.go:18

  • The new execWorkaround function alters global behavior based on SDK version but lacks tests. Add unit tests covering both branches (SDK >30 and ≤30) to ensure correctness.
func execWorkaround(androidSDKVersion int) {

client/android/exec.go:24

  • [nitpick] The error message is generic and doesn’t indicate which SDK levels are unsupported. Consider including the SDK version in the message, e.g., fmt.Errorf("pidfd unsupported on Android SDK %d or below", androidSDKVersion).
		return fmt.Errorf("unsupported Android version")

hakansa
hakansa previously approved these changes Jul 9, 2025
Copy link

sonarqubecloud bot commented Jul 9, 2025

@pappz pappz requested a review from hakansa July 9, 2025 19:58
@pappz pappz merged commit 408f423 into main Jul 9, 2025
32 checks passed
@pappz pappz deleted the fix/pidfd-workaround branch July 9, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants