Skip to content

Commit

Permalink
tls: Pass error code explicitly to tls_err_abort
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dave Watson authored and David S. Miller committed Mar 23, 2018
1 parent dbe4255 commit f4a8e43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions include/net/tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ static inline bool tls_is_pending_open_record(struct tls_context *tls_ctx)
return tls_ctx->pending_open_record_frags;
}

static inline void tls_err_abort(struct sock *sk)
static inline void tls_err_abort(struct sock *sk, int err)
{
sk->sk_err = EBADMSG;
sk->sk_err = err;
sk->sk_error_report(sk);
}

Expand All @@ -197,7 +197,7 @@ static inline void tls_advance_record_sn(struct sock *sk,
struct cipher_context *ctx)
{
if (tls_bigint_increment(ctx->rec_seq, ctx->rec_seq_size))
tls_err_abort(sk);
tls_err_abort(sk, EBADMSG);
tls_bigint_increment(ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
ctx->iv_size);
}
Expand Down
2 changes: 1 addition & 1 deletion net/tls/tls_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static int tls_push_record(struct sock *sk, int flags,
/* Only pass through MSG_DONTWAIT and MSG_NOSIGNAL flags */
rc = tls_push_sg(sk, tls_ctx, ctx->sg_encrypted_data, 0, flags);
if (rc < 0 && rc != -EAGAIN)
tls_err_abort(sk);
tls_err_abort(sk, EBADMSG);

tls_advance_record_sn(sk, &tls_ctx->tx);
return rc;
Expand Down

0 comments on commit f4a8e43

Please sign in to comment.