From patchwork Mon Oct 24 11:31: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: 8650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp421567wru; Mon, 24 Oct 2022 05:20:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4sBQuy6nasQdI5+Fgh0+YV6o5jEFEJeabjNgFtjAowA3uvj/MX45AFSYIXBlBtnWJ9UjgT X-Received: by 2002:a17:907:724d:b0:78d:acf4:4c57 with SMTP id ds13-20020a170907724d00b0078dacf44c57mr27355057ejc.516.1666614049025; Mon, 24 Oct 2022 05:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614049; cv=none; d=google.com; s=arc-20160816; b=eDmu9x7oi9Cy34B6+hmCuQq33R4T7Gkb9bGPwcGrrE8vS2ODp4IQh0wu4o1jKQo8W2 4ZO3sLiq6jXQQpTQ06CbT7XEUUBamsoglSnTueUXnAi+b1/1/1kF18iMSZsQcjR1wV9r OGUVl5m90MLVNWVrRR3MZxAA3VX5duyPZk/fYtLSV6/9v72OicIfpnOWFKZA8PBoBzbf 8BRpTJ5qDzrdch6lX4l42g/9jh7Ki+YFGSfuu1AgZkSF7hNHd8od0O9Bv9ZXk2cDtDa8 4dCA/vI8xaobT7aWwwnB/4WBVYuDAuWDqjZIgpDbI80dYlijSH/yHLRhMnZUkPmA8zJ3 tTjA== 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=mLtHKFvjxaRTiW18qaKVvv9Ru+QbA/8i3VVJDjE5oq8VrzOzksnKAEo09qW9OqaO6D adRLKtUMOHe+n3l7xp+CmJVLLQPNLRb7ka1PhMs8s1AkkseE8dsgU57nZ8o3fZNPPCjA Dx66MIZCsq+TP9eBE/tJ8oaupUVF1D/qVZwy7p0NK6iTtDnMXW246B4BoX8Reo1RXKCp 0K2SFC8OsPku+AyZ+mPfAjW8r+6/gRx0jPoydEjk7ganJO7tlLfhy5mJ+9IqI7I9FWLQ a0CR+BFtRiNU17CkrJAIoLfwO20y/byVv38/QIbFUfvxWAc4/xcBOKTdmP8CBOa2g4cs 1x6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RZKjxdQ9; 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 k4-20020a50cb84000000b00453688643fasi24704379edi.260.2022.10.24.05.20.24; Mon, 24 Oct 2022 05:20:49 -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=RZKjxdQ9; 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 S230414AbiJXMN4 (ORCPT + 99 others); Mon, 24 Oct 2022 08:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232710AbiJXMNT (ORCPT ); Mon, 24 Oct 2022 08:13:19 -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 694E81C410; Mon, 24 Oct 2022 04:54:47 -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 5F504612B3; Mon, 24 Oct 2022 11:54:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71AF3C433D6; Mon, 24 Oct 2022 11:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612446; bh=/XB4y2LpgVtKSLfj2FRGEXMsobFlbWAbbPzG5tqVxqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RZKjxdQ9BC+/khYxsp+tmmdscO06X1tZI1GGCQbHgmFAw8/sJKeFz7MkYjYNRp52I 6/2GfwhCzitFK5hob0Y7sMLU0OA72VFWNuNcvHvRDOf9TBWLfA9+xSuYNUDksAXNpb srECbKOQrTkcwraxn9gTWDVyLol904IbQ1ib2GLA= 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.14 172/210] xfrm: Update ipcomp_scratches with NULL when freed Date: Mon, 24 Oct 2022 13:31:29 +0200 Message-Id: <20221024113002.538535839@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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?1747571493272801038?= X-GMAIL-MSGID: =?utf-8?q?1747571493272801038?= 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)