lkml.org 
[lkml]   [2018]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 308/310] strparser: Fix sign of err codes
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Dave Watson <davejwatson@fb.com>


    [ Upstream commit cd00edc179863848abab5cc5683de5b7b5f70954 ]

    strp_parser_err is called with a negative code everywhere, which then
    calls abort_parser with a negative code. strp_msg_timeout calls
    abort_parser directly with a positive code. Negate ETIMEDOUT
    to match signed-ness of other calls.

    The default abort_parser callback, strp_abort_strp, sets
    sk->sk_err to err. Also negate the error here so sk_err always
    holds a positive value, as the rest of the net code expects. Currently
    a negative sk_err can result in endless loops, or user code that
    thinks it actually sent/received err bytes.

    Found while testing net/tls_sw recv path.

    Fixes: 43a0c6751a322847 ("strparser: Stream parser for messages")
    Signed-off-by: Dave Watson <davejwatson@fb.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/strparser/strparser.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    --- a/net/strparser/strparser.c
    +++ b/net/strparser/strparser.c
    @@ -59,7 +59,7 @@ static void strp_abort_rx_strp(struct st
    strp->rx_stopped = 1;

    /* Report an error on the lower socket */
    - csk->sk_err = err;
    + csk->sk_err = -err;
    csk->sk_error_report(csk);
    }

    @@ -422,7 +422,7 @@ static void strp_rx_msg_timeout(unsigned
    /* Message assembly timed out */
    STRP_STATS_INCR(strp->stats.rx_msg_timeouts);
    lock_sock(strp->sk);
    - strp->cb.abort_parser(strp, ETIMEDOUT);
    + strp->cb.abort_parser(strp, -ETIMEDOUT);
    release_sock(strp->sk);
    }


    \
     
     \ /
      Last update: 2018-04-11 21:10    [W:4.176 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site