From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35B4BC3DA4A for ; Thu, 22 Aug 2024 14:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ReVmM6ZLYLyGLHzU41oj8IRlAECMO3NTJbQTUqTSt70=; b=HI9In3W7hENqpFQiSFDFTQaQl/ hsulwJbkK+jmarQjymiy0qHqBrvGkQDPZ3MKlcPKt0FzzClOCz2pp3O+LIyr//KiBdKDXFDS24Flv S6Bf9tO9H/G6+XwYhfjr4kpQfGG0jIY5I1jVsUPg6tffNK704DbKlv9Pm4ebEAL8G2fP6HLAuEs6A v9FvjP5EmcXiItF29rVkevpTH9kz3g5pp4Sc1SKftT5G8LRjscGV+d8V2JyBtmYhZYO/KTrSR1Urd ZiSUiN/656QD4IIDvbaxMbajnZc6cUwK9aQ6LiMP+g0je9AqyO9DLxdkwQo6Oj5Z59cId23LKIGP1 MT75RVpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh99F-0000000DEFU-3FWz; Thu, 22 Aug 2024 14:50:49 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sh97j-0000000DDof-2GyQ for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2024 14:49:16 +0000 X-CSE-ConnectionGUID: HYqwU6WEQhexqwruiXOKIw== X-CSE-MsgGUID: g0uQ3UQ5T2OaRdwqPWfvfA== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="40221798" X-IronPort-AV: E=Sophos;i="6.10,167,1719903600"; d="scan'208";a="40221798" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2024 07:48:23 -0700 X-CSE-ConnectionGUID: UdIrjZhCSFGc6ouMiWWcLQ== X-CSE-MsgGUID: FsVdg77kTMeRpXd6tbM6Zw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,167,1719903600"; d="scan'208";a="61793671" Received: from smile.fi.intel.com ([10.237.72.54]) by orviesa006.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2024 07:48:14 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98) (envelope-from ) id 1sh96C-00000000U7b-2aUU; Thu, 22 Aug 2024 17:47:40 +0300 Date: Thu, 22 Aug 2024 17:47:40 +0300 From: Andy Shevchenko To: Philipp Stanner Cc: Jonathan Corbet , Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Richard Cochran , Mark Brown , David Lechner , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Damien Le Moal , Hannes Reinecke , Chaitanya Kulkarni , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, stable@vger.kernel.org, Christophe JAILLET Subject: Re: [PATCH v3 7/9] vdpa: solidrun: Fix UB bug with devres Message-ID: References: <20240822134744.44919-1-pstanner@redhat.com> <20240822134744.44919-8-pstanner@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240822134744.44919-8-pstanner@redhat.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240822_074915_701776_CEFA0CE9 X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 22, 2024 at 03:47:39PM +0200, Philipp Stanner wrote: > In psnet_open_pf_bar() and snet_open_vf_bar() a string later passed to > pcim_iomap_regions() is placed on the stack. Neither > pcim_iomap_regions() nor the functions it calls copy that string. > > Should the string later ever be used, this, consequently, causes > undefined behavior since the stack frame will by then have disappeared. > > Fix the bug by allocating the strings on the heap through > devm_kasprintf(). ... > - snprintf(name, sizeof(name), "psnet[%s]-bars", pci_name(pdev)); > + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev)); > + if (!name) > + return -ENOMEM; > + > ret = pcim_iomap_regions(pdev, mask, name); ... > - snprintf(name, sizeof(name), "snet[%s]-bar", pci_name(pdev)); > + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev)); > + if (!name) > + return -ENOMEM; + Blank line as in the above snippet? > /* Request and map BAR */ > ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name); -- With Best Regards, Andy Shevchenko