Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3986226rwi; Sat, 22 Oct 2022 03:23:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42Xe9dSA7BqY0Ua86tqK5k3OpANl4ZCdLMAsaPC79hHrtcd01s0KAohKOgZl6C/vGewYd7 X-Received: by 2002:a05:6402:c4d:b0:457:99ec:1837 with SMTP id cs13-20020a0564020c4d00b0045799ec1837mr21324910edb.86.1666434209641; Sat, 22 Oct 2022 03:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666434209; cv=none; d=google.com; s=arc-20160816; b=AVUbA/Z0q6FwsrEn+NMacL6RkkQZRU+I7VIGT9hdhLjR9UFFy+Nu5GX21cyZq+DeFg moztk0HNMNH7+aPuNEGF/QSQL2xEbJ7i5gB6f1QgOKrFkRGzBPgpFQVhum4A8483snJJ 4gkQionHlIqVmJIJ7fZLXi3KH6e4e9iDMVSwRYN3yRL1fXozh4uzJY8MUyuFMs68quz2 NlD8o/W8sPhW3GSbg7CFMTZWg+PqMxkK3QJQ6xWymggsYS+Va52UYk44xIE2pIr9yNgM xI3leDP24TXKlw7hNiipWLwms8tvdrQ3tPt5/YxeuRa5a3mXVI9BBjobOGvrtSlbawZ7 7UyA== 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=oNDMm6R0v1CWtxWak5RCLEVU+xPiglAz/G+wtNTku05L1k3ubzD54gbajSOZCSvnZg QA265uI5a8yweVPSd+Vpt10LQ87GqIg3AGGWrKYUpN30EIESH8+EED+RScSGbIBFMTss R/EuRFhXbNlHZWwBCN54qXUSQAXUh6AqXOA2TDKuLtPjx3Cy22sQZdXuSFr0t7R5Myz2 mEmm6a6iULBqluuI4XNyoxnZUzJ9k3z+U1d3wrwDmBe1tcLW0RKXeY67qJML54R0cdH9 RBkeoYS4lnyAFacCqsrgobjbbE7hBFEW9yIfeKNXF5taiWiY7GGWagZue8cyOkB5mi07 EntQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wcnlpNU8; 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 r9-20020a1709063d6900b007a0d3365aa9si1076525ejf.136.2022.10.22.03.23.04; Sat, 22 Oct 2022 03:23:29 -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=wcnlpNU8; 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 S230398AbiJVJuY (ORCPT + 99 others); Sat, 22 Oct 2022 05:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbiJVJtt (ORCPT ); Sat, 22 Oct 2022 05:49:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A66E2D2C36; Sat, 22 Oct 2022 02:01:00 -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 476DF60B4A; Sat, 22 Oct 2022 08:00:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DC85C433D6; Sat, 22 Oct 2022 08:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425647; bh=0yRnkpEfxS7tWFboF4T+L+HG5P/SvlF22wbvGiSDb4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wcnlpNU8U19wh9HbF0/BBh1U+R2MByKH8bgYibwr0cvNBBJzA7IPKtDseDqbDH7VZ GdQB412pm85LoiLjiE4N11bj+3Gf5vZXvs87mQ3bDH+bAeTqLxH6fdDnjR6e/lkoNc AStWtcJ+7zQ6FRXa+qUdXpMGE8cMLogKINnbtm+k= 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.19 570/717] xfrm: Update ipcomp_scratches with NULL when freed Date: Sat, 22 Oct 2022 09:27:29 +0200 Message-Id: <20221022072523.614085687@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@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