diff options
| author | Stefano Brivio <sbrivio@redhat.com> | 2026-12-01 02:04:29 +0100 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-12-02 22:59:29 +0100 |
| commit | 6569a6f6c94e656a04f77132f853666550b744c7 (patch) | |
| tree | 33ccf8edef50b73c5f8f886fea1c277bd67d2a1a | |
| parent | ffb4d5f7f68e455cc300b4285b5bef89f6d87ec0 (diff) | |
| download | passt-6569a6f6c94e656a04f77132f853666550b744c7.tar passt-6569a6f6c94e656a04f77132f853666550b744c7.tar.gz passt-6569a6f6c94e656a04f77132f853666550b744c7.tar.bz2 passt-6569a6f6c94e656a04f77132f853666550b744c7.tar.lz passt-6569a6f6c94e656a04f77132f853666550b744c7.tar.xz passt-6569a6f6c94e656a04f77132f853666550b744c7.tar.zst passt-6569a6f6c94e656a04f77132f853666550b744c7.zip | |
tcp: Fix return value of tcp_tap_handler() on SO_PEEK_OFF failure
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 <sbrivio@redhat.com>
| -rw-r--r-- | tcp.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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. */ |
