Skip to content

Commit f4a8e43

Browse files
Dave Watsondavem330
authored andcommitted
tls: Pass error code explicitly to tls_err_abort
Pass EBADMSG explicitly to tls_err_abort. Receive path will pass additional codes - EMSGSIZE if framing is larger than max TLS record size, EINVAL if TLS version mismatch. Signed-off-by: Dave Watson <davejwatson@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dbe4255 commit f4a8e43

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/net/tls.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ static inline bool tls_is_pending_open_record(struct tls_context *tls_ctx)
174174
return tls_ctx->pending_open_record_frags;
175175
}
176176

177-
static inline void tls_err_abort(struct sock *sk)
177+
static inline void tls_err_abort(struct sock *sk, int err)
178178
{
179-
sk->sk_err = EBADMSG;
179+
sk->sk_err = err;
180180
sk->sk_error_report(sk);
181181
}
182182

@@ -197,7 +197,7 @@ static inline void tls_advance_record_sn(struct sock *sk,
197197
struct cipher_context *ctx)
198198
{
199199
if (tls_bigint_increment(ctx->rec_seq, ctx->rec_seq_size))
200-
tls_err_abort(sk);
200+
tls_err_abort(sk, EBADMSG);
201201
tls_bigint_increment(ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
202202
ctx->iv_size);
203203
}

net/tls/tls_sw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int tls_push_record(struct sock *sk, int flags,
214214
/* Only pass through MSG_DONTWAIT and MSG_NOSIGNAL flags */
215215
rc = tls_push_sg(sk, tls_ctx, ctx->sg_encrypted_data, 0, flags);
216216
if (rc < 0 && rc != -EAGAIN)
217-
tls_err_abort(sk);
217+
tls_err_abort(sk, EBADMSG);
218218

219219
tls_advance_record_sn(sk, &tls_ctx->tx);
220220
return rc;

0 commit comments

Comments
 (0)