]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
strparser: Fix sign of err codes
authorDave Watson <davejwatson@fb.com>
Mon, 26 Mar 2018 19:31:21 +0000 (12:31 -0700)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Thu, 12 Apr 2018 13:06:51 +0000 (10:06 -0300)
BugLink: http://bugs.launchpad.net/bugs/1763366
[ 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>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
net/strparser/strparser.c

index 1fdab5c4eda8c2a218448abb9bc461cf6474615c..b9283ce5cd85b5df0062b5137720b7b8afe6c3de 100644 (file)
@@ -60,7 +60,7 @@ static void strp_abort_strp(struct strparser *strp, int err)
                struct sock *sk = strp->sk;
 
                /* Report an error on the lower socket */
-               sk->sk_err = err;
+               sk->sk_err = -err;
                sk->sk_error_report(sk);
        }
 }
@@ -458,7 +458,7 @@ static void strp_msg_timeout(struct work_struct *w)
        /* Message assembly timed out */
        STRP_STATS_INCR(strp->stats.msg_timeouts);
        strp->cb.lock(strp);
-       strp->cb.abort_parser(strp, ETIMEDOUT);
+       strp->cb.abort_parser(strp, -ETIMEDOUT);
        strp->cb.unlock(strp);
 }