Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp904006rwi; Wed, 19 Oct 2022 04:33:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4XVjLM8xC5O2BpERUmR+AlLpgmoYG0pp8Ak2tdclUzeHP+/PhoBCv1iYUxs7z5bvvoJRK7 X-Received: by 2002:a05:6a00:2350:b0:541:b5bf:2774 with SMTP id j16-20020a056a00235000b00541b5bf2774mr7799557pfj.28.1666179208146; Wed, 19 Oct 2022 04:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179208; cv=none; d=google.com; s=arc-20160816; b=NQigzx4OzWXLHu8dNr6YJ4dQD18DrIRhM3xavIYUHL1XI6uuf2jKhnAUH3pj5PitfT Ic9Jvn59SC9oj4gC5pJ3SW5u46auElYTmAw51VZ4VQDo5ScHUxkds6Sl2tRKCmfyxwqb U4qpRSW+PW78+DKlhZN4P8W6ScK48ZeeKLWCRKJdC7ZrxkuvT20atmuhdKDtv536RvJb OggcA44xEECINETn3FX5Lksgi1iD7VHtPGY95Vd4p1znHI/UbXQSshf+N8Sxj+ID0u0b SGqwp1mmuOFGF/QmdvX5YIXELCb+ZIpg2nMxNbB36Ka0i5sQLs4f0wkFBW21DW8csD/A Or+Q== 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=JpFcgvdo7ssdKcBhLIhV1MTi+58+iz+I50AwbFEhhXJeBs5Xt4FI6dcN3HeWK2M2xh rb0uJZGphka4zGqpQUHkmX0b7s5X/Uj7HRalP336RVZu0hxX3KD8yOckRX69CIunvwYP MNjzxKkxwaY4cxkQiIr2fcot2kRyq5oEIJOE/YMswl2VWdc4vHVtKOaFyt00xbSlcwXX HaGfDCZW/bE8c6EW0GWdh+bYdz/u2WOt2FLEK3Wmn/9Gj6x+cDjXN0h+16yFvxT2vlnf CWqWHD540G7SUusJVka5T3tSVIqRPETAZMiWaUEhCggkg22XfzwJUsaaY4hk4P1OtQpK eldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P33CsgQr; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ng18-20020a17090b1a9200b00205fb99a5fesi20506926pjb.136.2022.10.19.04.33.15; Wed, 19 Oct 2022 04:33:28 -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=P33CsgQr; 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 S234718AbiJSK5V (ORCPT + 99 others); Wed, 19 Oct 2022 06:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234710AbiJSK43 (ORCPT ); Wed, 19 Oct 2022 06:56:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBCBD4BD03; Wed, 19 Oct 2022 03:27:38 -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 16819B824A4; Wed, 19 Oct 2022 09:09:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D5FC433D6; Wed, 19 Oct 2022 09:09:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170547; bh=0yRnkpEfxS7tWFboF4T+L+HG5P/SvlF22wbvGiSDb4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P33CsgQrc1pEfq2TT84O8Yet7B/OrLa3r2QhN/O1xB9cEPA596Ajw4n8x2A1OFUhF oH6rxeB1fk09M4mdO8vi8AUnJxf2MAeThamxsOUi/5JtcWqu0w7BLrWNwzSes1MZXk pVoSnROtb8yXKomKaWbu4r4xdP5r4I5OSb2EVaCs= 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 6.0 696/862] xfrm: Update ipcomp_scratches with NULL when freed Date: Wed, 19 Oct 2022 10:33:03 +0200 Message-Id: <20221019083320.733613690@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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