Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5121385rwb; Mon, 8 Aug 2022 12:33:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4FVa8GpvGyjotRMDPb94t7B2bi/kPXCQrxCMSY8HtOTqzKTYy9eTt3/mc/d4e3GKzfYdUG X-Received: by 2002:a05:6402:20b:b0:440:cb9f:c469 with SMTP id t11-20020a056402020b00b00440cb9fc469mr4103908edv.420.1659987198460; Mon, 08 Aug 2022 12:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659987198; cv=none; d=google.com; s=arc-20160816; b=mciDBNsEZFxd99opOlvsdUUzfeEHCU5ZVdMI3Ma8v/q8+vfCIbFklVrykaxcGplZff hu6jonWxqznUdRQlgWmDIOJZ8vdRpMW+Fh9xnf4eVATfunXEBxPAahRYPvn1Hr6eviwJ cqDTivUXMIopMgXD0sIYejBQDZwclXlzjjxibUiPYBDO3zPRBpFK1E5Arp0KXxla6JuA SnjBInqB61sd5iBCMPqRO1Q5QmuHZtqnCDL3ZBISLKuNwiweM2jcox8RgGLBfsuRlwK/ lTs/uQsymYymn8T3YD2rZNgaqKfhH3etHzwYCxZTVbcFB+r/CsN1m+5F+lKu2jYiQT3C D/VQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=6z1hk+Fvb5s7Pb24mtCFANPYZG64OgeWLTva2DcHg+E=; b=uxJ6m5eUNJ9fOGF7kXgzl5Irwrchb6MdHk/ZE2SkfmSRtGr5w7T9nkPe+3IW2cbbcx gSb0jSzMLhVl4CLGDLiIQA+By73dOhKeov7FJgeWi8ToKX8O7EZO9x3wgyvfytTneiSF qB2LVmnVX8hS1pCcnYPg1d6ZPwPzfcvWr558SweGUR/Zm3elKpljJReeUxvgqa6V7F0R MARTgGz17KOcWF8EymNh1EW7bAnVy8S8298cfECxUPFH74dNrUv/2BQIc9JL3ZErT0pa XuNA3adM+wWmtNdB4lZiG2R6TovpjD3CY5xm8+ATOG/kkAFc1IlVDbV1sEvhlwVTO7n/ rIFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UBurGjx9; 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 bx6-20020a0564020b4600b00435b2a66c73si6482933edb.191.2022.08.08.12.32.52; Mon, 08 Aug 2022 12:33:18 -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=@kernel.org header.s=k20201202 header.b=UBurGjx9; 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 S244374AbiHHTQc (ORCPT + 99 others); Mon, 8 Aug 2022 15:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244400AbiHHTQR (ORCPT ); Mon, 8 Aug 2022 15:16:17 -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 5000219C11; Mon, 8 Aug 2022 12:15:39 -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 E2F52612B7; Mon, 8 Aug 2022 19:15:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00901C433D6; Mon, 8 Aug 2022 19:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659986138; bh=ixU74nyB6lXnufS/Mxla5bKUb4noApy93h18rcJcCRI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UBurGjx9NurCEAl795DGLNzZQIlE+xM/euccxXXfMp22iMdqCmFoM5WNELFOisml+ Mzq7k37AuK0sERsvWDCB6RlPGaTSXu7wqVMQ9R1rGfTucTWEkJsOybtbS8W7OE6HEO OyYC20uqQDDS5CV7xjjs8HESkvudJ7h1BeW03g6kjBT4UcMXpZLArgQAs+XpPfDs+H ZQPTGBDAeHmlmEGQkZAAgKiqHnKTWIqL1YLMttGPVw/KN69uXk39CLwrIIz68JN6vm LzKGcoq8GBLUoMJ4ioQTUskEYpItlmMHb5TvDFXDQGK3+CjekFIBosJN0QKcWNNHjL yQXjBJnYkdTSg== Date: Mon, 8 Aug 2022 12:15:36 -0700 From: Jakub Kicinski To: Jialiang Wang Cc: simon.horman@corigine.com, 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] nfp: fix use-after-free in area_cache_get() Message-ID: <20220808121536.412c042d@kernel.org> In-Reply-To: <20220806143043.106787-1-wangjialiang0806@163.com> References: <20220806143043.106787-1-wangjialiang0806@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 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,T_SCC_BODY_TEXT_LINE 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 Sat, 6 Aug 2022 22:30:43 +0800 Jialiang Wang wrote: > area_cache_get() calls cpp->op->area_init() and uses cache->area by > nfp_cpp_area_priv(area), but in > nfp_cpp_area_release()->nfp_cpp_area_put()->__release_cpp_area() we > already freed the cache->area. > > To avoid the use-after-free, reallocate a piece of memory for the > cache->area by nfp_cpp_area_alloc(). > > Note: This vulnerability is triggerable by providing emulated device > equipped with specified configuration. > > BUG: KASAN: use-after-free in nfp6000_area_init+0x74/0x1d0 [nfp] > Write of size 4 at addr ffff888005b490a0 by task insmod/226 > Call Trace: > > dump_stack_lvl+0x33/0x46 > print_report.cold.12+0xb2/0x6b7 > ? nfp6000_area_init+0x74/0x1d0 [nfp] > kasan_report+0xa5/0x120 > ? nfp6000_area_init+0x74/0x1d0 [nfp] > nfp6000_area_init+0x74/0x1d0 [nfp] > area_cache_get.constprop.8+0x2da/0x360 [nfp] Please provide more of the report, including the allocated at and freed at sections and run the thing thru stack decode so we get the line numbers.