Message ID | 20230717144930.26197-1-ruc_gongyuanjun@163.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/1] net: ipv4: fix return value check in esp_remove_trailer() | expand |
On 7/17/23 8:49 AM, Yuanjun Gong wrote: > return an error number if an unexpected result is returned by > pskb_tirm() in esp_remove_trailer(). > > Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> > --- > net/ipv4/esp4.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c > index ba06ed42e428..0660bf2bdbae 100644 > --- a/net/ipv4/esp4.c > +++ b/net/ipv4/esp4.c > @@ -732,7 +732,10 @@ static inline int esp_remove_trailer(struct sk_buff *skb) > skb->csum = csum_block_sub(skb->csum, csumdiff, > skb->len - trimlen); > } > - pskb_trim(skb, skb->len - trimlen); > + if (pskb_trim(skb, skb->len - trimlen)) { > + ret = -EINVAL; pskb_trim returns the error from ___pskb_trim; use it instead of changing it here. > + goto out; > + } > > ret = nexthdr[1]; >
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index ba06ed42e428..0660bf2bdbae 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -732,7 +732,10 @@ static inline int esp_remove_trailer(struct sk_buff *skb) skb->csum = csum_block_sub(skb->csum, csumdiff, skb->len - trimlen); } - pskb_trim(skb, skb->len - trimlen); + if (pskb_trim(skb, skb->len - trimlen)) { + ret = -EINVAL; + goto out; + } ret = nexthdr[1];
return an error number if an unexpected result is returned by pskb_tirm() in esp_remove_trailer(). Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> --- net/ipv4/esp4.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)