Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3987508rwb; Sun, 9 Oct 2022 15:22:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UJhgj7LsNTuphKulZ0PiQGAFZf415Zf6ZiwnRfab1Sq/N+9/FhPFARrQtNF/tVhxxYi+u X-Received: by 2002:a05:6402:414d:b0:451:73f0:e113 with SMTP id x13-20020a056402414d00b0045173f0e113mr15007357eda.207.1665354130495; Sun, 09 Oct 2022 15:22:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665354130; cv=none; d=google.com; s=arc-20160816; b=J8suyed5BM78+RQCnYoiZ+l/cImB2C+UMUQo24YAjLnBfBxif9y9/qMQ0mVPde2Xkf orNrXWB1ujODTBLnazBIccQzWbMKH7wk4SKw4c/uCG+FATqVgw3askms0vclRkxqk0UL 7DIB4mmuFwbqeTIi90X7+T89wgc32DXsKUxqirhb9ta7JCURWfNH5XI2cfzZLmutzSTO eHgcPhKlgy7x/t0wYCoxtKYDfac7MHcUZZRH853W6THFqQRu3YHdVtPizWTXl5vz3HWS bMx1sskHAv2J/Np71UCKnj0ru7+XCoLTdo5/RqPTcUFCfnHNo6TeFL4PeO92/aNB6gmv JOXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9R3SVjxd/uFQX/hq2iVgj/y4Cke6BXejPQ59Zwficek=; b=sZb6jGWLTKjAuxZGaQIGFxmKUP0YY3sqGfvHe1vExGvLcRSbKnsDWJ2mGKAjxnr72r zFAVkLptxbm8slkv2bZ/t3111mwKa3/An24hoDqU+19sEooUf0GvXXIPHEuxvADOdQz9 RvthYULZdtcSjERW46NYva7VFsgqL22gDXnpqzuooyNlac1x86py6oruD4EF1Jxll0Q7 MKzoqOpoM/U3YnDTekCFL27OqvIj55J+ER9vaVqsxZQ+PWgCV0zf9AGiRoNVOFqJOG+B FjEeJJJWq80syrXsqnILfH14LPVDjJwmRCLzzLaCSr1+Zs+D1Op0f79YIZQ/mu7L8gy3 LrzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6nNCjEy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ek22-20020a056402371600b0045bca61f75csi4993458edb.250.2022.10.09.15.21.45; Sun, 09 Oct 2022 15:22:10 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6nNCjEy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbiJIWLy (ORCPT + 99 others); Sun, 9 Oct 2022 18:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbiJIWLU (ORCPT ); Sun, 9 Oct 2022 18:11:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0877C2EF23; Sun, 9 Oct 2022 15:09:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0DEA1B80DD8; Sun, 9 Oct 2022 22:09:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81A36C433C1; Sun, 9 Oct 2022 22:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665353359; bh=0yRnkpEfxS7tWFboF4T+L+HG5P/SvlF22wbvGiSDb4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g6nNCjEy+yZLy6udfEp0mKkxxrztz5++1COnL6j+9t5CY/373S9slM1FxC+5DCHDt m1TKKq0MDt6Vf41bhnYWUOnEAs2Hwqad1aJgl2c7JWfeNghGeeoiIoddLhyTDEgCrt 28QASfwtNc+CqeRiNpL5aHEUlWJRoj3CTkp/JYdyvxHnPFOOXVk8io+y//jPgrgVp8 i+7d5T0SmoCa+9jOnexqAliFp5n4OrlQV/NpNO+SasaFAepq2kq1ijbZFIS6MZWIt8 h4WMX065xNyw4a0IGAaFqTbuYzM1azzNjmQEypc/my75a3zDSTQjltN0ecaU9S1MCI WMXKtk7IBqvDA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Khalid Masum , Herbert Xu , syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com, Steffen Klassert , Sasha Levin , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 25/77] xfrm: Update ipcomp_scratches with NULL when freed Date: Sun, 9 Oct 2022 18:07:02 -0400 Message-Id: <20221009220754.1214186-25-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009220754.1214186-1-sashal@kernel.org> References: <20221009220754.1214186-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Khalid Masum [ Upstream commit 8a04d2fc700f717104bfb95b0f6694e448a4537f ] 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 Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_ipcomp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c index cb40ff0ff28d..92ad336a83ab 100644 --- a/net/xfrm/xfrm_ipcomp.c +++ b/net/xfrm/xfrm_ipcomp.c @@ -203,6 +203,7 @@ static void ipcomp_free_scratches(void) vfree(*per_cpu_ptr(scratches, i)); free_percpu(scratches); + ipcomp_scratches = NULL; } static void * __percpu *ipcomp_alloc_scratches(void) -- 2.35.1