ipv4: tcp_input: fix stack out of bounds when parsing TCP options.
[platform/kernel/linux-starfive.git] / net / ipv4 / tcp_input.c
index c61edd0..08a477e 100644 (file)
@@ -3791,6 +3791,8 @@ void tcp_parse_options(const struct net *net,
                        length--;
                        continue;
                default:
+                       if (length < 2)
+                               return;
                        opsize = *ptr++;
                        if (opsize < 2) /* "silly options" */
                                return;