On Fri, 13 Nov 2026 05:45:05 GMT, Timofei Fedotov <[email protected]> wrote:

> convolveBI() and convolveRaster() entry points read kern[klen - 1] without 
> requiring a nonempty kernel array.
> 
> In JDK 25 and earlier, new Kernel(0, 0, new float[0]) is accepted by the 
> constructor. If this reaches the native convolution code, kern[klen - 1] 
> becomes kern[-1], an out-of-bounds read.
> 
> JDK 26 added dimension validation to the Kernel constructor (JDK-8368729), 
> but the native methods still read the dimensions and coefficient array 
> directly from the object's fields. Inconsistent values can also be supplied 
> through reflection.
> 
> Both methods should reject invalid kernel dimensions and array lengths before 
> accessing the coefficients.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 001844c0
Author:    Timofei Fedotov <[email protected]>
Committer: Artem Semenov <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/001844c0e984a7c799104eb749a8e4d3c9f70b72
Stats:     105 lines in 3 files changed: 84 ins; 12 del; 9 mod

8397252: Native convolution reads before the kernel array for zero-sized kernels

Reviewed-by: prr, asemenov

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

PR: https://git.openjdk.org/jdk/pull/33887

Reply via email to