Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp817869rwb; Thu, 15 Dec 2022 02:54:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf791WwYmegz+xqfVO2scq/nf63iXBNH57rrIgbECEogIUuNGlY5d1ASEH9y8Gezk6IPZkiE X-Received: by 2002:a17:906:fb02:b0:78d:f454:386d with SMTP id lz2-20020a170906fb0200b0078df454386dmr24139369ejb.42.1671101692036; Thu, 15 Dec 2022 02:54:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671101692; cv=none; d=google.com; s=arc-20160816; b=tmC/aAOdoIDgFSl3dSKdcS7duqdAb2mSlh04QrCq1vnHIyciY2igFmoAT+kzSUqqXW yuy3kc2G7Emlh8gKzenTVBAy8ZlPbBZbec6pzHLV6050yUPJ5QUIM/HnkRPYcRp/QfVL WlV3qk6frqYmUUaHr8/okXVzGr6/WNoTmalaaHpQXk9HhOKZqqXA1cIUGTOWOJj2DDVL PmiLuLGD7XzS4L3cHSFkbP7/lczAiD8y8qMWO1/8OEFnRQEKza/+dBqWPdw9rmRwFDEO AXW/cQprT93KjK6urc2l00hNIKLMEEueDHcEAvUH2H286MRrY2+uRKEEo9s8KRqm6hZY 6CLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=33Ep0eBYcznh4YKdgwgjEF0eTogWfQEGQNtMKXb2ORM=; b=Suq4Eqn90dyBkelKpfiFDDz8RLgCQRCN/LhwDBcEXaniocf6/TiFD8gFxr6/Z5kERV nnkDv2h0bJttPlivYTZF2MwOwu1jDdiur+zqgq4tI626ryAkZJyML016t1iHSbiBTk91 yZqQEEaxAooR7+nwuEEwn4Tx42RHN62sdOMMXp1+Y5heWigajvRUzBR670wIh3MeI3kN R5Pg9lNOkwdE+mqhAv9PFjG+VoMbbL0BkLpratPziFhDIJ/QfU+PsVBjV716IrIrO2g5 6u8eM4sCTMpqPuuEhVrEd3uEeQ5SFZ0rH+fh4zzrbQ85dSv/OaFkw2M8CXflms7jFDjW Ty+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MMmP9YTQ; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb7-20020a170907160700b0078db3762061si6601166ejc.439.2022.12.15.02.54.36; Thu, 15 Dec 2022 02:54:52 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=MMmP9YTQ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230148AbiLOJwT (ORCPT + 68 others); Thu, 15 Dec 2022 04:52:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbiLOJva (ORCPT ); Thu, 15 Dec 2022 04:51:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28398183B8; Thu, 15 Dec 2022 01:51:29 -0800 (PST) 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 B6AF061D48; Thu, 15 Dec 2022 09:51:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 446CDC433EF; Thu, 15 Dec 2022 09:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671097888; bh=FLxhdTY1VQyzwuVG4/oOhod3ZbSIZVOgwKf6XLYV1MA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MMmP9YTQ4+7Uq3C6aqSAyLsc1NPi2HjOnLfNzaxBSFW/sWd0+E1NYJYQcdggTomMj FDWrfRfN2JXKlS6aSyjb5e97cADfhK9tQe4Z3ZFELt6FNDjYjhZAY+sGR/77f0bSs8 /Ptf2SFeLw22wtrTx7mX26zSYL6vHgwhAA9rYpTZKIJT67I/Zf459NbFnuN2g68VLe cp7SD1Lb3LE8Iv8QyQ64K4i9yeDyljNSsTjF9aAJD2PJ21wu3gzdEQsa3Ewp8y3J01 w0Rc4uKNRnRgUfweSffTDejQKm/P0tHLSntgoyj1XPuV5hPW+dtk7w3Cnro0zeg9rP boMctuMA6N+eQ== Date: Thu, 15 Dec 2022 09:51:21 +0000 From: Lee Jones To: Greg KH Cc: Simon Horman , Jialiang Wang , stable@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, niejianglei2021@163.com, oss-drivers@corigine.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] nfp: fix use-after-free in area_cache_get() Message-ID: References: <20220810073057.4032-1-wangjialiang0806@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 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 On Thu, 15 Dec 2022, Greg KH wrote: > On Thu, Dec 15, 2022 at 09:25:23AM +0000, Lee Jones wrote: > > Dear Stable, > > > > [NB: Re-poking Stable with the correct contact address this time! :)] > > > > > > > area_cache_get() is used to distribute cache->area and set cache->id, > > > > > and if cache->id is not 0 and cache->area->kref refcount is 0, it will > > > > > release the cache->area by nfp_cpp_area_release(). area_cache_get() > > > > > set cache->id before cpp->op->area_init() and nfp_cpp_area_acquire(). > > > > > > > > > > But if area_init() or nfp_cpp_area_acquire() fails, the cache->id is > > > > > is already set but the refcount is not increased as expected. At this > > > > > time, calling the nfp_cpp_area_release() will cause use-after-free. > > > > > > > > > > To avoid the use-after-free, set cache->id after area_init() and > > > > > nfp_cpp_area_acquire() complete successfully. > > > > > > > > > > Note: This vulnerability is triggerable by providing emulated device > > > > > equipped with specified configuration. > > > > > > > > > > BUG: KASAN: use-after-free in nfp6000_area_init (/home/user/Kernel/v5.19 > > > > > /x86_64/src/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c:760) > > > > > Write of size 4 at addr ffff888005b7f4a0 by task swapper/0/1 > > > > > > > > > > Call Trace: > > > > > > > > > > nfp6000_area_init (/home/user/Kernel/v5.19/x86_64/src/drivers/net > > > > > /ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c:760) > > > > > area_cache_get.constprop.8 (/home/user/Kernel/v5.19/x86_64/src/drivers > > > > > /net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:884) > > > > > > > > > > Allocated by task 1: > > > > > nfp_cpp_area_alloc_with_name (/home/user/Kernel/v5.19/x86_64/src/drivers > > > > > /net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:303) > > > > > nfp_cpp_area_cache_add (/home/user/Kernel/v5.19/x86_64/src/drivers/net > > > > > /ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:802) > > > > > nfp6000_init (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet > > > > > /netronome/nfp/nfpcore/nfp6000_pcie.c:1230) > > > > > nfp_cpp_from_operations (/home/user/Kernel/v5.19/x86_64/src/drivers/net > > > > > /ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:1215) > > > > > nfp_pci_probe (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet > > > > > /netronome/nfp/nfp_main.c:744) > > > > > > > > > > Freed by task 1: > > > > > kfree (/home/user/Kernel/v5.19/x86_64/src/mm/slub.c:4562) > > > > > area_cache_get.constprop.8 (/home/user/Kernel/v5.19/x86_64/src/drivers > > > > > /net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:873) > > > > > nfp_cpp_read (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet > > > > > /netronome/nfp/nfpcore/nfp_cppcore.c:924 /home/user/Kernel/v5.19/x86_64 > > > > > /src/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c:973) > > > > > nfp_cpp_readl (/home/user/Kernel/v5.19/x86_64/src/drivers/net/ethernet > > > > > /netronome/nfp/nfpcore/nfp_cpplib.c:48) > > > > > > > > > > Signed-off-by: Jialiang Wang > > > > > > > > Any reason why this doesn't have a Fixes: tag applied and/or didn't > > > > get sent to Stable? > > > > > > > > Looks as if this needs to go back as far as v4.19. > > > > > > > > Fixes: 4cb584e0ee7df ("nfp: add CPP access core") > > > > > > > > commit 02e1a114fdb71e59ee6770294166c30d437bf86a upstream. > > > > Would you be able to take this with the information provided please? > > You really want this back to 4.14.y, as 4cb584e0ee7df ("nfp: add CPP > access core") showed up in the 4.11 release, right? Yes please. Brain said one thing, fingers typed another! > if so, now queued up. Thank you. -- Lee Jones [李琼斯]