Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1460237lqj; Tue, 4 Jun 2024 02:08:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzjC4NyeIu4QXcj8dQqlR/1u79TqqKCBix+NIvdleCzKiSejmnPjt/W0+rRNV7cbewHYBvPtXUXBuUUS6Igtk2AshgsO2xYTC0wBRxww== X-Google-Smtp-Source: AGHT+IHrljM8nRgImhHmZlmWeXamfI0jZYwsBST7WFJTuSww2lHXje/rWD6u6IrduEvN0GoOKJkU X-Received: by 2002:a05:6e02:1d11:b0:374:9552:821a with SMTP id e9e14a558f8ab-374955285d8mr85234895ab.5.1717492099768; Tue, 04 Jun 2024 02:08:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717492099; cv=pass; d=google.com; s=arc-20160816; b=cdpZ3h8mMO2OjG3X9v95OjV04ZPKNADE9uccn0buYzFYKjVUsJi73S+U1STUoOnpd2 9s5BidcGCsD62dOjrKMB3/DaXRa+Q+sADcRbro07iS2qXnAQSzsZnCL/eddt30dBHS5e hrdinmBTZMAwqv7J6SOXSw6ifncHSbJnu3HDzKLwO1FKBGY0aqxj3YRApc1HNzvyXr0k 4LE6YWLjh5g9JIW95hKsRB1DC7vQLVigkQg5ckCeB+UTowNouCU3iqTPhnrcnhqNYOsl mFfmX+DanYFry6KUoxq5QSmVUyIAqyEQeAI1VCm66h6N+ss/AxT5P24vTMud5Gg/rKaP aujw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature:dkim-filter; bh=UQ3dE+N/0pFO6FIyT3FNM4hfEUPHqbcPEwjKMAJv84M=; fh=Oh7ISTCnTTAwBTFe2MGd4+/TilShj52te/ioKdU9yfo=; b=xX6lJ8OxC//BGRJ3kyfcFeT4ysEg5/3KI1/U/FRp8LD8QNoWwKNlINYz55ZOEWZrRT QpPLm9SIqxcPRS+6ozPXEuvs6vh/jbYDqkKn/kLGy++3zH0O4Uglc6o0VB3TIh9sNWUy EWKFAGvBM6GOraUwdZFkWETL/hHjbMwhkS/wFzHF+2uZWkhsOzJTQauydL9wf2ODC2nC 6QpGJzQl8wNQlUrelfdbJlsiSF7+fec4Gqc58RXrfIfB/E/vKICIqhQ2um4WC59Y4mVP O8XbVlITTbAv/mHRkEPJDqwiq2dSN7PvDcErhf3X+GeopQ8yW43ZelpMb0vTgpRmhvSY bNcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=AsidLimY; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-200300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35515641bsi7685848a12.209.2024.06.04.02.08.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=AsidLimY; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-200300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6D8FAB24BEA for ; Tue, 4 Jun 2024 09:01:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 135DF143754; Tue, 4 Jun 2024 09:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="AsidLimY" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE3E4652; Tue, 4 Jun 2024 09:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717491672; cv=none; b=esVvlLyh4VYb0YAkKQ6yVLusHeROAhOR/qiYSVz5JJ+xjQesNXnEO5Rls/rukUM3fcguhWdpkhFri8+7dBVmeBGZ5zM1GpxQLsHthj2LjEnTz+TAltNc/hzzV408SWtd++BM2X2okxuUKl+pnRoe4xNE131D+SCaWJnZAi2SBAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717491672; c=relaxed/simple; bh=77c9JqkTvByLnMHXjAWcS4jMhO6cdGjdlVGhwyYHjZQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TNpNMtgSDWFV/+CxXDfHKj6ZjERHtuMIFICfO3p50rlDZiYiF3Ss80f4frAhUb9kdsj8hc0pSTTdFbh6wbDyM1bgMUuOqH6lZp7gmok3VNoLyd4Lo8EwzWSJly14b9E+2vCXdPdkruqEQTXz2Scq1ePvTKY0Z9+ihXl8aCWFlyQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=AsidLimY; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: by linux.microsoft.com (Postfix, from userid 1134) id 45F2220B915A; Tue, 4 Jun 2024 02:01:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 45F2220B915A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1717491670; bh=UQ3dE+N/0pFO6FIyT3FNM4hfEUPHqbcPEwjKMAJv84M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AsidLimY5TPpyvOLbjRWzCVqbqAUnF7dDloZafb856Z1DJsm5Z1Nq/RYsydZSy0ro DcOYptWLGpA7fc+3cMVqo+SQkxHI7EaFpLkJUr0xqAkc4WmoHwwoTQvhp+ZklDCxDH 6JqNAXLTvTTWeLz5NgyF15mjLaiaH91MFA/oy7Aw= Date: Tue, 4 Jun 2024 02:01:10 -0700 From: Shradha Gupta To: Leon Romanovsky Cc: linux-hardening@vger.kernel.org, netdev@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Colin Ian King , Ahmed Zaki , Pavan Chebbi , Souradeep Chakrabarti , Konstantin Taranov , Kees Cook , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Dexuan Cui , Wei Liu , Haiyang Zhang , "K. Y. Srinivasan" , Jason Gunthorpe , Long Li , Shradha Gupta Subject: Re: [PATCH net-next v3] net: mana: Allow variable size indirection table Message-ID: <20240604090110.GA11436@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1717169861-15825-1-git-send-email-shradhagupta@linux.microsoft.com> <20240603084122.GK3884@unreal> <20240604053648.GA14220@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <20240604083205.GM3884@unreal> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240604083205.GM3884@unreal> User-Agent: Mutt/1.5.21 (2010-09-15) On Tue, Jun 04, 2024 at 11:32:05AM +0300, Leon Romanovsky wrote: > On Mon, Jun 03, 2024 at 10:36:48PM -0700, Shradha Gupta wrote: > > On Mon, Jun 03, 2024 at 11:41:22AM +0300, Leon Romanovsky wrote: > > > On Fri, May 31, 2024 at 08:37:41AM -0700, Shradha Gupta wrote: > > > > Allow variable size indirection table allocation in MANA instead > > > > of using a constant value MANA_INDIRECT_TABLE_SIZE. > > > > The size is now derived from the MANA_QUERY_VPORT_CONFIG and the > > > > indirection table is allocated dynamically. > > > > > > > > Signed-off-by: Shradha Gupta > > > > Reviewed-by: Dexuan Cui > > > > Reviewed-by: Haiyang Zhang > > > > --- > > > > Changes in v3: > > > > * Fixed the memory leak(save_table) in mana_set_rxfh() > > > > > > > > Changes in v2: > > > > * Rebased to latest net-next tree > > > > * Rearranged cleanup code in mana_probe_port to avoid extra operations > > > > --- > > > > drivers/infiniband/hw/mana/qp.c | 10 +-- > > > > drivers/net/ethernet/microsoft/mana/mana_en.c | 68 ++++++++++++++++--- > > > > .../ethernet/microsoft/mana/mana_ethtool.c | 27 +++++--- > > > > include/net/mana/gdma.h | 4 +- > > > > include/net/mana/mana.h | 9 +-- > > > > 5 files changed, 89 insertions(+), 29 deletions(-) > > > > > > <...> > > > > > > > +free_indir: > > > > + apc->indir_table_sz = 0; > > > > + kfree(apc->indir_table); > > > > + apc->indir_table = NULL; > > > > + kfree(apc->rxobj_table); > > > > + apc->rxobj_table = NULL; > > > > reset_apc: > > > > kfree(apc->rxqs); > > > > apc->rxqs = NULL; > > > > @@ -2897,6 +2936,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending) > > > > { > > > > > > <...> > > > > > > > @@ -2931,6 +2972,11 @@ void mana_remove(struct gdma_dev *gd, bool suspending) > > > > } > > > > > > > > unregister_netdevice(ndev); > > > > + apc->indir_table_sz = 0; > > > > + kfree(apc->indir_table); > > > > + apc->indir_table = NULL; > > > > + kfree(apc->rxobj_table); > > > > + apc->rxobj_table = NULL; > > > > > > Why do you need to NULLify here? Will apc is going to be accessible > > > after call to mana_remove? or port probe failure? > > Right, they won't be accessed. This is just for the sake of completeness > > and to prevent double free in case there are code bug in other place. > > This coding patter is called defensive programming, which is discouraged > in the kernel. You are not preventing double free, but hiding bugs which > were possible to be found by various static analysis tools. > > Please don't do it. > > Thanks Understood, it makes sense. Let me fix this in the next version. Regards, Shradha > > > > > Regards, > > Shradha. > > > > > > Thanks