Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp715074rwb; Tue, 29 Nov 2022 04:34:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7bcNs0OC+XQZnXvqbhxCEzG0F9GOaI1D/1Ba3/GPtIBVWp8hYy66LlpCr/ymdYa8nbIwEO X-Received: by 2002:a05:6402:456:b0:461:9955:b54a with SMTP id p22-20020a056402045600b004619955b54amr40076559edw.159.1669725275631; Tue, 29 Nov 2022 04:34:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669725275; cv=none; d=google.com; s=arc-20160816; b=Z6+YpA1W7FNc6AwHkeUGLKdgXJCcHVQM91nXVHmfARE+k6rm+JKeNG9hPM6YkdBr4P bsHY2X/R/niHjvsyFPA5GhhDcYihpFi/oSXJGsCLrFQaNVwbvYsa9EkRNKL9kTP4wrF7 DxyzZmQ8NAoFCQN44gh5uqZKfjXGDdV4hNR+9i3VO0dRE8iQpgNLRiqk6hOvTLZBF3GF YUFyAkupyu1IcuxZTzVFcEVOu9bCZVTTn5KrNadsgpoPU86JEdyJWlDwC9Q8iS3y5pGO R39ET0bAxoKbkeD7yN8CSRyUMIA2HYjnxUSF+X2BF3uFBvxuhHYDc0LezfWIKi5oDcSX ViZA== 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:date:cc:to:from:subject :message-id:dkim-signature; bh=1imltAz45YNaotAIbFUcpudsIMx54FwHI8IznpWl/fg=; b=HUCslbVD8a03ffDCGf6c3VV3lUfBSKdQBBiTL8Xr+RUPVxvvxclXY79Gngjtx0ruQU 1xT5BDPTvyNNvhN2Y8PxEMQBo2d7zheQTAzuv5PD1XZxZqUD23QKRBplOxjQLfLETp43 ZsTwC3p+lGfps1hoDGfMz4gR6XXhgPVUpvarh/W5g9dkdI1CycfLErgrzavmxrVoZalv bpqQUmeAK81zmOQg15mFNew6hqoIiDoC4gtJnnp5Hm8Obwl38CGMrAKL+ba9dwkRYGBF Wvx5ZUVyuzw5pJmX7aODvZ3DNuBvnvJWhJBBvWmKaMJGZptuKjR1+sADDfvjcXk0jQpB YeZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DZiWfkSm; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go18-20020a1709070d9200b0078de536a3cdsi12763248ejc.119.2022.11.29.04.34.16; Tue, 29 Nov 2022 04:34:35 -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=@redhat.com header.s=mimecast20190719 header.b=DZiWfkSm; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233961AbiK2MGa (ORCPT + 83 others); Tue, 29 Nov 2022 07:06:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233706AbiK2MFw (ORCPT ); Tue, 29 Nov 2022 07:05:52 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDC393AE for ; Tue, 29 Nov 2022 04:04:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669723442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1imltAz45YNaotAIbFUcpudsIMx54FwHI8IznpWl/fg=; b=DZiWfkSmk9op8LYHLDPa9W3amaOrRk9jTZllB6vcxQahBxMZ7OnMTso0EuxCRbd+9QZ2GH 8inMZJ1dMmdw2UudmxcHBtbBUSMRsRs95OXrBkE2rs51lHbtL3em4l9IahP9sO9uLdjty7 InckPMs7f9V7chRHxw3VpXP7BY9rF90= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-453-858TOkXrNFqA_slCxMhMLQ-1; Tue, 29 Nov 2022 07:04:00 -0500 X-MC-Unique: 858TOkXrNFqA_slCxMhMLQ-1 Received: by mail-qk1-f198.google.com with SMTP id h13-20020a05620a244d00b006fb713618b8so27871625qkn.0 for ; Tue, 29 Nov 2022 04:04:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1imltAz45YNaotAIbFUcpudsIMx54FwHI8IznpWl/fg=; b=mLuWUQK+++VOk/wa4DfI/4K7yL6WMV419x2zviWOL++isRHKdvTJoeEDZ3nH1Y1vNL ywu5mr+5Plyn+YLSa303IbtIZhQsoHYLHcJmD1/Nuli3pge5Px9mxSGTlghK3NKvo/K/ 38qPyggey9JmKk9Dum8duumHJz40cQDvHQhunRr4scKa55FwMYCOMhZ02kjWs/0bu8tE AOGEhMY6SMfxGX5cOVDTr9CsDjRE/wziqn2oBsCRF1/Nk/mCQfXJtIQOQkG+Ky2We99k CuT8/utluztORBhbpRkxLjWhdY0OJWUj3Tm5xgKWETE9U24Lzu/9xE/7D8BOAnJpagtt N14Q== X-Gm-Message-State: ANoB5pksmPH3PLD4J5mxx7NNuNX1cXIXt/qmSB/WSjznNTCIr7UWpfX0 HrxMeZiq02iQ/BivPqUWyFg+R6z13OwgvAFHCAAHGrxW38SSp5x1MNffzDwIPn7uMoeCLIsb+1e x+/rLpOZamCh0aeuEOqgt0wA3 X-Received: by 2002:ac8:528d:0:b0:3a5:1eb:d8ab with SMTP id s13-20020ac8528d000000b003a501ebd8abmr51370139qtn.443.1669723440197; Tue, 29 Nov 2022 04:04:00 -0800 (PST) X-Received: by 2002:ac8:528d:0:b0:3a5:1eb:d8ab with SMTP id s13-20020ac8528d000000b003a501ebd8abmr51370110qtn.443.1669723439921; Tue, 29 Nov 2022 04:03:59 -0800 (PST) Received: from gerbillo.redhat.com (146-241-120-203.dyn.eolo.it. [146.241.120.203]) by smtp.gmail.com with ESMTPSA id x5-20020ac84a05000000b0039cc7ebf46bsm8455425qtq.93.2022.11.29.04.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 04:03:59 -0800 (PST) Message-ID: Subject: Re: [PATCH net 2/2] octeontx2-pf: Fix a potential double free in otx2_sq_free_sqbs() From: Paolo Abeni To: Ziyang Xuan , sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Date: Tue, 29 Nov 2022 13:03:56 +0100 In-Reply-To: <047b210eb3b3a2e26703d8b0570a0a017789c169.1669361183.git.william.xuanziyang@huawei.com> References: <047b210eb3b3a2e26703d8b0570a0a017789c169.1669361183.git.william.xuanziyang@huawei.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Hello, On Fri, 2022-11-25 at 15:45 +0800, Ziyang Xuan wrote: > otx2_sq_free_sqbs() will be called twice when goto "err_free_nix_queues" > label in otx2_init_hw_resources(). The first calling is within > otx2_free_sq_res() at "err_free_nix_queues" label, and the second calling > is at later "err_free_sq_ptrs" label. > > In otx2_sq_free_sqbs(), If sq->sqb_ptrs[i] is not 0, the memory page it > points to will be freed, and sq->sqb_ptrs[i] do not be assigned 0 after > memory page be freed. If otx2_sq_free_sqbs() is called twice, the memory > page pointed by sq->sqb_ptrs[i] will be freeed twice. To fix the bug, > assign 0 to sq->sqb_ptrs[i] after memory page be freed. > > Fixes: caa2da34fd25 ("octeontx2-pf: Initialize and config queues") > Signed-off-by: Ziyang Xuan > --- > drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > index 9e10e7471b88..5a25fe51d102 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > @@ -1146,6 +1146,7 @@ void otx2_sq_free_sqbs(struct otx2_nic *pfvf) > DMA_FROM_DEVICE, > DMA_ATTR_SKIP_CPU_SYNC); > put_page(virt_to_page(phys_to_virt(pa))); > + sq->sqb_ptrs[sqb] = 0; The above looks not needed... > } > sq->sqb_count = 0; ... as this will prevent the next invocation of otx2_sq_free_sqbs() from traversing and freeing any sq->sqb_ptrs[] element. Cheers, Paolo > }