# GHSA-X2J7-6J3J-5VWJ: Summary With IORING\_RECVSEND\_BUNDLE, one completion can span several consecutive provided-buffer ring entries

- Database: GitHub
- Severity: CVSS 5.3 (Medium)
- Published: 2026-12-02
- Modified: 2026-12-02

## Tracked as

- [CVE-2026-142439](https://cve.now/CVE-2026-142439.md): Io.netty/netty-transport-classes-io\_uring: netty: iouringbufferring.nextbid() predicts wrong buffer id under recvsend\_bundle

## Affected versions

- io.netty:netty-transport-classes-io\_uring (Maven): from 4.2.0.Final, through 4.2.18.Final

## Description

### Summary

With `IORING_RECVSEND_BUNDLE`, one completion can span several consecutive provided-buffer ring entries. `AbstractIoUringStreamChannel` walks them with `bid = bufferRing.nextBid(bid)`, and `IoUringBufferRing.nextBid` (IoUringBufferRing.java:271-273) computes `(bid + 1) & (allocatedBuffers - 1)`. That equals `(bid + 1) % allocatedBuffers` only when `allocatedBuffers` is a power of two **and** hasn't changed since the kernel consumed the entries. Two reachable states break it:

- **A. Non-power-of-two ring.** `IoUringBufferRingConfig` accepts any `batchSize` in `[1, ringSize]`, and the ring grows by `batchSize` per expansion. For example, `ringSize=16, batchSize=4` goes 4 → 8 → 12 → 16. At `allocatedBuffers=12`, `nextBid(3) = 4 & 11 = 0` (should be 4), and `nextBid(11) = 12 & 11 = 8` (should be 0).
- **B. Expansion during a bundle.** The `useBuffer(bid)` call that empties the ring grows `allocatedBuffers` before the caller asks `nextBid(bid)` (IoUringBufferRing.java:241-266). With `batchSize = ringSize/2`, a bundle spanning bid 7 → 0 sees `allocatedBuffers` go 8 → 16, so `nextBid(7) = 8` (should be 0).

### Impact

In both cases Netty reads the wrong ring slot:
- The rest of the received data is taken from a different buffer, possibly one still posted for other reads (**wrong or foreign data delivered to the pipeline**).
- The buffer the kernel actually filled is never delivered and its bid is never recycled (**buffer leak / ring stall**).
- A ring entry can be left pointing at a buffer Netty has already released, so a later kernel write would go into released memory (**possible use-after-free**).

A remote peer only has to send data in a pattern that produces bundle completions.

**Preconditions (these limit exposure):**
- `RECVSEND_BUNDLE` is **disabled by default** in `IoUring` (`io.netty.iouring.recvsendBundleEnabled=false`, because of a known kernel bug). Only users who opt in are affected.
- It needs the io_uring transport with a provided buffer ring (`IoUringBufferRingConfig`). Scenario A needs `batchSize < ringSize/2`.
- Linux only.

### Reproduction

I didn't run this against a real Linux kernel. I compiled the real `transport-classes-io_uring` sources against a small JNI stub and drove `useBuffer`/`nextBid` with a simulated kernel that consumes consecutive ring entries. The ring memory layout and the bid arithmetic are pure Java.

```
== scenario A, batchSize 4
after ENOBUFS round 1: allocatedBuffers=12
kernel filled bids 3,4 (consecutive ring entries), allocatedBuffers=12
nextBid(3) = 0   (kernel used bid 4)
delivered to pipeline: [bid 3: AAAAAAAA] [bid 0: ........]
== scenario B, default batchSize
kernel bundle used bids 7,0
allocatedBuffers now 16; nextBid(7) = 8   (kernel used bid 0)
delivered to pipeline: [bid 7: AAAAAAAA] [bid 8: ........]
kernel-filled buffer of bid 0 never delivered and never recycled: true
```

`batchSize 8` on a 16-entry ring, where `allocatedBuffers` is always a power of two, behaves correctly. This is a sibling of #17568 (the missing per-entry clamp in `useBuffer`), in the same RECVSEND_BUNDLE multi-entry path.

### Suggested fix

Don't derive the next bid from the current `allocatedBuffers`. Either:
- mask by the fixed ring size (`entries`, always a power of two) and don't grow the ring in the middle of a bundle walk (defer the expansion until the bundle loop in `AbstractIoUringStreamChannel` finishes), or
- track the bid sequence of the bundle explicitly.

Also consider keeping `allocatedBuffers` a power of two, for example by growing in power-of-two steps.

---
Found by modelling the arithmetic in Lean 4 and reproducing it against the real classes on 4.2 HEAD (cd967a41). The same code is on 5.0 (and 4.1 where the class exists) as of 2026-09-23. Reported by @allthingssecurity; the analysis and this report were prepared with Claude Code (Claude Opus 5.5). A patch with regression tests can follow once you confirm how you want to handle it.

## References

- https://github.com/netty/netty/security/advisories/GHSA-x2j7-6j3j-5vwj

Page: https://cve.now/GHSA-X2J7-6J3J-5VWJ

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
