All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Florian Westphal <fw@strlen.de>
Cc: Ma Ke <make_ruc2021@163.com>,
	steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: xfrm: fix return value check in ipcomp_compress
Date: Fri, 6 Oct 2023 13:59:12 +0200	[thread overview]
Message-ID: <20231006115912.GB29258@breakpoint.cc> (raw)
In-Reply-To: <20231006114751.GA29258@breakpoint.cc>

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().

      reply	other threads:[~2023-10-06 11:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231006115912.GB29258@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=make_ruc2021@163.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.