Skip to content

ffi: validate pointer ranges in optimized calls - #66371

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-bigint-range-validation
Open

trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-bigint-range-validation

Conversation

@trivikr

@trivikr trivikr commented Sep 28, 2026

Copy link
Copy Markdown
Member

Fixes: #66370

On x64 SysV and arm64, a Fast API signature with two or more arguments that uses only pointer and float types got no JS wrapper. V8 then truncated pointer BigInts silently. With -1n or 2n ** 64n + 5n, cold calls threw ERR_INVALID_ARG_VALUE, while optimized calls passed 0xffffffffffffffff or 5 to native code.

Use the argument wrapper for any signature with a pointer argument.


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 c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Sep 28, 2026
On x64 SysV and arm64, a Fast API signature with two or more
arguments that uses only pointer and float types got no JS wrapper.
V8 then truncated pointer BigInts silently. With `-1n` or
`2n ** 64n + 5n`, cold calls threw ERR_INVALID_ARG_VALUE, while
optimized calls passed 0xffffffffffffffff or 5 to native code.

Use the argument wrapper for any signature with a pointer argument.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
@trivikr
trivikr force-pushed the ffi-bigint-range-validation branch from 4896eb3 to f448808 Compare September 28, 2026 06:05
@trivikr trivikr added the ffi Issues and PRs related to experimental Foreign Function Interface support. label Sep 28, 2026
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.36%. Comparing base (75e4bbe) to head (f448808).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66371      +/-   ##
==========================================
- Coverage   90.36%   90.36%   -0.01%     
==========================================
  Files         792      792              
  Lines      275398   275425      +27     
  Branches    52776    52789      +13     
==========================================
+ Hits       248877   248900      +23     
+ Misses      16937    16935       -2     
- Partials     9584     9590       +6     
Files with missing lines Coverage Δ
src/node_ffi.cc 72.32% <100.00%> (-0.09%) ⬇️

... and 21 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.

@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 Sep 28, 2026
@daeyeon daeyeon added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 28, 2026
@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 Sep 28, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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. c++ Issues and PRs that require attention from people who are familiar with C++. 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: optimized calls skip BigInt range validation for pointer arguments

3 participants