Commit 32a2fd96 authored by Dave Watson's avatar Dave Watson Committed by Greg Kroah-Hartman

strparser: Fix sign of err codes


[ Upstream commit cd00edc1 ]

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: 43a0c675 ("strparser: Stream parser for messages")
Signed-off-by: default avatarDave Watson <davejwatson@fb.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d392d2e
......@@ -59,7 +59,7 @@ static void strp_abort_rx_strp(struct strparser *strp, int err)
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 long arg)
/* 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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment