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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0465AC433EF for ; Fri, 18 Mar 2022 18:13:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239086AbiCRSOt (ORCPT ); Fri, 18 Mar 2022 14:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233194AbiCRSOt (ORCPT ); Fri, 18 Mar 2022 14:14:49 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB014939DC; Fri, 18 Mar 2022 11:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647627210; x=1679163210; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=ZcLZFns2cmqmUDYsf79yEaH3pnYex27zE67UUmjrAQU=; b=PrPujoHJH+SZDrMGogNvPpMufkdHurjQmdh0x5c7p3hAGzTYo4vxwJmR Gi6DUuujeBg3g2ZqI3gAfNSbBbOgAPoMeIeUfrYe927nYbnIfMBjg8t8M 04oqWCVHCuKPLY8qeSbXWBe8zh+sxdoKrGDqw64wbF5gQ5AzWDSxnkRp8 lya8WF9j0LBhfMp1Bplr+2Y4NzlFROgjmPSgBBtZxuPY4/Fr4bNBeRHJu 9OuKQvvecB3u0hBKsv/fpjAK0g6vQWPOebT5ucNFetRxIw67flhFYI7mV xMavr6svoQILCavL3sDUpRsARds2iIko7otmdQ343WSNOTJ3LkVhtKcoM A==; X-IronPort-AV: E=McAfee;i="6200,9189,10290"; a="256920621" X-IronPort-AV: E=Sophos;i="5.90,192,1643702400"; d="scan'208";a="256920621" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2022 11:10:27 -0700 X-IronPort-AV: E=Sophos;i="5.90,192,1643702400"; d="scan'208";a="558577638" Received: from smile.fi.intel.com ([10.237.72.59]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2022 11:10:17 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nVH2f-002Npa-DH; Fri, 18 Mar 2022 20:09:37 +0200 Date: Fri, 18 Mar 2022 20:09:37 +0200 From: Andy Shevchenko To: =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= Cc: Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "'Rafael J . Wysocki '" , Wolfram Sang , Peter Rosin , Russell King , Andrew Lunn , Heiner Kallweit , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Hans de Goede , Thomas Petazzoni , Alexandre Belloni , Allan Nielsen , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 1/6] property: add fwnode_property_read_string_index() Message-ID: References: <20220318160059.328208-1-clement.leger@bootlin.com> <20220318160059.328208-2-clement.leger@bootlin.com> <20220318174912.5759095f@fixe.home> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220318174912.5759095f@fixe.home> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Fri, Mar 18, 2022 at 05:49:12PM +0100, Clément Léger wrote: > Le Fri, 18 Mar 2022 18:26:00 +0200, > Andy Shevchenko a écrit : > > On Fri, Mar 18, 2022 at 05:00:47PM +0100, Clément Léger wrote: > > > Add fwnode_property_read_string_index() function which allows to > > > retrieve a string from an array by its index. This function is the > > > equivalent of of_property_read_string_index() but for fwnode support. ... > > > + values = kcalloc(nval, sizeof(*values), GFP_KERNEL); > > > + if (!values) > > > + return -ENOMEM; > > > + > > > + ret = fwnode_property_read_string_array(fwnode, propname, values, nval); > > > + if (ret < 0) > > > + goto out; > > > + > > > + *string = values[index]; > > > +out: > > > + kfree(values); > > > > Here is UAF (use after free). How is it supposed to work? > > values is an array of pointers. I'm only retrieving a pointer out of > it. I see, thanks for pointing out. Nevertheless, I don't like the idea of allocating memory in this case. Can we rather add a new callback that will provide us the necessary property directly? -- With Best Regards, Andy Shevchenko