Skip to content

ffi: remove permission checks from dlclose and dlsym - #66426

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-permissions-close-sym
Open

trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-permissions-close-sym

Conversation

@trivikr

@trivikr trivikr commented Oct 1, 2026

Copy link
Copy Markdown
Member

Fixes: #66425

The docs describe ffi.dlclose(handle) and ffi.dlsym(handle, symbol) as equivalent to handle.close() and handle.getSymbol(symbol), but only the functions called checkFFIPermission(). After process.permission.drop('ffi'), ffi.dlclose(lib) threw ERR_ACCESS_DENIED while lib.close() succeeded.

Remove the checks so the functions defer to the handle. Permission is already checked when the DynamicLibrary is constructed, and dropping a permission does not revoke resources that are already open.


Assisted-by: claude:opus-5.5

The docs describe `ffi.dlclose(handle)` and `ffi.dlsym(handle, symbol)`
as equivalent to `handle.close()` and `handle.getSymbol(symbol)`, but
only the functions called `checkFFIPermission()`. After
`process.permission.drop('ffi')`, `ffi.dlclose(lib)` threw
`ERR_ACCESS_DENIED` while `lib.close()` succeeded.

Remove the checks so the functions defer to the handle. Permission is
already checked when the `DynamicLibrary` is constructed, and dropping
a permission does not revoke resources that are already open.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi

@nodejs-github-bot nodejs-github-bot added ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Oct 1, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 1, 2026
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.37%. Comparing base (d7ea02d) to head (b83b2af).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66426   +/-   ##
=======================================
  Coverage   90.37%   90.37%           
=======================================
  Files         792      792           
  Lines      275683   275681    -2     
  Branches    52854    52849    -5     
=======================================
- Hits       249147   249146    -1     
+ Misses      16947    16941    -6     
- Partials     9589     9594    +5     
Files with missing lines Coverage Δ
lib/ffi.js 96.35% <ø> (-0.02%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 1, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@addaleax addaleax added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 1, 2026
@github-actions github-actions Bot added request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 1, 2026
@github-actions

This comment was marked as resolved.

@panva panva removed the request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. label Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi: dlclose()/dlsym() check permissions that handle.close()/handle.getSymbol() don't

5 participants