From patchwork Mon Oct 24 11:31:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp436911wru; Mon, 24 Oct 2022 05:58:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4E1x1kX541cIwCeDanuFlSY3+do4Qrm44gLnAj2+Y82ds9AunX2d20Xx26eSCm41FkvtEz X-Received: by 2002:a63:ed58:0:b0:439:b3a:4f01 with SMTP id m24-20020a63ed58000000b004390b3a4f01mr28172404pgk.327.1666616305845; Mon, 24 Oct 2022 05:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616305; cv=none; d=google.com; s=arc-20160816; b=0UUBwcGLDzx6E0Isn5K7QSFaO4A5a7PY2IIz3/laSFzWgENFkDXXYWtn4eILPY+Bhc 0A8gSuJid508YDZrXtBollaG1bEY0/U/+Bgf8Ifq3TYACRT7Z8d+ZwR/Xpr2FKM23ukW n/yk5QO0n6pFz//EeymWKJk3bAg6QKWRZkz/pG5ZLyrPHf/lTMYbzUxPsJzeGtmmEU2b tFZORjZtOg0lFgjBULabHwqvEVoQo8R+6vKW7itjPPxxfO59yOfWl52tWiJKuCxEOHsh TwGVS5BXW7FXCOlMkRuvKWG/vom4y6QvfAV6UDA9Tzb0iJ9dSox91ak5tE2jZbyKTlxD Cpbw== 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=4BgnxY8Xq7pAa2cP7T34R31PX0cLoamtQqcxDEYuJgk=; b=V2/m8xHbHNTtaZJP59sqtXONzYeCucod11ENPznTE1VEjWeJm4YRVL5JWgk+BNP/EP 1ZMZmRrzKDRkDfvKtPlIRO6Xg+XyeUD51wqvwc0MPdAqNtddlSpAF8HwZWHN4DPpjOw/ XJkyzlJzA6MkhnPSEJ/oCi5YH0vDQVHHmr6foSs03Xtna5JraGeP14xZedoS01hZGlWo qE/x5OKqnIrU2iYTFPOlQ14AgKeBkQOmjEMuIeaom2y9i7FpxPGezNuLH5VHSbgVgC+R 12Y9pLR7pnEk4lAtq1T63xn6szlHmCquLxjszSiXtCoBd9FObG/siGae+kAMjA+Yb1Yb vgSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i9vJlWz7; 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 t22-20020a634616000000b00434ba40afd5si36534472pga.873.2022.10.24.05.58.12; Mon, 24 Oct 2022 05:58:25 -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=i9vJlWz7; 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 S234803AbiJXM5e (ORCPT + 99 others); Mon, 24 Oct 2022 08:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232122AbiJXM5M (ORCPT ); Mon, 24 Oct 2022 08:57:12 -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 94A4C95E63; Mon, 24 Oct 2022 05:16:41 -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 3F8EB612BB; Mon, 24 Oct 2022 12:13:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51A6EC433D6; Mon, 24 Oct 2022 12:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613594; bh=3ZJ2Dr8BARql+3f/+Ul44E6zF7y3fz2ppwdvpIevRAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i9vJlWz7oCU70JM6ftD8ti0BD3X1xNmgYImDcrCt+oZ8XrHZDWmVVPX8Dwswp+NDH 94Cnxg2bieWoCAaOIBU3mSNtIgrcuFH56su5AHcrkFKDSPOo6Tip2g225pSLCNYbKG xF1iyUJJu30MDQQAEgteRIt9MdW1o+pU4gEqFpVw= 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.4 197/255] xfrm: Update ipcomp_scratches with NULL when freed Date: Mon, 24 Oct 2022 13:31:47 +0200 Message-Id: <20221024113009.545061040@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573859736401770?= X-GMAIL-MSGID: =?utf-8?q?1747573859736401770?= 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 4d422447aadc..4fca4b6cec8b 100644 --- a/net/xfrm/xfrm_ipcomp.c +++ b/net/xfrm/xfrm_ipcomp.c @@ -212,6 +212,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)