lkml.org 
[lkml]   [2020]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.6 037/177] net/tls: fix encryption error checking
    Date
    From: Vadim Fedorenko <vfedorenko@novek.ru>

    commit a7bff11f6f9afa87c25711db8050c9b5324db0e2 upstream.

    bpf_exec_tx_verdict() can return negative value for copied
    variable. In that case this value will be pushed back to caller
    and the real error code will be lost. Fix it using signed type and
    checking for positive value.

    Fixes: d10523d0b3d7 ("net/tls: free the record on encryption error")
    Fixes: d3b18ad31f93 ("tls: add bpf support to sk_msg handling")
    Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    net/tls/tls_sw.c | 11 ++++++-----
    1 file changed, 6 insertions(+), 5 deletions(-)

    --- a/net/tls/tls_sw.c
    +++ b/net/tls/tls_sw.c
    @@ -784,7 +784,7 @@ static int tls_push_record(struct sock *

    static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk,
    bool full_record, u8 record_type,
    - size_t *copied, int flags)
    + ssize_t *copied, int flags)
    {
    struct tls_context *tls_ctx = tls_get_ctx(sk);
    struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx);
    @@ -920,7 +920,8 @@ int tls_sw_sendmsg(struct sock *sk, stru
    unsigned char record_type = TLS_RECORD_TYPE_DATA;
    bool is_kvec = iov_iter_is_kvec(&msg->msg_iter);
    bool eor = !(msg->msg_flags & MSG_MORE);
    - size_t try_to_copy, copied = 0;
    + size_t try_to_copy;
    + ssize_t copied = 0;
    struct sk_msg *msg_pl, *msg_en;
    struct tls_rec *rec;
    int required_size;
    @@ -1129,7 +1130,7 @@ send_end:

    release_sock(sk);
    mutex_unlock(&tls_ctx->tx_lock);
    - return copied ? copied : ret;
    + return copied > 0 ? copied : ret;
    }

    static int tls_sw_do_sendpage(struct sock *sk, struct page *page,
    @@ -1143,7 +1144,7 @@ static int tls_sw_do_sendpage(struct soc
    struct sk_msg *msg_pl;
    struct tls_rec *rec;
    int num_async = 0;
    - size_t copied = 0;
    + ssize_t copied = 0;
    bool full_record;
    int record_room;
    int ret = 0;
    @@ -1245,7 +1246,7 @@ wait_for_memory:
    }
    sendpage_end:
    ret = sk_stream_error(sk, flags, ret);
    - return copied ? copied : ret;
    + return copied > 0 ? copied : ret;
    }

    int tls_sw_sendpage_locked(struct sock *sk, struct page *page,

    \
     
     \ /
      Last update: 2020-06-01 20:41    [W:5.787 / U:0.088 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site