From: netdev-bot+sashiko@kernel.org
To: zibuyu423@gmail.com
Cc: mptcp@lists.linux.dev, kuba@kernel.org
Subject: Re: [PATCH mptcp-next 2/2] selftests: mptcp: exercise socket option propagation and behavior
Date: Sat, 05 Dec 2026 04:09:32 +0000 [thread overview]
Message-ID: <179644377218.3143.17955908305598888026@kernel.org> (raw)
In-Reply-To: <179630953225.20.15369199654780650380.mptcp-525-0002@gmail.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 4
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] TEST_F(sockopt, rx_timestamp) in
tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c is racy and can…
- [Low] TEST_F(sockopt, priority_and_incoming_cpu) in
tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c (lines 315-328)…
- [Low] selftests: mptcp: missing netns isolation and EADDRNOTAVAIL skip
- [Low] selftests/mptcp: uninitialized buffer read in
check_bound_device()
- [Low] selftests/mptcp: buffer_sizes SO_SNDBUF 8192 doubles to default
tcp_wmem[1]
--
selftests: mptcp: exercise socket option propagation and behavior
This adds a new kselftest harness program, mptcp_sockopt_test. It checks
that options set on an MPTCP listener reach the TCP socket underneath by
inspecting fallback children. It also covers SO_LINGER, TCP_DEFER_ACCEPT,
IPV6_V6ONLY, integer socket options and RX software timestamps via
SO_TIMESTAMPING_NEW on negotiated MPTCP connections.
Link: https://github.com/multipath-tcp/mptcp_net-next/issues/525
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c
> new file mode 100644
> index 0000000000000..48ca5522ed0b7
> --- /dev/null
> +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt_test.c
> @@ -0,0 +1,348 @@
[ ... ]
> +TEST_F(sockopt, rx_timestamp)
> +{
> + const struct so_timestamping opt = {
> + .flags = SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_RX_SOFTWARE,
> + };
[ ... ]
> + connect_pair(_metadata, &self->server, IPPROTO_MPTCP, &client, &child);
> + ASSERT_EQ(setsockopt(child, SOL_SOCKET, SO_TIMESTAMPING_NEW, &opt, optlen), 0);
> + ASSERT_EQ(write(client, &byte, 1), 1);
> + ASSERT_EQ(recvmsg(child, &msg, 0), 1);
> + ASSERT_EQ(msg.msg_flags & MSG_CTRUNC, 0);
> + cmsg = CMSG_FIRSTHDR(&msg);
> + ASSERT_NE(cmsg, NULL);
[Severity: Medium]
Can this assertion fail now and then even when the kernel is working
correctly?
Take a kernel built with CONFIG_JUMP_LABEL=y where no other socket on the
system uses timestamps. In that case the setsockopt() above does not turn
on netstamp_needed_key right away. net_enable_timestamp() only schedules
the enable for later:
net/core/dev.c:net_enable_timestamp() {
...
atomic_inc(&netstamp_needed_deferred);
schedule_work(&netstamp_work);
...
}
The key is turned on later by netstamp_clear(), which runs on a kworker.
On loopback, the receive side runs inside the write() call itself. Both
places that set the RX software timestamp check the key first:
loopback_xmit()->__netif_rx()->netif_rx_internal()->net_timestamp_check()
ip_local_deliver_finish()->skb_clear_delivery_time()
include/linux/skbuff.h:skb_clear_delivery_time() {
...
if (static_branch_unlikely(&netstamp_needed_key))
skb->tstamp = ktime_get_real();
else
skb->tstamp = 0;
...
}
If the kworker has not finished static_branch_enable() yet, skb->tstamp
is 0. tcp_v4_fill_cb() then leaves has_rxtstamp false, and
__mptcp_recvmsg_mskq() never sets MPTCP_CMSG_TS:
net/mptcp/protocol.c:__mptcp_recvmsg_mskq() {
...
if (MPTCP_SKB_CB(skb)->has_rxtstamp &&
tcp_want_rx_tstamp_cmsg(sk)) {
tcp_update_recv_tstamps(skb, tss);
*cmsg_flags |= MPTCP_CMSG_TS;
...
}
In that case no cmsg is sent, CMSG_FIRSTHDR() returns NULL and the test
fails.
The second iteration seems to have the same problem. Closing the first
child calls net_disable_timestamp(), which schedules a decrement for
later. That decrement can turn the key off again before the next enable.
Could the test avoid depending on when the scheduled key enable finishes,
for example by retrying until a timestamped segment arrives?
[ ... ]
> +TEST_F(sockopt, priority_and_incoming_cpu)
> +{
> + static const int opts[] = { SO_PRIORITY, SO_INCOMING_CPU };
> + unsigned int i;
> +
> + start_listener(_metadata, &self->server);
> + for (i = 0; i < ARRAY_SIZE(opts); i++) {
> + int value = 2;
> +
> + ASSERT_EQ(setsockopt(self->server.fd, SOL_SOCKET, opts[i],
> + &value, sizeof(value)), 0);
> + ASSERT_EQ(read_int_opt(_metadata, self->server.fd, SOL_SOCKET, opts[i]), value);
[Severity: Low]
Does this check exercise any of the MPTCP propagation?
The value is read back from self->server.fd, which is the msk itself.
The generic sk_getsockopt() handles SOL_SOCKET getsockopt on it. The msk
field is written before any subflow loop runs, either by
sock_setsockopt() in mptcp_sol_socket_intval() or by
WRITE_ONCE(sk->sk_incoming_cpu) in mptcp_so_incoming_cpu().
The MPTCP-specific copies are the per-subflow ones in
mptcp_sol_socket_sync_intval():
net/mptcp/sockopt.c:mptcp_sol_socket_sync_intval() {
...
case SO_PRIORITY:
WRITE_ONCE(ssk->sk_priority, val);
break;
...
case SO_INCOMING_CPU:
WRITE_ONCE(ssk->sk_incoming_cpu, val);
break;
...
}
and the copy made at subflow creation in sync_socket_options():
net/mptcp/sockopt.c:sync_socket_options() {
...
ssk->sk_priority = sk->sk_priority;
ssk->sk_bound_dev_if = sk->sk_bound_dev_if;
ssk->sk_incoming_cpu = sk->sk_incoming_cpu;
...
}
This test would still pass if either of these were removed. The commit
message gives the goal as checking "whether listener options reach the
TCP socket underneath".
The other tests in this file check a fallback child. Could SO_PRIORITY be
checked the same way through connect_pair(), since sk_priority is copied
to the child when it is cloned?
[ ... ]
> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
> --- a/tools/testing/selftests/net/mptcp/Makefile
> +++ b/tools/testing/selftests/net/mptcp/Makefile
> @@ -19,6 +19,8 @@ TEST_PROGS := \
> userspace_pm.sh \
> # end of TEST_PROGS
>
> +TEST_GEN_PROGS := mptcp_sockopt_test
> +
> TEST_GEN_FILES := \
> mptcp_connect \
> mptcp_diag \
[Severity: Low]
Is it intended that this binary runs directly in the caller's network
namespace?
Every other test in this directory runs inside namespaces created by
mptcp_lib_ns_init(), including the C helpers driven by
mptcp_sockopt.sh. Listing mptcp_sockopt_test in TEST_GEN_PROGS means
the runner executes it in the host netns, so host sysctls leak into
the results.
Two cases look like they turn into failures rather than skips:
With net.ipv6.conf.lo.disable_ipv6=1, or ipv6.disable_ipv6=1 on the
command line, inet6_create() still succeeds, so FIXTURE_SETUP() does
not skip the ipv6 variant. But ::1 is not configured on lo, so the
bind() in start_listener() fails with EADDRNOTAVAIL from
__inet6_bind() and the assertion fires. Since ipv6.disable_ipv6=1 is
also inherited by new namespaces through addrconf_init_net(), this
looks like it needs an explicit skip on EADDRNOTAVAIL even with netns
isolation, similar to what udp_splice_checksum.c does.
With net.ipv4.tcp_syncookies=2 on the host, tcp_conn_request() always
answers with a cookie and no request sock is hashed. The bare ACK from
the client then goes through cookie_v4_check() or cookie_v6_check()
and tcp_get_cookie_sock(), and never reaches the rskq_defer_accept
check in tcp_check_req(). The child is queued right away, the listener
becomes readable, and the first poll() in the defer_accept test
returns 1 instead of 0. A fresh namespace starts with
sysctl_tcp_syncookies set to 1 by tcp_sk_init(), which avoids this.
Would it make sense to run this from a small wrapper script that uses
mptcp_lib_ns_init(), or to unshare(CLONE_NEWNET) when permitted? If
so, please keep unprivileged runs working, since the debug test
already expects to be run without CAP_NET_ADMIN.
[ ... ]
> @@ -0,0 +1,348 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <arpa/inet.h>
> +#include <linux/net_tstamp.h>
> +#include <linux/errqueue.h>
> +#include <net/if.h>
> +#include <netinet/tcp.h>
> +#include <poll.h>
> +
> +#include "../../kselftest_harness.h"
> +
> +#ifndef IPPROTO_MPTCP
> +#define IPPROTO_MPTCP 262
> +#endif
> +
> +struct listener {
> + int fd;
> + union {
> + struct sockaddr sa;
> + struct sockaddr_in v4;
> + struct sockaddr_in6 v6;
> + } addr;
> + socklen_t addrlen;
> +};
> +
> +FIXTURE(sockopt) {
> + struct listener server;
> +};
> +
> +FIXTURE_VARIANT(sockopt) {
> + int family;
> +};
> +
> +FIXTURE_VARIANT_ADD(sockopt, ipv4) {
> + .family = AF_INET,
> +};
> +
> +FIXTURE_VARIANT_ADD(sockopt, ipv6) {
> + .family = AF_INET6,
> +};
> +
> +FIXTURE_SETUP(sockopt)
> +{
> + self->server.fd = socket(variant->family, SOCK_STREAM, IPPROTO_MPTCP);
> + if (self->server.fd < 0 && (errno == EPROTONOSUPPORT ||
> + errno == ENOPROTOOPT || errno == EAFNOSUPPORT))
> + SKIP(return, "MPTCP unavailable for address family %d", variant->family);
> + ASSERT_GE(self->server.fd, 0);
> +
> + if (variant->family == AF_INET) {
> + self->server.addr.v4.sin_family = AF_INET;
> + self->server.addr.v4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
> + self->server.addrlen = sizeof(self->server.addr.v4);
> + } else {
> + self->server.addr.v6.sin6_family = AF_INET6;
> + self->server.addr.v6.sin6_addr = in6addr_loopback;
> + self->server.addrlen = sizeof(self->server.addr.v6);
> + }
> +}
> +
> +FIXTURE_TEARDOWN(sockopt)
> +{
> + if (self->server.fd >= 0)
> + close(self->server.fd);
> +}
> +
> +static void start_listener(struct __test_metadata *_metadata,
> + struct listener *server)
> +{
> + ASSERT_EQ(bind(server->fd, &server->addr.sa, server->addrlen), 0);
> + ASSERT_EQ(listen(server->fd, 1), 0);
> + ASSERT_EQ(getsockname(server->fd, &server->addr.sa, &server->addrlen), 0);
> +}
> +
> +static void connect_pair(struct __test_metadata *_metadata,
> + struct listener *server, int protocol,
> + int *client, int *child)
> +{
> + int accepted_proto;
> + socklen_t len = sizeof(accepted_proto);
> +
> + *client = socket(server->addr.sa.sa_family, SOCK_STREAM, protocol);
> + ASSERT_GE(*client, 0);
> + ASSERT_EQ(connect(*client, &server->addr.sa, server->addrlen), 0);
> + *child = accept(server->fd, NULL, NULL);
> + ASSERT_GE(*child, 0);
> + ASSERT_EQ(getsockopt(*child, SOL_SOCKET, SO_PROTOCOL, &accepted_proto, &len), 0);
> + ASSERT_EQ(accepted_proto, protocol);
> +}
> +
> +TEST_F(sockopt, linger)
> +{
> + static const struct linger cases[] = {
> + { .l_onoff = 1, .l_linger = 7 },
> + { .l_onoff = 1, .l_linger = 0 },
> + { .l_onoff = 0 },
> + };
> + int child, client;
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(cases); i++) {
> + struct linger got;
> + socklen_t len = sizeof(got);
> + char buf;
> +
> + ASSERT_EQ(setsockopt(self->server.fd, SOL_SOCKET, SO_LINGER,
> + &cases[i], sizeof(cases[i])), 0);
> + if (!i)
> + start_listener(_metadata, &self->server);
> +
> + /* A fallback child inherits its options from the TCP listener. */
> + connect_pair(_metadata, &self->server, IPPROTO_TCP, &client, &child);
> + ASSERT_EQ(getsockopt(child, SOL_SOCKET, SO_LINGER, &got, &len), 0);
> + ASSERT_EQ(len, sizeof(got));
> + ASSERT_EQ(got.l_onoff, cases[i].l_onoff);
> + if (got.l_onoff)
> + ASSERT_EQ(got.l_linger, cases[i].l_linger);
> + close(child);
> +
> + if (cases[i].l_onoff && !cases[i].l_linger) {
> + ASSERT_EQ(read(client, &buf, 1), -1);
> + ASSERT_EQ(errno, ECONNRESET);
> + } else {
> + ASSERT_EQ(read(client, &buf, 1), 0);
> + }
> + close(client);
> + }
> +}
> +
> +TEST_F(sockopt, congestion)
> +{
> + static const char reno[] = "reno";
> + static const char invalid[] = "no-such-tcp-cc";
> + int child, client;
> + char name[32];
> + socklen_t len;
> +
> + /* Exercise an existing TCP subflow and verify its fallback child. */
> + start_listener(_metadata, &self->server);
> + ASSERT_EQ(setsockopt(self->server.fd, IPPROTO_TCP, TCP_CONGESTION,
> + reno, sizeof(reno)), 0);
> + ASSERT_EQ(setsockopt(self->server.fd, IPPROTO_TCP, TCP_CONGESTION,
> + invalid, sizeof(invalid)), -1);
> + ASSERT_EQ(errno, ENOENT);
> +
> + connect_pair(_metadata, &self->server, IPPROTO_TCP, &client, &child);
> + len = sizeof(name);
> + ASSERT_EQ(getsockopt(child, IPPROTO_TCP, TCP_CONGESTION, name, &len), 0);
> + ASSERT_STREQ(name, reno);
> + close(child);
> + close(client);
> +}
> +
> +TEST_F(sockopt, rx_timestamp)
> +{
> + const struct so_timestamping opt = {
> + .flags = SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_RX_SOFTWARE,
> + };
> + int child, client;
> + char byte = 't';
> + unsigned int i;
> +
> + start_listener(_metadata, &self->server);
> + for (i = 0; i < 2; i++) {
> + union {
> + struct cmsghdr align;
> + char buf[CMSG_SPACE(sizeof(struct scm_timestamping64))];
> + } control;
> + struct iovec iov = { .iov_base = &byte, .iov_len = 1 };
> + struct msghdr msg = {
> + .msg_iov = &iov,
> + .msg_iovlen = 1,
> + .msg_control = control.buf,
> + .msg_controllen = sizeof(control.buf),
> + };
> + struct scm_timestamping64 ts;
> + struct cmsghdr *cmsg;
> + socklen_t optlen = i ? sizeof(opt) : sizeof(opt.flags);
> +
> + connect_pair(_metadata, &self->server, IPPROTO_MPTCP, &client, &child);
> + ASSERT_EQ(setsockopt(child, SOL_SOCKET, SO_TIMESTAMPING_NEW, &opt, optlen), 0);
> + ASSERT_EQ(write(client, &byte, 1), 1);
> + ASSERT_EQ(recvmsg(child, &msg, 0), 1);
> + ASSERT_EQ(msg.msg_flags & MSG_CTRUNC, 0);
> + cmsg = CMSG_FIRSTHDR(&msg);
> + ASSERT_NE(cmsg, NULL);
> + ASSERT_EQ(cmsg->cmsg_level, SOL_SOCKET);
> + ASSERT_EQ(cmsg->cmsg_type, SO_TIMESTAMPING_NEW);
> + ASSERT_EQ(cmsg->cmsg_len, CMSG_LEN(sizeof(ts)));
> + memcpy(&ts, CMSG_DATA(cmsg), sizeof(ts));
> + ASSERT_GT(ts.ts[0].tv_sec, 0);
> + ASSERT_GE(ts.ts[0].tv_nsec, 0);
> + ASSERT_LT(ts.ts[0].tv_nsec, 1000000000);
> + close(child);
> + close(client);
> + }
> +}
> +
> +TEST_F(sockopt, defer_accept)
> +{
> + struct pollfd pfd = { .fd = self->server.fd, .events = POLLIN };
> + int client, child, timeout = 10;
> + char byte = 'x';
> +
> + ASSERT_EQ(setsockopt(self->server.fd, IPPROTO_TCP, TCP_DEFER_ACCEPT,
> + &timeout, sizeof(timeout)), 0);
> + start_listener(_metadata, &self->server);
> + client = socket(variant->family, SOCK_STREAM, IPPROTO_TCP);
> + ASSERT_GE(client, 0);
> + ASSERT_EQ(connect(client, &self->server.addr.sa, self->server.addrlen), 0);
> +
> + /* The TCP handshake alone should not wake the MPTCP listener. */
> + ASSERT_EQ(poll(&pfd, 1, 100), 0);
> + ASSERT_EQ(write(client, &byte, 1), 1);
> + ASSERT_EQ(poll(&pfd, 1, 5000), 1);
> + ASSERT_EQ(pfd.revents, POLLIN);
> + child = accept(self->server.fd, NULL, NULL);
> + ASSERT_GE(child, 0);
> + ASSERT_EQ(read(child, &byte, 1), 1);
> + ASSERT_EQ(byte, 'x');
> + close(child);
> + close(client);
> +}
> +
> +static int read_int_opt(struct __test_metadata *_metadata, int fd, int level, int opt)
> +{
> + int val;
> + socklen_t len = sizeof(val);
> +
> + ASSERT_EQ(getsockopt(fd, level, opt, &val, &len), 0);
> + ASSERT_EQ(len, sizeof(val));
> + return val;
> +}
> +
> +TEST_F(sockopt, freebind)
> +{
> + int level = variant->family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6;
> + int opt = variant->family == AF_INET ? IP_FREEBIND : IPV6_FREEBIND;
> + int child, client, on = 1;
> +
> + ASSERT_EQ(setsockopt(self->server.fd, level, opt, &on, sizeof(on)), 0);
> + start_listener(_metadata, &self->server);
> + connect_pair(_metadata, &self->server, IPPROTO_TCP, &client, &child);
> + ASSERT_EQ(read_int_opt(_metadata, child, level, opt), 1);
> + close(child);
> + close(client);
> +}
> +
> +TEST_F(sockopt, v6only)
> +{
> + struct sockaddr_in6 mapped = { .sin6_family = AF_INET6 };
> + int on = 1;
> +
> + if (variant->family != AF_INET6)
> + SKIP(return, "IPv6 only");
> +
> + ASSERT_EQ(inet_pton(AF_INET6, "::ffff:127.0.0.1", &mapped.sin6_addr), 1);
> + ASSERT_EQ(setsockopt(self->server.fd, IPPROTO_IPV6, IPV6_V6ONLY,
> + &on, sizeof(on)), 0);
> + ASSERT_EQ(read_int_opt(_metadata, self->server.fd, IPPROTO_IPV6, IPV6_V6ONLY), 1);
> + ASSERT_EQ(bind(self->server.fd, (struct sockaddr *)&mapped, sizeof(mapped)), -1);
> + ASSERT_EQ(errno, EINVAL);
> +}
> +
> +static void check_bound_device(struct __test_metadata *_metadata,
> + struct listener *server)
> +{
> + int client, child;
> + socklen_t len;
> + char name[IFNAMSIZ];
> +
> + start_listener(_metadata, server);
> + connect_pair(_metadata, server, IPPROTO_TCP, &client, &child);
> + len = sizeof(name);
> + ASSERT_EQ(getsockopt(child, SOL_SOCKET, SO_BINDTODEVICE, name, &len), 0);
> + ASSERT_STREQ(name, "lo");
> + ASSERT_EQ(read_int_opt(_metadata, child, SOL_SOCKET, SO_BINDTOIFINDEX),
> + if_nametoindex("lo"));
> + close(child);
> + close(client);
> +}
> +
> +TEST_F(sockopt, bind_to_ifindex)
> +{
> + int ifindex = if_nametoindex("lo");
> +
> + ASSERT_GT(ifindex, 0);
> + ASSERT_EQ(setsockopt(self->server.fd, SOL_SOCKET, SO_BINDTOIFINDEX,
> + &ifindex, sizeof(ifindex)), 0);
> + check_bound_device(_metadata, &self->server);
> +}
> +
> +TEST_F(sockopt, bind_to_device)
> +{
> + ASSERT_EQ(setsockopt(self->server.fd, SOL_SOCKET, SO_BINDTODEVICE,
> + "lo", sizeof("lo")), 0);
> + check_bound_device(_metadata, &self->server);
> +}
> +
> +TEST_F(sockopt, debug)
> +{
> + int on = 1, client, child;
> +
> + start_listener(_metadata, &self->server);
> + if (setsockopt(self->server.fd, SOL_SOCKET, SO_DEBUG, &on, sizeof(on))) {
> + ASSERT_EQ(errno, EACCES);
> + SKIP(return, "SO_DEBUG needs CAP_NET_ADMIN in the initial user namespace");
> + }
> + connect_pair(_metadata, &self->server, IPPROTO_TCP, &client, &child);
> + ASSERT_EQ(read_int_opt(_metadata, child, SOL_SOCKET, SO_DEBUG), 1);
> + close(child);
> + close(client);
> +}
> +
> +TEST_F(sockopt, priority_and_incoming_cpu)
> +{
> + static const int opts[] = { SO_PRIORITY, SO_INCOMING_CPU };
> + unsigned int i;
> +
> + start_listener(_metadata, &self->server);
> + for (i = 0; i < ARRAY_SIZE(opts); i++) {
> + int value = 2;
> +
> + ASSERT_EQ(setsockopt(self->server.fd, SOL_SOCKET, opts[i],
> + &value, sizeof(value)), 0);
> + ASSERT_EQ(read_int_opt(_metadata, self->server.fd, SOL_SOCKET, opts[i]), value);
> + }
> +}
> +
> +TEST_F(sockopt, buffer_sizes)
> +{
> + static const int opts[] = { SO_SNDBUF, SO_RCVBUF };
> + int child, client, size = 8192;
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(opts); i++)
> + ASSERT_EQ(setsockopt(self->server.fd, SOL_SOCKET, opts[i],
> + &size, sizeof(size)), 0);
> + start_listener(_metadata, &self->server);
> + connect_pair(_metadata, &self->server, IPPROTO_TCP, &client, &child);
> + for (i = 0; i < ARRAY_SIZE(opts); i++)
> + ASSERT_EQ(read_int_opt(_metadata, child, SOL_SOCKET, opts[i]),
> + read_int_opt(_metadata, self->server.fd, SOL_SOCKET, opts[i]));
> + close(child);
> + close(client);
> +}
> +
> +TEST_HARNESS_MAIN
>
[Severity: Low]
Does the SO_SNDBUF half of this test move the value away from its
default?
sk_setsockopt() stores max_t(int, val * 2, SOCK_MIN_SNDBUF) for
SO_SNDBUF, so 8192 becomes 16384. That is the same as the default
sysctl_tcp_wmem[1] set in tcp_init(), which is what a new TCP socket
and a new msk both start with in sk_sndbuf. So the listener and the
child would both report 16384 even if the msk value were never copied
to the subflow.
SOCK_SNDBUF_LOCK propagation is still covered indirectly, since an
unlocked child would have its sndbuf grown by tcp_sndbuf_expand() from
tcp_init_buffer_space(), and SO_RCVBUF is fine because 16384 differs
from the default tcp_rmem[1] of 131072. But a regression that copies
the lock flag without the sk_sndbuf value would go unnoticed.
Could a size be used whose doubled value differs from both defaults,
such as 12288, or could the test check that the listener value
changed from what it read before the setsockopt()?
[Severity: Low]
What happens here if the device binding does not reach the child?
name is not initialised and len is not checked after the
SO_BINDTODEVICE getsockopt(). For an unbound socket,
sock_getbindtodevice() takes the bound_dev_if == 0 branch, reports a
length of 0 and returns success without writing anything to optval.
ASSERT_STREQ() then runs strcmp() on uninitialised stack bytes, and
the failure message prints them with %s, which can read past the end
of name[IFNAMSIZ].
This only matters on the failure path, and the SO_BINDTOIFINDEX check
that follows would still catch an unbound child. But the diagnostic
for exactly the regression this test is meant to catch would be
garbage, and with unlucky stack contents the string check could even
pass.
Could name be zero-initialised, and len checked against sizeof("lo")
before the string comparison?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179630953224.20.3586549954582163150.mptcp-525-0000%40gmail.com
next prev parent reply other threads:[~2026-12-05 4:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:52 [PATCH mptcp-next 0/2] selftests: mptcp: exercise socket options across listen and accept Ruilin Mao
2026-12-03 14:52 ` [PATCH mptcp-next 1/2] selftests/net: use the fixture protocol in the late bind test Ruilin Mao
2026-12-03 17:32 ` Matthieu Baerts
2026-12-03 14:52 ` [PATCH mptcp-next 2/2] selftests: mptcp: exercise socket option propagation and behavior Ruilin Mao
2026-12-03 15:22 ` sashiko-bot
2026-12-05 4:09 ` netdev-bot+sashiko [this message]
2026-12-03 17:29 ` [PATCH mptcp-next 0/2] selftests: mptcp: exercise socket options across listen and accept Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179644377218.3143.17955908305598888026@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=kuba@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=zibuyu423@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.