From patchwork Sat Oct 22 07:27:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1133705wrr; Sat, 22 Oct 2022 03:05:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6z2fyPEx7meI6Yf5hsjH8evv3ZAHR0Lvi4VMSv7XwrYM8rvqsuLuTHL3LtNMHpuZo/1c2Z X-Received: by 2002:a17:906:d54d:b0:78e:2fbf:ca2a with SMTP id cr13-20020a170906d54d00b0078e2fbfca2amr19793392ejc.488.1666433114282; Sat, 22 Oct 2022 03:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666433114; cv=none; d=google.com; s=arc-20160816; b=JSzQFAqYcfAZD0hlJk0NuZ3nNVYJQ4KXBGppZY76oAiy9qM+oDtwn4MjGIfjzPN966 FZkVKuHFvo4LrSEr4Dxpaynco//0KuL5iul2uwx1f/Hr9Qnk74MG5Ja3tzhzjubVuin5 71Jo1qQZaU+pRQ2hhtn2Sgc5TZk6G3ReI30SODIMOyO0nnidqtegshIs9Tqlv1xAxRej 0vQVB4xn3rqQ5Zsh3T7ce5LbpP4zv9sXUH40HT9e29ufrGKO0CsWR3otLuBN+ZD6sCjC zZ4eB8CYOc9iVBm/Oa6PUpJx+t9osqdmwK1X6A2gWJmRENAK0CjySx9MX4GFFaBjjVA7 9UHw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn10-20020a17090794ca00b00791a84056d9si9925333ejc.751.2022.10.22.03.04.49; Sat, 22 Oct 2022 03:05:14 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747381769221263766?= X-GMAIL-MSGID: =?utf-8?q?1747381769221263766?= 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)