From patchwork Mon Oct 24 11:32:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp480434wru; Mon, 24 Oct 2022 07:20:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Kh+rGDgk60YaAv2ylyMw8OZ1xjbLZeO/G5rk4lcksZN2MbsLbK3F8NZl9mwWd9wqrsbCg X-Received: by 2002:a17:907:2c4a:b0:78d:ee99:a06b with SMTP id hf10-20020a1709072c4a00b0078dee99a06bmr26831570ejc.578.1666621258378; Mon, 24 Oct 2022 07:20:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621258; cv=none; d=google.com; s=arc-20160816; b=onCGoeW2x0dHCLaJnT3bwQD0g3615HyuG5nDFh2cGvqOqGH7ymSK3JoYaQioDWx83p Q0IQac/aYGb/bgsC6EhfjCJoLorW58Ge1moaTxyKPMtL9yKiwR9zGnDa+/WQp/b+Eikz caZG3apUG7h4T1J+CRxfWlB3jRr9Xps0gVOextiMek2zPmNSEfv0mZ2BmPwXur7lBQnG FsmDVr5rKOW776tg3AoASe1GpSA9C4fTlGD1PBUPS8asUi96vCdVdGhG4LVOvBpiRRKy UnrX+LiD3d3pDV10a/2svkl7qwJsQC6+bJ4ImjN0VffpdPprxnm2lnFAUj2nLxgjvX6P jUaw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9R3SVjxd/uFQX/hq2iVgj/y4Cke6BXejPQ59Zwficek=; b=bPQI5Ztj15sRjLzgwSFe9hFMvYsxBZRisvUz3F3xUQteQNvPaRokID93niUFak0YLc qlHAAFoFP8lXuymvH/xbrciUIVzeh0rxLUo4aIUaw2vjSLUbE1pkd8HCadZfyROc47gf nQQi/UxpC5gU9UefNCgNGfN2oMWSi+5e/AuAnoG2ylF1EOIwrHxxSDL2SkIpJMQAaabB QWsd64pQt3buLHudeiqtqjaQLhEtspuza3RBOyt4fyLp+pqOd9CIv1iNXuuGPmX4j/y4 xjkXdJWV7vrhrJgFMiZB5f8/ExSeb19yUImwgVtZXOyDZCPjd4Sp9AcYFR62pqtYDnUk QXtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zoYJk6Rj; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc11-20020a1709078a0b00b0078de51e1c3dsi28186945ejc.840.2022.10.24.07.20.32; Mon, 24 Oct 2022 07:20:58 -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=@linuxfoundation.org header.s=korg header.b=zoYJk6Rj; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235661AbiJXOTK (ORCPT + 99 others); Mon, 24 Oct 2022 10:19:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234697AbiJXOOI (ORCPT ); Mon, 24 Oct 2022 10:14:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03023CABE0; Mon, 24 Oct 2022 05:53:58 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B40846125D; Mon, 24 Oct 2022 12:51:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F66BC433D7; Mon, 24 Oct 2022 12:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615902; bh=0yRnkpEfxS7tWFboF4T+L+HG5P/SvlF22wbvGiSDb4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zoYJk6RjuhOCX7rdvI3uYQazUV+fha0KYFFKQqJ+jx00jbiNzxqDcvVK3G8crk9Wi +ftRfY2APDIEzsC/xCA7VQpGcBKLeF8vjWQXTCx6C5Rse6Uqiz+iv1eUdaATB7UA4O GLnIXtmKJUhExlJdxDqIkWdOd8izdClPeQl44Oig= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com, Khalid Masum , Steffen Klassert , Sasha Levin Subject: [PATCH 5.15 425/530] xfrm: Update ipcomp_scratches with NULL when freed Date: Mon, 24 Oct 2022 13:32:49 +0200 Message-Id: <20221024113104.345480133@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747579052584875996?= X-GMAIL-MSGID: =?utf-8?q?1747579052584875996?= 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)