Skip to content

Commit 02eca68

Browse files
nkarstensNipaLocal
authored andcommitted
strparser: Fix signed/unsigned mismatch bug
The `len` member of the sk_buff is an unsigned int. This is cast to `ssize_t` (a signed type) for the first sk_buff in the comparison, but not the second sk_buff. On 32-bit systems, this can result in an integer underflow for certain values because unsigned arithmetic is being used. This appears to be an oversight: if the intention was to use unsigned arithmetic, then the first cast would have been omitted. The change ensures both len values are cast to `ssize_t`. The underflow causes an issue with ktls when multiple TLS PDUs are included in a single TCP segment. The mainline kernel does not use strparser for ktls anymore, but this is still useful for other features that still use strparser, and for backporting. Signed-off-by: Nate Karstens <[email protected]> Cc: [email protected] Fixes: 43a0c67 ("strparser: Stream parser for messages") Signed-off-by: NipaLocal <nipa@local>
1 parent 3947825 commit 02eca68

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/strparser/strparser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
238238
strp_parser_err(strp, -EMSGSIZE, desc);
239239
break;
240240
} else if (len <= (ssize_t)head->len -
241-
skb->len - stm->strp.offset) {
241+
(ssize_t)skb->len - stm->strp.offset) {
242242
/* Length must be into new skb (and also
243243
* greater than zero)
244244
*/

0 commit comments

Comments
 (0)