Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp443738rwe; Thu, 1 Sep 2022 02:05:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wqtMDhmGmhlm/Q4VPaoj1Z/STP2/MM+kzVFY23+bp12BCiXKOCPXpqqkZKC1KtU+rr46z X-Received: by 2002:a17:903:110e:b0:171:5a95:a91d with SMTP id n14-20020a170903110e00b001715a95a91dmr29652603plh.3.1662023147463; Thu, 01 Sep 2022 02:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662023147; cv=none; d=google.com; s=arc-20160816; b=d4XX4rOaUoGfoqmddfvGipM7s74cKipvIPn6k5fCjhcQqQ26T3Jst3tfLA/l71eCCn urNnC+q9rjODdRXEa/vqbg1E9DuGhYSlPGXexjDqawRszDBZQL9o1iBLSEY1CUvgaENh DPloXgKWMFEV1E8mAoElCMnrzx4BJ74boh9CPzDhc6D0odxlDEWu9KxJaqFb8TUa1UtO CcNIToeG5HYS3oyR7if0VzEo4nUlncG3Wp2pTAnxGP9P9+9qF1Kh5tt+WcrtkobalFK6 /Nbyvg3QEb+HKnjVnYF43BuuwixthY6/z2P2Kd8l4NFhEvl54jzEl84VOZ5avdxgbiAw N/mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=VBT/wgQueaBiOMsOEcRtYMOJ39N4ykYOyhRn/0fiSuw=; b=Rvhigp1K7NOo7YmGH4ekAd9oy3LX9kAkryr5GayS7p5ItSa3P1wHdzQOwVGbNEahOb 0sFQ5+919vOUM0RJQUOWA8GqKUgm6UOXMOOmfozLjhwPbnp9x1POi6XYWuUnHf2ir1IH xOSWQy6lloagq8BsxRpcY5MPOo9/ctI4/DNfVzzMYEf7IgUm7QkYvmnIosglBK7YUS3T Nj+Op/BAAcgSfZTRJwxr2/osaW/nVrKY4Y70B4JcmdssJSs+hIAgrtzxocj4Dmgfgcau hWeIy88uV7rcqje5UYTtncOlXSQX4EdVM59h/qJexyoCELEb/cNJW6Nv9zZMe6hepb0X 0knw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a170902aa8900b00174f7aa9218si8010481plr.334.2022.09.01.02.05.34; Thu, 01 Sep 2022 02:05:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233624AbiIAHuT (ORCPT + 99 others); Thu, 1 Sep 2022 03:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234328AbiIAHtP (ORCPT ); Thu, 1 Sep 2022 03:49:15 -0400 Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 821651257E7; Thu, 1 Sep 2022 00:48:40 -0700 (PDT) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1oTewD-00HUk4-KZ; Thu, 01 Sep 2022 17:48:34 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 01 Sep 2022 15:48:33 +0800 Date: Thu, 1 Sep 2022 15:48:33 +0800 From: Herbert Xu To: Khalid Masum Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Steffen Klassert , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan , syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com Subject: Re: [PATCH v4] xfrm: Update ipcomp_scratches with NULL when freed Message-ID: References: <00000000000092839d0581fd74ad@google.com> <20220901071210.8402-1-khalid.masum.92@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220901071210.8402-1-khalid.masum.92@gmail.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 01, 2022 at 01:12:10PM +0600, Khalid Masum wrote: > Currently if ipcomp_alloc_scratches() fails to allocate memory > ipcomp_scratches holds obsolete address. So when we try to free the > percpu scratches using ipcomp_free_scratches() it tries to vfree non > existent vm area. Described below: > > static void * __percpu *ipcomp_alloc_scratches(void) > { > ... > scratches = alloc_percpu(void *); > if (!scratches) > return NULL; > ipcomp_scratches does not know about this allocation failure. > Therefore holding the old obsolete address. > ... > } > > So when we free, > > static void ipcomp_free_scratches(void) > { > ... > scratches = ipcomp_scratches; > Assigning obsolete address from ipcomp_scratches > > if (!scratches) > return; > > for_each_possible_cpu(i) > vfree(*per_cpu_ptr(scratches, i)); > Trying to free non existent page, causing warning: trying to vfree > existent vm area. > ... > } > > Fix this breakage by updating ipcomp_scrtches with NULL when scratches > is freed > > Suggested-by: Herbert Xu > Reported-by: syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com > Tested-by: syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com > Signed-off-by: Khalid Masum Acked-by: Herbert Xu Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt