* [PATCH] net: xfrm: fix return value check in ipcomp_compress
@ 2023-10-06 11:41 Ma Ke
2023-10-06 11:47 ` Florian Westphal
0 siblings, 1 reply; 3+ messages in thread
From: Ma Ke @ 2023-10-06 11:41 UTC (permalink / raw)
To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Ma Ke
In ipcomp_compress, to avoid an unexpected result returned by
pskb_trim, we should check the return value of pskb_trim().
Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
net/xfrm/xfrm_ipcomp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index 9c0fa0e1786a..5f2e6edadf48 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -144,7 +144,9 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
local_bh_enable();
- pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
+ err = pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
+ if (unlikely(err))
+ goto out;
return 0;
out:
--
2.37.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: xfrm: fix return value check in ipcomp_compress
2023-10-06 11:41 [PATCH] net: xfrm: fix return value check in ipcomp_compress Ma Ke
@ 2023-10-06 11:47 ` Florian Westphal
2023-10-06 11:59 ` Florian Westphal
0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2023-10-06 11:47 UTC (permalink / raw)
To: Ma Ke
Cc: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, netdev,
linux-kernel
Ma Ke <make_ruc2021@163.com> wrote:
> In ipcomp_compress, to avoid an unexpected result returned by
> pskb_trim, we should check the return value of pskb_trim().
>
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
> net/xfrm/xfrm_ipcomp.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
> index 9c0fa0e1786a..5f2e6edadf48 100644
> --- a/net/xfrm/xfrm_ipcomp.c
> +++ b/net/xfrm/xfrm_ipcomp.c
> @@ -144,7 +144,9 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
> memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
> local_bh_enable();
>
> - pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
> + err = pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
> + if (unlikely(err))
> + goto out;
This can't be right, this now calls local_bh_enable() twice.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: xfrm: fix return value check in ipcomp_compress
2023-10-06 11:47 ` Florian Westphal
@ 2023-10-06 11:59 ` Florian Westphal
0 siblings, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2023-10-06 11:59 UTC (permalink / raw)
To: Florian Westphal
Cc: Ma Ke, steffen.klassert, herbert, davem, edumazet, kuba, pabeni,
netdev, linux-kernel
Florian Westphal <fw@strlen.de> wrote:
> Ma Ke <make_ruc2021@163.com> wrote:
> > In ipcomp_compress, to avoid an unexpected result returned by
> > pskb_trim, we should check the return value of pskb_trim().
> >
> > Signed-off-by: Ma Ke <make_ruc2021@163.com>
> > ---
> > net/xfrm/xfrm_ipcomp.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
> > index 9c0fa0e1786a..5f2e6edadf48 100644
> > --- a/net/xfrm/xfrm_ipcomp.c
> > +++ b/net/xfrm/xfrm_ipcomp.c
> > @@ -144,7 +144,9 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
> > memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
> > local_bh_enable();
> >
> > - pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
> > + err = pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
> > + if (unlikely(err))
> > + goto out;
>
> This can't be right, this now calls local_bh_enable() twice.
Furthermore, looking at this:
1. skb went through skb_linearize_cow() before, so no paged data anymore
2. Right before there is a check to bail in case compression inflated
packet size.
IOW, this pskb_trim cannot fail, it boils down to __skb_trim().
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-06 11:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 11:41 [PATCH] net: xfrm: fix return value check in ipcomp_compress Ma Ke
2023-10-06 11:47 ` Florian Westphal
2023-10-06 11:59 ` Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).