GeezerVison is showing github.com — Fix io_uring domain socket fd leak on multi-fd SCM_RIGHTS messages · netty/netty@e863e69
File treeExpand file treeCollapse file tree Open diff view settings transport-classes-io_uring/src main/java/io/netty/channel/uring test/java/io/netty/channel/uring
transport-native-io_uring/src/main/c
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/CmsgHdr.java +85-2Lines changed: 85 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | */ | 16 | 16 | package io.netty.channel.uring; | 17 | 17 |
| | 18 | +import io.netty.channel.unix.Errors; | | 19 | + | | 20 | +import java.io.IOException; | 18 | 21 | import java.nio.ByteBuffer; | 19 | 22 |
| 20 | 23 | /** | @@ -58,7 +61,87 @@ static void writeScmRights(ByteBuffer cmsghdr, int cmsgHdrDataOffset, int fd) { | 58 | 61 | cmsghdr.putInt(cmsghdrPosition + cmsgHdrDataOffset, fd); | 59 | 62 | } | 60 | 63 |
| 61 | | - static int readScmRights(ByteBuffer cmsghdr, int cmsgHdrDataOffset) { | 62 | | - return cmsghdr.getInt(cmsghdr.position() + cmsgHdrDataOffset); | | 64 | + /** | | 65 | + * Reads the file descriptor delivered via a {@code SCM_RIGHTS} control message. | | 66 | + * <p> | | 67 | + * A malicious (or buggy) peer can pack more than one file descriptor into the single control message that | | 68 | + * Netty only ever sizes for one fd. On 64-bit Linux {@code CMSG_SPACE(sizeof(int))} and | | 69 | + * {@code CMSG_SPACE(2 * sizeof(int))} are both 24 bytes (due to 8 byte alignment), so the kernel does not | | 70 | + * report {@code MSG_CTRUNC} even though two fds were delivered. If that is not detected the surplus fd is | | 71 | + * never closed and leaks for the lifetime of the process (see CVE-2026-45536 for the equivalent issue that | | 72 | + * was fixed for the epoll/kqueue transports in {@code netty_unix_socket_recvFd()}). | | 73 | + * <p> | | 74 | + * To guard against this we validate the cmsg level/type, compute the real number of fds from | | 75 | + * {@code cmsg_len} and, if more than one fd (or a truncated message) was received, close every fd we got | | 76 | + * and fail instead of silently returning a partial (and leaking) result. | | 77 | + * | | 78 | + * @throws IOException if the control message did not carry exactly one well-formed {@code SCM_RIGHTS} fd. | | 79 | + */ | | 80 | + static int readScmRights(ByteBuffer cmsghdr, int cmsgHdrDataOffset, boolean truncated) throws IOException { | | 81 | + int cmsghdrPosition = cmsghdr.position(); | | 82 | + long cmsgLen = Native.SIZEOF_SIZE_T == 4 | | 83 | + ? cmsghdr.getInt(cmsghdrPosition + Native.CMSG_OFFSETOF_CMSG_LEN) & 0xFFFFFFFFL | | 84 | + : cmsghdr.getLong(cmsghdrPosition + Native.CMSG_OFFSETOF_CMSG_LEN); | | 85 | + int cmsgLevel = cmsghdr.getInt(cmsghdrPosition + Native.CMSG_OFFSETOF_CMSG_LEVEL); | | 86 | + int cmsgType = cmsghdr.getInt(cmsghdrPosition + Native.CMSG_OFFSETOF_CMSG_TYPE); | | 87 | + | | 88 | + if (cmsgLevel != Native.SOL_SOCKET || cmsgType != Native.SCM_RIGHTS) { | | 89 | + throw new IOException( | | 90 | + "Received unexpected cmsg (level: " + cmsgLevel + ", type: " + cmsgType + ')'); | | 91 | + } | | 92 | + | | 93 | + // MSG_CTRUNC only means that some of the control data was discarded, the kernel still reports the fds it did | | 94 | + // deliver via cmsg_len. So always compute nfds from cmsg_len to be able to close whatever was delivered. | | 95 | + int nfds = numFds(cmsgLen, Native.CMSG_LEN_FOR_FD, Native.SIZEOF_INT); | | 96 | + if (truncated || nfds != 1) { | | 97 | + IOException error = new IOException(truncated | | 98 | + ? "Received a truncated SCM_RIGHTS cmsg (cmsg_len: " + cmsgLen + ')' | | 99 | + : nfds < 0 | | 100 | + ? "Received a malformed SCM_RIGHTS cmsg (cmsg_len: " + cmsgLen + ')' | | 101 | + : "Received " + nfds + " file descriptors in a single SCM_RIGHTS cmsg, expected 1"); | | 102 | + // Close every fd that was actually delivered so nothing leaks, even though we reject the message. | | 103 | + int toClose = numFdsToClose(nfds, truncated); | | 104 | + for (int i = 0; i < toClose; i++) { | | 105 | + closeQuietly(cmsghdr.getInt(cmsghdrPosition + cmsgHdrDataOffset + i * Native.SIZEOF_INT), error); | | 106 | + } | | 107 | + throw error; | | 108 | + } | | 109 | + return cmsghdr.getInt(cmsghdrPosition + cmsgHdrDataOffset); | | 110 | + } | | 111 | + | | 112 | + /** | | 113 | + * Computes how many file descriptors a {@code SCM_RIGHTS} cmsg of the given {@code cmsgLen} carries, given | | 114 | + * {@code cmsgLenForFd}, the platform's {@code CMSG_LEN(sizeof(int))} (the length of a cmsg holding exactly | | 115 | + * one fd), and {@code sizeofInt}, the platform's {@code sizeof(int)}. Returns {@code -1} if {@code cmsgLen} | | 116 | + * is smaller than one fd or not a whole number of fds (i.e. truncated or malformed). | | 117 | + * <p> | | 118 | + * Pure function of primitives (no native/JNI dependency) so it can be unit tested in isolation. | | 119 | + */ | | 120 | + static int numFds(long cmsgLen, int cmsgLenForFd, int sizeofInt) { | | 121 | + long dataLen = cmsgLen - (cmsgLenForFd - sizeofInt); | | 122 | + if (dataLen < sizeofInt || dataLen % sizeofInt != 0) { | | 123 | + return -1; | | 124 | + } | | 125 | + return (int) (dataLen / sizeofInt); | | 126 | + } | | 127 | + | | 128 | + /** | | 129 | + * Returns the number of delivered fds that must be closed because the message is rejected: all of them if the | | 130 | + * message was truncated (and at least one fd was delivered) or if more than one fd was delivered. | | 131 | + * <p> | | 132 | + * Pure function of primitives so it can be unit tested in isolation. | | 133 | + */ | | 134 | + static int numFdsToClose(int nfds, boolean truncated) { | | 135 | + return nfds > 0 && (truncated || nfds > 1) ? nfds : 0; | | 136 | + } | | 137 | + | | 138 | + private static void closeQuietly(int fd, Throwable error) { | | 139 | + if (fd < 0) { | | 140 | + return; | | 141 | + } | | 142 | + int res = Native.close(fd); | | 143 | + if (res < 0) { | | 144 | + error.addSuppressed(Errors.newIOException("close", res)); | | 145 | + } | 63 | 146 | } | 64 | 147 | } |
Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringDomainSocketChannel.java +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -223,6 +223,11 @@ protected void readComplete0(byte op, int res, int flags, short data, int outsta | 223 | 223 | final ChannelPipeline pipeline = pipeline(); | 224 | 224 | try { | 225 | 225 | int nativeCallResult = res >= 0 ? res : Errors.ioResult("io_uring recvmsg", res); | | 226 | + if (nativeCallResult == 0) { | | 227 | + // EOF: the peer closed the connection, so there is no control message to inspect. | | 228 | + shutdownInput(true); | | 229 | + return; | | 230 | + } | 226 | 231 | int nativeFd = readMsgHdrMemory.getScmRightsFd(); | 227 | 232 | allocHandle.lastBytesRead(nativeFd); | 228 | 233 | allocHandle.incMessagesRead(1); | |
Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/MsgHdr.java +12-2Lines changed: 12 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 |
| 18 | 18 | import io.netty.channel.unix.Buffer; | 19 | 19 |
| | 20 | +import java.io.IOException; | 20 | 21 | import java.nio.ByteBuffer; | 21 | 22 |
| 22 | 23 | /** | @@ -132,7 +133,16 @@ static void prepReadFd(ByteBuffer memory, ByteBuffer msgControl, int cmsgHdrData | 132 | 133 | } | 133 | 134 | } | 134 | 135 |
| 135 | | - static int getCmsgData(ByteBuffer memory, ByteBuffer msgControl, int cmsgHdrDataOffset) { | 136 | | - return CmsgHdr.readScmRights(msgControl, cmsgHdrDataOffset); | | 136 | + static int getCmsgData(ByteBuffer memory, ByteBuffer msgControl, int cmsgHdrDataOffset) throws IOException { | | 137 | + int memoryPosition = memory.position(); | | 138 | + long msgControlLen = Native.SIZEOF_SIZE_T == 4 | | 139 | + ? memory.getInt(memoryPosition + Native.MSGHDR_OFFSETOF_MSG_CONTROLLEN) & 0xFFFFFFFFL | | 140 | + : memory.getLong(memoryPosition + Native.MSGHDR_OFFSETOF_MSG_CONTROLLEN); | | 141 | + if (msgControlLen <= 0) { | | 142 | + throw new IOException("Received no ancillary data while expecting a SCM_RIGHTS file descriptor"); | | 143 | + } | | 144 | + int msgFlags = memory.getInt(memoryPosition + Native.MSGHDR_OFFSETOF_MSG_FLAGS); | | 145 | + boolean truncated = (msgFlags & Native.MSG_CTRUNC) != 0; | | 146 | + return CmsgHdr.readScmRights(msgControl, cmsgHdrDataOffset, truncated); | 137 | 147 | } | 138 | 148 | } |
Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/MsgHdrMemory.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 21 | 21 | import io.netty.util.internal.CleanableDirectBuffer; | 22 | 22 | import io.netty.util.internal.PlatformDependent; | 23 | 23 |
| | 24 | +import java.io.IOException; | 24 | 25 | import java.net.InetSocketAddress; | 25 | 26 | import java.nio.ByteBuffer; | 26 | 27 | import java.nio.ByteOrder; | @@ -140,7 +141,7 @@ void setScmRightsFd(int fd) { | 140 | 141 | MsgHdr.prepSendFd(msgHdrMemory, fd, cmsgDataMemory, cmsgDataOffset, iovMemory, 1); | 141 | 142 | } | 142 | 143 |
| 143 | | - int getScmRightsFd() { | | 144 | + int getScmRightsFd() throws IOException { | 144 | 145 | return MsgHdr.getCmsgData(msgHdrMemory, cmsgDataMemory, cmsgDataOffset); | 145 | 146 | } | 146 | 147 |
| |
Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/Native.java +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -116,6 +116,7 @@ final class Native { | 116 | 116 | NativeStaticallyReferencedJniMethods.sockaddrIn6OffsetofSin6ScopeId(); | 117 | 117 | static final int IN6_ADDRESS_OFFSETOF_S6_ADDR = NativeStaticallyReferencedJniMethods.in6AddressOffsetofS6Addr(); | 118 | 118 | static final int SIZEOF_SIZE_T = NativeStaticallyReferencedJniMethods.sizeofSizeT(); | | 119 | + static final int SIZEOF_INT = NativeStaticallyReferencedJniMethods.sizeofInt(); | 119 | 120 | static final int SIZEOF_IOVEC = NativeStaticallyReferencedJniMethods.sizeofIovec(); | 120 | 121 | static final int CMSG_SPACE = NativeStaticallyReferencedJniMethods.cmsgSpace(); | 121 | 122 | static final int CMSG_SPACE_FOR_FD = NativeStaticallyReferencedJniMethods.cmsgSpaceForFd(); | @@ -326,6 +327,7 @@ static String opToStr(byte op) { | 326 | 327 | static final int IOSQE_CQE_SKIP_SUCCESS = 1 << 6; | 327 | 328 | static final int MSG_DONTWAIT = NativeStaticallyReferencedJniMethods.msgDontwait(); | 328 | 329 | static final int MSG_FASTOPEN = NativeStaticallyReferencedJniMethods.msgFastopen(); | | 330 | + static final int MSG_CTRUNC = NativeStaticallyReferencedJniMethods.msgCtrunc(); | 329 | 331 | static final int SOL_UDP = NativeStaticallyReferencedJniMethods.solUdp(); | 330 | 332 | static final int SOL_SOCKET = NativeStaticallyReferencedJniMethods.solSocket(); | 331 | 333 | static final int UDP_SEGMENT = NativeStaticallyReferencedJniMethods.udpSegment(); | @@ -627,6 +629,12 @@ static IoUringProbe ioUringProbe(int ringfd) { | 627 | 629 |
| 628 | 630 | static native void eventFdWrite(int fd, long value); | 629 | 631 |
| | 632 | + /** | | 633 | + * Close the given fd, returning {@code 0} on success or the negated {@code errno} on failure. {@code EINTR} | | 634 | + * is treated as success, matching {@code FileDescriptor.close()} semantics. | | 635 | + */ | | 636 | + static native int close(int fd); | | 637 | + | 630 | 638 | static int getFd(DefaultFileRegion fileChannel) { | 631 | 639 | return getFd0(fileChannel); | 632 | 640 | } | |
Collapse file Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/NativeStaticallyReferencedJniMethods.java +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -54,6 +54,7 @@ private NativeStaticallyReferencedJniMethods() { } | 54 | 54 | static native int sockaddrUnOffsetofSunPath(); | 55 | 55 | static native int maxSunPathLen(); | 56 | 56 | static native int sizeofSizeT(); | | 57 | + static native int sizeofInt(); | 57 | 58 | static native int sizeofIovec(); | 58 | 59 | static native int iovecOffsetofIovBase(); | 59 | 60 | static native int iovecOffsetofIovLen(); | @@ -79,6 +80,7 @@ private NativeStaticallyReferencedJniMethods() { } | 79 | 80 | static native int msgDontwait(); | 80 | 81 | static native int iosqeBufferSelect(); | 81 | 82 | static native int msgFastopen(); | | 83 | + static native int msgCtrunc(); | 82 | 84 | static native int cmsgSpace(); | 83 | 85 | static native int cmsgSpaceForFd(); | 84 | 86 | static native int cmsgLen(); | |
Collapse file Copy file name to clipboard +101Lines changed: 101 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/* | | 2 | + * Copyright 2026 The Netty Project | | 3 | + * | | 4 | + * The Netty Project licenses this file to you under the Apache License, | | 5 | + * version 2.0 (the "License"); you may not use this file except in compliance | | 6 | + * with the License. You may obtain a copy of the License at: | | 7 | + * | | 8 | + * https://www.apache.org/licenses/LICENSE-2.0 | | 9 | + * | | 10 | + * Unless required by applicable law or agreed to in writing, software | | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | | 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | | 13 | + * License for the specific language governing permissions and limitations | | 14 | + * under the License. | | 15 | + */ | | 16 | +package io.netty.channel.uring; | | 17 | + | | 18 | +import org.junit.jupiter.api.Test; | | 19 | +import org.junit.jupiter.api.condition.EnabledForJreRange; | | 20 | +import org.junit.jupiter.api.condition.JRE; | | 21 | + | | 22 | +import static org.junit.jupiter.api.Assertions.assertEquals; | | 23 | + | | 24 | +/** | | 25 | + * Tests for {@link CmsgHdr#numFds(long, int, int)}, the pure fd-count computation used to detect a peer packing | | 26 | + * more than one file descriptor into the single {@code SCM_RIGHTS} control message that Netty's io_uring | | 27 | + * transport sizes for exactly one fd (CVE-2026-45536 equivalent for io_uring; the epoll/kqueue transports | | 28 | + * already guard against this in {@code netty_unix_socket_recvFd()}). | | 29 | + * <p> | | 30 | + * This test intentionally never touches the {@link Native} class (which loads the native library) so it can run | | 31 | + * without the io_uring native library being available, exactly like {@link LoadClassTest}. | | 32 | + */ | | 33 | +// CmsgHdr is compiled with release 9 (see the module's pom.xml), so it cannot be loaded on a Java 8 | | 34 | +// runtime; gate the whole class since every test here touches CmsgHdr. | | 35 | +@EnabledForJreRange(min = JRE.JAVA_9) | | 36 | +public class CmsgHdrTest { | | 37 | + | | 38 | + // sizeof(int) is 4 on every Linux architecture io_uring supports. | | 39 | + private static final int SIZEOF_INT = 4; | | 40 | + // CMSG_LEN(sizeof(int)) on 64-bit Linux: CMSG_ALIGN(sizeof(struct cmsghdr)) [16] + sizeof(int) [4]. | | 41 | + private static final int CMSG_LEN_FOR_FD_64BIT = 20; | | 42 | + // CMSG_LEN(sizeof(int)) on 32-bit Linux: CMSG_ALIGN(sizeof(struct cmsghdr)) [12] + sizeof(int) [4]. | | 43 | + private static final int CMSG_LEN_FOR_FD_32BIT = 16; | | 44 | + | | 45 | + @Test | | 46 | + public void singleFdIsAccepted() { | | 47 | + assertEquals(1, CmsgHdr.numFds(CMSG_LEN_FOR_FD_64BIT, CMSG_LEN_FOR_FD_64BIT, SIZEOF_INT)); | | 48 | + assertEquals(1, CmsgHdr.numFds(CMSG_LEN_FOR_FD_32BIT, CMSG_LEN_FOR_FD_32BIT, SIZEOF_INT)); | | 49 | + } | | 50 | + | | 51 | + @Test | | 52 | + public void twoFdsPackedIntoBufferSizedForOneAreDetected() { | | 53 | + // This is the crux of the vulnerability: on 64-bit Linux CMSG_SPACE(sizeof(int)) (the buffer Netty | | 54 | + // allocates) and CMSG_SPACE(2 * sizeof(int)) are both 24 bytes because of 8-byte alignment, so a peer | | 55 | + // can pack 2 fds into the same space without the kernel ever setting MSG_CTRUNC. cmsg_len for that | | 56 | + // 2-fd message is CMSG_LEN_FOR_FD + sizeof(int) == 24. | | 57 | + assertEquals(2, CmsgHdr.numFds(CMSG_LEN_FOR_FD_64BIT + 4, CMSG_LEN_FOR_FD_64BIT, SIZEOF_INT)); | | 58 | + } | | 59 | + | | 60 | + @Test | | 61 | + public void manyFdsPackedIntoOneCmsgAreDetected() { | | 62 | + assertEquals(5, CmsgHdr.numFds(CMSG_LEN_FOR_FD_64BIT + 4 * 4, CMSG_LEN_FOR_FD_64BIT, SIZEOF_INT)); | | 63 | + } | | 64 | + | | 65 | + @Test | | 66 | + public void cmsgLenSmallerThanOneFdIsTruncated() { | | 67 | + assertEquals(-1, CmsgHdr.numFds(CMSG_LEN_FOR_FD_64BIT - 1, CMSG_LEN_FOR_FD_64BIT, SIZEOF_INT)); | | 68 | + assertEquals(-1, CmsgHdr.numFds(0, CMSG_LEN_FOR_FD_64BIT, SIZEOF_INT)); | | 69 | + } | | 70 | + | | 71 | + @Test | | 72 | + public void cmsgLenNotAWholeNumberOfFdsIsMalformed() { | | 73 | + assertEquals(-1, CmsgHdr.numFds(CMSG_LEN_FOR_FD_64BIT + 1, CMSG_LEN_FOR_FD_64BIT, SIZEOF_INT)); | | 74 | + assertEquals(-1, CmsgHdr.numFds(CMSG_LEN_FOR_FD_64BIT + 3, CMSG_LEN_FOR_FD_64BIT, SIZEOF_INT)); | | 75 | + } | | 76 | + | | 77 | + @Test | | 78 | + public void truncatedMessageWithDeliveredFdsClosesThem() { | | 79 | + // MSG_CTRUNC does not mean no fd was delivered, so the delivered one needs to be closed. | | 80 | + assertEquals(1, CmsgHdr.numFdsToClose(1, true)); | | 81 | + assertEquals(2, CmsgHdr.numFdsToClose(2, true)); | | 82 | + } | | 83 | + | | 84 | + @Test | | 85 | + public void truncatedMessageWithoutDeliveredFdsClosesNothing() { | | 86 | + assertEquals(0, CmsgHdr.numFdsToClose(-1, true)); | | 87 | + assertEquals(0, CmsgHdr.numFdsToClose(0, true)); | | 88 | + } | | 89 | + | | 90 | + @Test | | 91 | + public void multipleFdsAreAllClosedEvenIfNotTruncated() { | | 92 | + assertEquals(2, CmsgHdr.numFdsToClose(2, false)); | | 93 | + assertEquals(5, CmsgHdr.numFdsToClose(5, false)); | | 94 | + } | | 95 | + | | 96 | + @Test | | 97 | + public void singleFdInNonTruncatedMessageIsNotClosed() { | | 98 | + assertEquals(0, CmsgHdr.numFdsToClose(1, false)); | | 99 | + assertEquals(0, CmsgHdr.numFdsToClose(-1, false)); | | 100 | + } | | 101 | +} |
Collapse file Copy file name to clipboardExpand all lines: transport-native-io_uring/src/main/c/netty_io_uring_native.c +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -222,6 +222,21 @@ static void netty_io_uring_eventFdWrite(JNIEnv* env, jclass clazz, jint fd, jlon | 222 | 222 | netty_unix_errors_throwChannelExceptionErrorNo(env, "eventfd_write(...) failed: ", err); | 223 | 223 | } | 224 | 224 |
| | 225 | +static jint netty_io_uring_close(JNIEnv* env, jclass clazz, jint fd) { | | 226 | + if (close(fd) < 0) { | | 227 | + // There is really nothing "sane" we can do when EINTR was reported on close. So just ignore it and | | 228 | + // "assume" everything is fine == we closed the file descriptor. | | 229 | + // | | 230 | + // For more details see: | | 231 | + // - https://bugs.chromium.org/p/chromium/issues/detail?id=269623 | | 232 | + // - https://lwn.net/Articles/576478/ | | 233 | + if (errno != EINTR) { | | 234 | + return -errno; | | 235 | + } | | 236 | + } | | 237 | + return 0; | | 238 | +} | | 239 | + | 225 | 240 | static jint netty_io_uring_getFd0(JNIEnv* env, jclass clazz, jobject fileRegion) { | 226 | 241 | jobject fileChannel = (*env)->GetObjectField(env, fileRegion, fileChannelFieldId); | 227 | 242 | if (fileChannel == NULL) { | @@ -600,6 +615,10 @@ static jint netty_io_uring_sizeofSizeT(JNIEnv* env, jclass clazz) { | 600 | 615 | return sizeof(size_t); | 601 | 616 | } | 602 | 617 |
| | 618 | +static jint netty_io_uring_sizeofInt(JNIEnv* env, jclass clazz) { | | 619 | + return sizeof(int); | | 620 | +} | | 621 | + | 603 | 622 | static jint netty_io_uring_sizeofIovec(JNIEnv* env, jclass clazz) { | 604 | 623 | return sizeof(struct iovec); | 605 | 624 | } | @@ -758,6 +777,10 @@ static jint netty_io_uring_msgFastopen(JNIEnv* env, jclass clazz) { | 758 | 777 | return MSG_FASTOPEN; | 759 | 778 | } | 760 | 779 |
| | 780 | +static jint netty_io_uring_msgCtrunc(JNIEnv* env, jclass clazz) { | | 781 | + return MSG_CTRUNC; | | 782 | +} | | 783 | + | 761 | 784 | static jint netty_io_uring_cmsgSpace(JNIEnv* env, jclass clazz) { | 762 | 785 | return CMSG_SPACE(sizeof(uint16_t)); | 763 | 786 | } | @@ -821,6 +844,7 @@ static const JNINativeMethod statically_referenced_fixed_method_table[] = { | 821 | 844 | { "sockaddrUnOffsetofSunPath", "()I", (void *) netty_io_uring_sockaddrUnOffsetofSunPath }, | 822 | 845 | { "maxSunPathLen", "()I", (void *) netty_io_uring_max_sun_path_len }, | 823 | 846 | { "sizeofSizeT", "()I", (void *) netty_io_uring_sizeofSizeT }, | | 847 | + { "sizeofInt", "()I", (void *) netty_io_uring_sizeofInt }, | 824 | 848 | { "sizeofIovec", "()I", (void *) netty_io_uring_sizeofIovec }, | 825 | 849 | { "cmsgSpace", "()I", (void *) netty_io_uring_cmsgSpace}, | 826 | 850 | { "cmsgSpaceForFd", "()I", (void *) netty_io_uring_cmsgSpace_for_fd}, | @@ -851,6 +875,7 @@ static const JNINativeMethod statically_referenced_fixed_method_table[] = { | 851 | 875 | { "iosqeBufferSelect", "()I", (void *) netty_io_uring_BufferSelect }, | 852 | 876 | { "msgDontwait", "()I", (void *) netty_io_uring_msgDontwait }, | 853 | 877 | { "msgFastopen", "()I", (void *) netty_io_uring_msgFastopen }, | | 878 | + { "msgCtrunc", "()I", (void *) netty_io_uring_msgCtrunc }, | 854 | 879 | { "solUdp", "()I", (void *) netty_io_uring_solUdp }, | 855 | 880 | { "solSocket", "()I", (void *) netty_io_uring_solSocket }, | 856 | 881 | { "udpSegment", "()I", (void *) netty_io_uring_udpSegment }, | @@ -882,6 +907,7 @@ static const JNINativeMethod method_table[] = { | 882 | 907 | {"ioUringEnter", "(IIII)I", (void *) netty_io_uring_enter}, | 883 | 908 | {"blockingEventFd", "()I", (void *) netty_epoll_native_blocking_event_fd}, | 884 | 909 | {"eventFdWrite", "(IJ)V", (void *) netty_io_uring_eventFdWrite }, | | 910 | + {"close", "(I)I", (void *) netty_io_uring_close }, | 885 | 911 | {"registerUnix", "()I", (void *) netty_io_uring_registerUnix }, | 886 | 912 | {"cmsghdrData", "(J)J", (void *) netty_io_uring_cmsghdrData}, | 887 | 913 | {"kernelVersion", "()Ljava/lang/String;", (void *) netty_io_uring_kernel_version }, | |
|