From patchwork Mon Oct 24 11:31:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp458340wru; Mon, 24 Oct 2022 06:37:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7afxhg2dzFDOarf87VH3oLUFanf+R1C66B1evTtwgQvgr6Z07yevgfckKuD81tQEe+KE9H X-Received: by 2002:a17:907:2e0b:b0:7a5:fc2e:dc7 with SMTP id ig11-20020a1709072e0b00b007a5fc2e0dc7mr6004051ejc.257.1666618644102; Mon, 24 Oct 2022 06:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618644; cv=none; d=google.com; s=arc-20160816; b=KQ+Ygw5VbWxrPI+Usxiyf+5CBCuX0FkHXXv26lHQen5Ln1N6GJphNSTMeu/u3OumeO EKbSpAOCJz3irPCQb/EeXTeT+vHmJRHz4mpCitCxpm9txT1U0JymQuXMsBdYnD11bx6O aYyceG3KIfOICoVM2vd5WQ0hEDUPAHrZPAyNpv5KT7ESiP+bpWZrJ+2aKafdI5803wPJ bATQaPKMAxmabVOzcg7QdcGR+ZvsATffAc+wYmspQTKpnMcsKeuqfFSbd1ENVqQ6ml2D 7NMm6tMtRMoRApM2DMkjWCTk9AEJQrfHjfFvVUW4Xd82jWStZWoiX4EC8ALCjd4qk9yU Qhyw== 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=BuhjIss6Rgrewa1XtK15PpkMW6kPfqoVkQrQO9Wwag0=; b=LmaPEpW4cOhNz/EHk09lsf2w/68KCYDC2NO0vP3X7iY4d3Zt5jw2Uuuftsk4LpLY5n FrwcY8aJ+WwyZ53BzAcdGjym0g3EOFQr4gL4CxcWcnaiuTcGpAzrswBTrJqRMgDOoOV/ REOYu86w3r5PY/wf/4NbCX4Guv5OjN8NRSRyhsdT+2Rf1tYf5UuSUOK9wAuq+fTZysgH ip6vn5EhGrmpGU8T3J3TtGRf1FvlIIWzWI/jP+oVjY6ns2I/s6X03uOh69kdiFumkqTz WXtbDmr0zX/4XMBU5DrpjAQrxOE/UcTPAE22ZH5u0yUksdLsxw6seF2+tZ9o6YLq72Kd e3PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hzI1oSKM; 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 gv28-20020a1709072bdc00b0079800b81731si11666688ejc.82.2022.10.24.06.36.44; Mon, 24 Oct 2022 06:37:24 -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=hzI1oSKM; 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 S230128AbiJXN1A (ORCPT + 99 others); Mon, 24 Oct 2022 09:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236127AbiJXNY3 (ORCPT ); Mon, 24 Oct 2022 09:24:29 -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 BA67918383; Mon, 24 Oct 2022 05:30:42 -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 26F9E612FF; Mon, 24 Oct 2022 12:29:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39700C433D6; Mon, 24 Oct 2022 12:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614570; bh=Jad87ZPGbOMCQZjFg6peU5RSSRiKnGTlnlSYbcbi8sA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzI1oSKMH4D6t8Ir7PW6yB4NxGgIDPrz4eNrwDgEhNOsRq6JXQcNet8c+FG34iyEk kRJ4RoP2V7fyFP6rIJXngxA1RljWgpoRibWtClUqUYTxIUXXj1V0hrGVjcmw+2pRw0 cHU6iv+5f/U8Mh1qwjbOxPjhcqniyWVtMHpujPmA= 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.10 311/390] xfrm: Update ipcomp_scratches with NULL when freed Date: Mon, 24 Oct 2022 13:31:48 +0200 Message-Id: <20221024113036.218746726@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747576311401710093?= X-GMAIL-MSGID: =?utf-8?q?1747576311401710093?= 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 0814320472f1..24ac6805275e 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)