Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'vsock-fix-so_zerocopy-on-accept-ed-vsocks'

Michal Luczaj says:

====================
vsock: Fix SO_ZEROCOPY on accept()ed vsocks

vsock has its own handling of setsockopt(SO_ZEROCOPY). Which works just
fine unless socket comes from a call to accept(). Because
SOCK_CUSTOM_SOCKOPT flag is missing, attempting to set the option always
results in errno EOPNOTSUPP.
====================

Link: https://patch.msgid.link/20251229-vsock-child-sock-custom-sockopt-v2-0-64778d6c4f88@rbox.co
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+36
+4
net/vmw_vsock/af_vsock.c
··· 1787 1787 } else { 1788 1788 newsock->state = SS_CONNECTED; 1789 1789 sock_graft(connected, newsock); 1790 + 1791 + set_bit(SOCK_CUSTOM_SOCKOPT, 1792 + &connected->sk_socket->flags); 1793 + 1790 1794 if (vsock_msgzerocopy_allow(vconnected->transport)) 1791 1795 set_bit(SOCK_SUPPORT_ZC, 1792 1796 &connected->sk_socket->flags);
+32
tools/testing/vsock/vsock_test.c
··· 2192 2192 close(fd); 2193 2193 } 2194 2194 2195 + static void test_stream_accepted_setsockopt_client(const struct test_opts *opts) 2196 + { 2197 + int fd; 2198 + 2199 + fd = vsock_stream_connect(opts->peer_cid, opts->peer_port); 2200 + if (fd < 0) { 2201 + perror("connect"); 2202 + exit(EXIT_FAILURE); 2203 + } 2204 + 2205 + close(fd); 2206 + } 2207 + 2208 + static void test_stream_accepted_setsockopt_server(const struct test_opts *opts) 2209 + { 2210 + int fd; 2211 + 2212 + fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL); 2213 + if (fd < 0) { 2214 + perror("accept"); 2215 + exit(EXIT_FAILURE); 2216 + } 2217 + 2218 + enable_so_zerocopy_check(fd); 2219 + close(fd); 2220 + } 2221 + 2195 2222 static struct test_case test_cases[] = { 2196 2223 { 2197 2224 .name = "SOCK_STREAM connection reset", ··· 2397 2370 .name = "SOCK_SEQPACKET ioctl(SIOCINQ) functionality", 2398 2371 .run_client = test_seqpacket_unread_bytes_client, 2399 2372 .run_server = test_seqpacket_unread_bytes_server, 2373 + }, 2374 + { 2375 + .name = "SOCK_STREAM accept()ed socket custom setsockopt()", 2376 + .run_client = test_stream_accepted_setsockopt_client, 2377 + .run_server = test_stream_accepted_setsockopt_server, 2400 2378 }, 2401 2379 {}, 2402 2380 };