From patchwork Mon Oct 24 11:31:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp432983wru; Mon, 24 Oct 2022 05:48:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74SwruyslTUakG/DNq92/4+LoAul8Pj152bek6WEuZMQS7VLeGJtMzjzD4DBJ1AJ83IFc6 X-Received: by 2002:a17:90a:354:b0:20a:6867:4a2b with SMTP id 20-20020a17090a035400b0020a68674a2bmr74049819pjf.157.1666615695454; Mon, 24 Oct 2022 05:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615695; cv=none; d=google.com; s=arc-20160816; b=yJ82Z6zvzuhd4yLgjI0mEMAnbD3raRCkX/8H/LQfcoYPod7L/s63DxsuMUQ1cSbKgz kp5Q3hjacJhhTODj3Dyup7Oo80FcdpUMyMNePGB9b5TtByRAaLFlsAHUAEIhAAd8VlKp KzDL0oIDkuGAFz28DHR7ZpJ+0Ap43UPjjTqRZbM5TKTJGT4CWh0Ndt1BxgvvNI/AViTu fybph4eSjLPIZUxqHA1gkQyxpJgFsQksjqpJeyCvR4zcR30mgD/+vBlNPVavrkJ6kyOA aX3grE+28pt6fWUwBnRF067avF72Hox4y/IHpLSXYbykwn211V76txJ9J8GyoL8DDwax imFQ== 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=Tm717FB0OfzvRFjmRnD6aZ2+61xnbGzoQzQDqRQxaYQ=; b=aZK58FHSwFJ0GhblBrA4xsUkI4xXtBY5jnKxeSbH7vbcdVOqwqfKDU/2u9Fh+wQWD/ 0ET+vGnZW8giI97OrzcnArkh+bsaCZmsg31j3JeGZgdsMRA5L0dKZiI+p2v0+k2tPEFm 5GYczHpooMzppc8BFSbcmAam3mTbnuCCGp2qPT2zdvqhuFbXX3NJhpSYcLOYOyYxIC8v i3WQ5fSRePTBFygz0vRvWts/LD4257BYMQWpU6HKoMsXSRz2Uko8NQreJYzQN9KTSR09 nKLFRBWoyg5Cw6qy3KlGhmFP+DPk0iczBysg7rdx1QpqEGUjU+0ADH11Mdgfq6yRelb0 PbTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jrqRm/k1"; 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 bc22-20020a656d96000000b0046ed85dc141si7732418pgb.472.2022.10.24.05.48.01; Mon, 24 Oct 2022 05:48:15 -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="jrqRm/k1"; 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 S234022AbiJXMi2 (ORCPT + 99 others); Mon, 24 Oct 2022 08:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234489AbiJXMfK (ORCPT ); Mon, 24 Oct 2022 08:35:10 -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 E2DD25FF40; Mon, 24 Oct 2022 05:05:29 -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 687F5612DB; Mon, 24 Oct 2022 12:02:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BA1EC433C1; Mon, 24 Oct 2022 12:02:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612953; bh=/XB4y2LpgVtKSLfj2FRGEXMsobFlbWAbbPzG5tqVxqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jrqRm/k1b/V6HcATXfa9l86fIiZ6IF0qWDEEhRh7Aoz5Ree4YSeYoj/qAH3GxycIB x3r2AyBE3Wur04PIUccxhaIURwkSnRKKRvs/LAnWAH9CiYxvqvMcKokHeKE60+0qt6 3vX1IMAsVfMuNFFVSrE4pogp2RTRtiyIH7e9BAzQ= 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 4.19 181/229] xfrm: Update ipcomp_scratches with NULL when freed Date: Mon, 24 Oct 2022 13:31:40 +0200 Message-Id: <20221024113004.944366721@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747573219820352051?= X-GMAIL-MSGID: =?utf-8?q?1747573219820352051?= 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 a00ec715aa46..32aed1d0f6ee 100644 --- a/net/xfrm/xfrm_ipcomp.c +++ b/net/xfrm/xfrm_ipcomp.c @@ -216,6 +216,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)