Skip to content

Commit

Permalink
strparser: Fix sign of err codes
Browse files Browse the repository at this point in the history
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: 43a0c67 ("strparser: Stream parser for messages")
Signed-off-by: Dave Watson <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Dave Watson authored and davem330 committed Mar 27, 2018
1 parent 734549e commit cd00edc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/strparser/strparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit cd00edc

Please sign in to comment.