Message ID | 20230717145049.27642-1-ruc_gongyuanjun@163.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [1/1] net:tipc: check return value of pskb_trim() | expand |
From: Yuanjun Gong <ruc_gongyuanjun@163.com> Date: Mon, 17 Jul 2023 22:50:49 +0800 > goto free_skb if an unexpected result is returned by pskb_tirm() > in tipc_crypto_rcv_complete(). > > Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> > --- > net/tipc/crypto.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c > index 577fa5af33ec..1b86cea261a5 100644 > --- a/net/tipc/crypto.c > +++ b/net/tipc/crypto.c > @@ -1894,6 +1894,7 @@ static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead, > struct tipc_aead *tmp = NULL; > struct tipc_ehdr *ehdr; > struct tipc_node *n; > + int ret; > > /* Is this completed by TX? */ > if (unlikely(is_tx(aead->crypto))) { > @@ -1960,7 +1961,9 @@ static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead, > > skb_reset_network_header(*skb); > skb_pull(*skb, tipc_ehdr_size(ehdr)); > - pskb_trim(*skb, (*skb)->len - aead->authsize); > + ret = pskb_trim(*skb, (*skb)->len - aead->authsize); > + if (ret) No need to define ret. > + goto free_skb; > > /* Validate TIPCv2 message */ > if (unlikely(!tipc_msg_validate(skb))) { > -- > 2.17.1
diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c index 577fa5af33ec..1b86cea261a5 100644 --- a/net/tipc/crypto.c +++ b/net/tipc/crypto.c @@ -1894,6 +1894,7 @@ static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead, struct tipc_aead *tmp = NULL; struct tipc_ehdr *ehdr; struct tipc_node *n; + int ret; /* Is this completed by TX? */ if (unlikely(is_tx(aead->crypto))) { @@ -1960,7 +1961,9 @@ static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead, skb_reset_network_header(*skb); skb_pull(*skb, tipc_ehdr_size(ehdr)); - pskb_trim(*skb, (*skb)->len - aead->authsize); + ret = pskb_trim(*skb, (*skb)->len - aead->authsize); + if (ret) + goto free_skb; /* Validate TIPCv2 message */ if (unlikely(!tipc_msg_validate(skb))) {
goto free_skb if an unexpected result is returned by pskb_tirm() in tipc_crypto_rcv_complete(). Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> --- net/tipc/crypto.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)