Received: by 2002:ac8:760c:0:b0:40f:fb00:664b with SMTP id t12csp927760qtq; Thu, 14 Sep 2023 22:46:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm4hNBcybr8+F+Ye36AaEwGjZ6K6MjM4ZN1zyAz8RlaH49rbeZ3hEFaQG+U+IqWJAehJRc X-Received: by 2002:a05:6a00:b8e:b0:68f:fa41:4e92 with SMTP id g14-20020a056a000b8e00b0068ffa414e92mr761074pfj.1.1694756779144; Thu, 14 Sep 2023 22:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694756779; cv=none; d=google.com; s=arc-20160816; b=tXwwq2wMhe/zpQVX0NQGV7ZTuHLrHOnliixsx/A8Bp7F9RfH93hjoMxuJ+fbbIVog9 hfM6wc8rLrciQ/J8nrTaY5wZD6bDxnkj/9MW8L9UqCCvd0/TwkF/kQl+/af8yYAc0V5B Yi2ZgbkG6GBmWjC+yDb22Xn1M2dzg7OgVKinmwKq0QMrVsRNbzdPMyci7XzkvEQGSyVb u7fNAJQI3gJMkPYd2rWA9bPRyxqkM2sgSldiPVXiTcPM8javG+E42CwNAPmnZCxXHmg4 CfLsBlSifpM4AH4iRfesvMTVHv0h/VJg8TwvCIGswyFcyftWjJoRTI0+J5lw+COyqt1M qluA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fzknch3bkkQ+8eP9KG2p7MCdrH9DkYKoxSaNbOwqAvM=; fh=NGTNJ/ArZl9RmbXZGA8l7FPZIwnb387K+TtMFO+kumE=; b=zE3jNWlPkwswkG0kCFBGiZtFtYiSDzdjF6jO91oiFgJSUq/tlqgPZuc9SAwRJmdS0A q7puVCvwwrB2lB7Ma2xn7UIxS+8TPZ9lyYXb+Tm9xe5lKNb53cKOoBgw3sCkge8Gdd92 KMwu42GzeRWs4nox985Iuukih8nrE5eAdGO/3m4TOiCjbr9jabwM7rkVavNzprnrJhDm GGbfOPGuVc2AN3LAOgz1HNqX7NHixVk+5kA00gcmELujsnMjZ/pScD212VzuusOpst4C JvTOmJkVfQqXhQgRw89CRrmZYNefzjrO6sTk6lBPZumDg9k2kVFyKj6JkJG3VnBTIRpM lj8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AFmeNfCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id f10-20020a056a00228a00b0068fadbc3169si2908827pfe.254.2023.09.14.22.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 22:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AFmeNfCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C000F83743AD; Thu, 14 Sep 2023 22:45:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232057AbjIOFpw (ORCPT + 99 others); Fri, 15 Sep 2023 01:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjIOFpv (ORCPT ); Fri, 15 Sep 2023 01:45:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F07EA1FC7 for ; Thu, 14 Sep 2023 22:45:46 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C79CC433C7; Fri, 15 Sep 2023 05:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694756746; bh=RkQ+VQK/LtyZI9gl6pg1mDINFpvds0mAdYYBVjSe2Do=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AFmeNfCmf0UoU2TDXz1Q08pNza4cMwv4wVxKRKe9UD+B+ZRsXpTFSVLgpalZJp562 lxz2ddDGm3iwA9uamSzYoUyClxUMGDmnCFkhU3ZPzgcOYSRhxAzTxFuDLNBHztl9hc 6qwACV+O4ac+Ec/vlysxEeDvCvoKMBcBE79uTIWfbHK1bC1wv9GuF8CuCBvC0bDMeJ Iqz74JV9xRnnA4qFRN9lQEdyqVTfWL8jwv8mriXX+1IKbid9loMRY9J8XWIfJdATEh 6amQveAa5iTUdzxteuxFLbRxYZhRLOEaGKF4zBYIVJwZU2VpBV2QhhyHkThy33rqPT ryaHOif+TQ82g== Date: Fri, 15 Sep 2023 07:45:41 +0200 From: Simon Horman To: Ma Ke Cc: shshaikh@marvell.com, manishc@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, GR-Linux-NIC-Dev@marvell.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb() Message-ID: <20230915054541.GB758782@kernel.org> References: <20230913104119.3344592-1-make_ruc2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230913104119.3344592-1-make_ruc2021@163.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 22:45:51 -0700 (PDT) On Wed, Sep 13, 2023 at 06:41:19PM +0800, Ma Ke wrote: > In qlcnic_alloc_rx_skb(), when dma_map_single() fails, skb is freed > immediately. And skb could be freed again. This issue could allow a > local attacker to crash the system due to a use-after-free flaw. > > Signed-off-by: Ma Ke > --- > drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c > index 41894d154013..6501aaf2b5ce 100644 > --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c > +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c > @@ -832,6 +832,7 @@ static int qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter, > if (dma_mapping_error(&pdev->dev, dma)) { > adapter->stats.rx_dma_map_error++; > dev_kfree_skb_any(skb); > + skb = NULL; > return -ENOMEM; Hi Ma Ke, I am a unclear on how skb could be freed a second time. skb is a local variable which goes out of scope when the function returns.