]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: esp: cleanup esp_output_tail_tcp() in case of unsupported ESPINTCP
authorHagar Hemdan <hagarhem@amazon.com>
Sat, 18 May 2024 13:04:39 +0000 (13:04 +0000)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 23 May 2024 06:46:03 +0000 (08:46 +0200)
xmit() functions should consume skb or return error codes in error
paths.
When the configuration "CONFIG_INET_ESPINTCP" is not set, the
implementation of the function "esp_output_tail_tcp" violates this rule.
The function frees the skb and returns the error code.
This change removes the kfree_skb from both functions, for both
esp4 and esp6.
WARN_ON is added because esp_output_tail_tcp() should never be called if
CONFIG_INET_ESPINTCP is not set.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
Signed-off-by: Hagar Hemdan <hagarhem@amazon.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/ipv4/esp4.c
net/ipv6/esp6.c

index 3968d3f98e08302570f722ef8acb76353dd6ef16..619a4df7be1e809a2bba648707582a54ec2170c9 100644 (file)
@@ -239,8 +239,7 @@ static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb)
 #else
 static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb)
 {
-       kfree_skb(skb);
-
+       WARN_ON(1);
        return -EOPNOTSUPP;
 }
 #endif
index 34a9a5b9ed00b794f09556757322e14f11f1652a..3920e8aa1031ee2ecc0e92276bfb8132bae16656 100644 (file)
@@ -256,8 +256,7 @@ static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb)
 #else
 static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb)
 {
-       kfree_skb(skb);
-
+       WARN_ON(1);
        return -EOPNOTSUPP;
 }
 #endif