Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: esp: cleanup esp_output_tail_tcp() in case of unsupported ESPINTCP

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>

authored by

Hagar Hemdan and committed by
Steffen Klassert
96f887a6 9c91c7fa

+2 -4
+1 -2
net/ipv4/esp4.c
··· 239 239 #else 240 240 static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb) 241 241 { 242 - kfree_skb(skb); 243 - 242 + WARN_ON(1); 244 243 return -EOPNOTSUPP; 245 244 } 246 245 #endif
+1 -2
net/ipv6/esp6.c
··· 256 256 #else 257 257 static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb) 258 258 { 259 - kfree_skb(skb); 260 - 259 + WARN_ON(1); 261 260 return -EOPNOTSUPP; 262 261 } 263 262 #endif