[foreign-memaccess+abi] Integrated: 8294309: Downcall and Upcall unboxing code should reject heap segments

Jorn Vernee jvernee at openjdk.org
Tue Oct 4 13:37:52 UTC 2022


On Mon, 3 Oct 2022 21:16:41 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> Recently I noticed that we don't check for heap segments anymore when unboxing memory segments to be passed to native code as addresses. This allows someone to pass a heap segment, which will be unboxed simply by calling `MemorySegment::address` which for heap segments returns the byte offset into the array. This is of course not a valid pointer.
> 
> This patch changes the unboxing logic to reject heap segments with an `IllegalArgumentException`.

This pull request has now been integrated.

Changeset: ca57d13e
Author:    Jorn Vernee <jvernee at openjdk.org>
URL:       https://git.openjdk.org/panama-foreign/commit/ca57d13ebc27989abee43769655812e092d9ac36
Stats:     299 lines in 7 files changed: 233 ins; 53 del; 13 mod

8294309: Downcall and Upcall unboxing code should reject heap segments

Reviewed-by: mcimadamore

-------------

PR: https://git.openjdk.org/panama-foreign/pull/737


More information about the panama-dev mailing list