Skip to content

Commit 5ef7f6b

Browse files
committed
Merge branch 'tls-splice-hint-fixes'
John Fastabend says: ==================== tls fixes for SPLICE with more hint Syzbot found a splat where it tried to splice data over a tls socket with the more hint and sending greater than the number of frags that fit in a msg scatterlist. This resulted in an error where we do not correctly send the data when the msg sg is full. The more flag being just a hint not a strict contract. This then results in the syzbot warning on the next send. Edward generated an initial patch for this which checked for a full msg on entry to the sendmsg hook. This fixed the WARNING, but didn't fully resolve the issue because the full msg_pl scatterlist was never sent resulting in a stuck socket. In this series instead avoid the situation by forcing the send on the splice that fills the scatterlist. Also in original thread I mentioned it didn't seem to be enough to simply fix the send on full sg problem. That was incorrect and was really a bug in my test program that was hanging the test program. I had setup a repair socket and wasn't handling it correctly so my tester got stuck. Thanks. Please review. Fix in patch 1 and test in patch 2. v2: use SPLICE_F_ flag names instead of cryptic 0xe ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 894d750 + 034ea13 commit 5ef7f6b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

net/tls/tls_sw.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,11 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,
10521052
if (ret < 0)
10531053
goto send_end;
10541054
tls_ctx->pending_open_record_frags = true;
1055-
if (full_record || eor || sk_msg_full(msg_pl))
1055+
1056+
if (sk_msg_full(msg_pl))
1057+
full_record = true;
1058+
1059+
if (full_record || eor)
10561060
goto copied;
10571061
continue;
10581062
}

tools/testing/selftests/net/tls.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,20 @@ TEST_F(tls, splice_from_pipe)
707707
EXPECT_EQ(memcmp(mem_send, mem_recv, send_len), 0);
708708
}
709709

710+
TEST_F(tls, splice_more)
711+
{
712+
unsigned int f = SPLICE_F_NONBLOCK | SPLICE_F_MORE | SPLICE_F_GIFT;
713+
int send_len = TLS_PAYLOAD_MAX_LEN;
714+
char mem_send[TLS_PAYLOAD_MAX_LEN];
715+
int i, send_pipe = 1;
716+
int p[2];
717+
718+
ASSERT_GE(pipe(p), 0);
719+
EXPECT_GE(write(p[1], mem_send, send_len), 0);
720+
for (i = 0; i < 32; i++)
721+
EXPECT_EQ(splice(p[0], NULL, self->fd, NULL, send_pipe, f), 1);
722+
}
723+
710724
TEST_F(tls, splice_from_pipe2)
711725
{
712726
int send_len = 16000;

0 commit comments

Comments
 (0)