skbuff: don't mix ubuf_info from different sources
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 12 Jul 2022 20:52:27 +0000 (21:52 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 19 Jul 2022 02:58:45 +0000 (19:58 -0700)
We should not append MSG_ZEROCOPY requests to skbuff with non
MSG_ZEROCOPY ubuf_info, they might be not compatible.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/skbuff.c

index 5b3559cb1d82794c0fffcb3f6ec5b26fc523208f..09f56bfa2771e8a6785c12841fa6a8b74e5e04df 100644 (file)
@@ -1212,6 +1212,10 @@ struct ubuf_info *msg_zerocopy_realloc(struct sock *sk, size_t size,
                const u32 byte_limit = 1 << 19;         /* limit to a few TSO */
                u32 bytelen, next;
 
+               /* there might be non MSG_ZEROCOPY users */
+               if (uarg->callback != msg_zerocopy_callback)
+                       return NULL;
+
                /* realloc only when socket is locked (TCP, UDP cork),
                 * so uarg->len and sk_zckey access is serialized
                 */