From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40CDAE81DE9 for ; Fri, 6 Oct 2023 11:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232110AbjJFLsJ (ORCPT ); Fri, 6 Oct 2023 07:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbjJFLsH (ORCPT ); Fri, 6 Oct 2023 07:48:07 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7ADCCA; Fri, 6 Oct 2023 04:48:05 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qojJ9-0008Nn-Kd; Fri, 06 Oct 2023 13:47:51 +0200 Date: Fri, 6 Oct 2023 13:47:51 +0200 From: Florian Westphal To: Ma Ke Cc: 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 Message-ID: <20231006114751.GA29258@breakpoint.cc> References: <20231006114106.3982925-1-make_ruc2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231006114106.3982925-1-make_ruc2021@163.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ma Ke 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 > --- > 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.