From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 03B1C5A0272; Tue, 01 Dec 2026 09:24:36 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 1/3] tcp: Fix return value of tcp_tap_handler() on SO_PEEK_OFF failure Date: Tue, 1 Dec 2026 09:24:33 +0100 Message-ID: <20261201082435.1302453-2-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261201082435.1302453-1-sbrivio@redhat.com> References: <20261201082435.1302453-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: RQEYBXZVVTXE2NQU3IINU7EEHIAR7XQI X-Message-ID-Hash: RQEYBXZVVTXE2NQU3IINU7EEHIAR7XQI X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier , Jon Maloy X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This can't actually happen with the current kernel implementation of SO_PEEK_OFF, but still it's rather fragile and obviously wrong: tcp_tap_handler() should never return negative values, but that's what the error path for tcp_rewind_seq() actually does. For some reason, Coverity Scan spotted this only after 6637c202f261 ("tap: Explicitly drop outbound IPv6 fragments, warn about them") in combination with other recent commits. Instead of -1, return a value corresponding to one consumed packet. While at it, fix the comment to tcp_data_from_tap() indicating that, there, -1 is a legitimate return value instead. Fixes: bde1847960cf ("tcp: Fast re-transmit if half-closed, make TAP_FIN_RCVD path consistent") Signed-off-by: Stefano Brivio --- tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcp.c b/tcp.c index 15a41c5..481cdfb 100644 --- a/tcp.c +++ b/tcp.c @@ -1935,7 +1935,7 @@ static ssize_t tcp_packet_data_len(const struct tcphdr *th, size_t l4len) * * #syscalls sendmsg * - * Return: count of consumed packets + * Return: count of consumed packets, -1 on unrecoverable connection error */ static int tcp_data_from_tap(const struct ctx *c, struct tcp_tap_conn *conn, const struct pool *p, int idx, @@ -2450,7 +2450,7 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af, ntohl(th->ack_seq), conn->seq_to_tap); if (tcp_rewind_seq(c, conn, now)) - return -1; + return packet_next(p, idx) - idx; } /* An unchanged ACK and window must not restart the timer. */ -- 2.43.0