Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp519789rdd; Tue, 9 Jan 2024 10:59:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJNgLcmqmHNjEZ6j5Ohs7zwVYfn1GJoLJCscQxPSi2k6D6CyWuHVjjhGMSNEnHDuHLOgld X-Received: by 2002:a05:600c:3b04:b0:40e:4d51:99a2 with SMTP id m4-20020a05600c3b0400b0040e4d5199a2mr675762wms.145.1704826761081; Tue, 09 Jan 2024 10:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704826761; cv=none; d=google.com; s=arc-20160816; b=gWTl2KP0hYkNikKqoZeMB/ghOQqEWGQlRfjyuzYrQ2kXt4qfAy+hrWYBLmdsNGVIhU +kw1uFeVNyx+Sxyb76ap2PpVHa9V+VhaQ3l5xz+5F+JccXf/ul8EuqqpAyGaekq/erDB +R7tiEsI1BwrBd0NLMQ2wFJXiBeVog/TGaBV5/MQniPpOadBp2z9Lh2Co67w7hOQApCS g+fWm96b4qwbNyWWd6921KiNV58LKRT4kSqMeHYBDIlb/sT68EWqvrvOdyZB4ALXI5Tp OL4W99iNPr0+/2qa5EBAllwpZYDbqijScIlNsplt4LAqeXGjXiYPdYZ9zfFUtTtWS8Xm tc/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ktpWqLoLBUZWt3bdWuYR6mGDdugSR4u2H8vvbC3v48c=; fh=WKavsXCI6EzkGA73EdPdubaVohr/a5X17e9pLDsWcfY=; b=rS4ft/CUiWe4M9WboXOYjbq0WtZnoig3Gh3aHlEUoZZoYxdeIQK3uF1Xz4FtocQ5Iv 6iWNLbUZSc7hFJzZMxrxRTiK7faFDvOfdGb7dPv+seGny5rpOPT8U4nvFazczREFkdPj 71vSIWgsLT2FS6O5pGcR8U9STd0+rfKS5wc/uJVhlWY+W5M9V7iKhEjokxAzEEZ4zOwJ VWdoMn7+fglS8QnEI3mOQ3dzsoPrdV4IFIFhAjTyjbOqUQCOAXfY4s6mmxRH/GYJiVxl i5uT1IrhRqpTKfw8JIE/XVDnAd0NxlV/CkTlyirbL8AqqXF+qrk32jivz1QSKy4YBAkL HCBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JLeFMio1; spf=pass (google.com: domain of linux-kernel+bounces-21281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h24-20020a170906719800b00a28a9e27f6asi1031427ejk.536.2024.01.09.10.59.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 10:59:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JLeFMio1; spf=pass (google.com: domain of linux-kernel+bounces-21281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21281-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D287A1F24958 for ; Tue, 9 Jan 2024 18:59:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1615D3D0C6; Tue, 9 Jan 2024 18:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JLeFMio1" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 460C03D0C1; Tue, 9 Jan 2024 18:58:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17844C433C7; Tue, 9 Jan 2024 18:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704826735; bh=frfr5IByY3xaoXjECp9aAtO5yrxIgIIlmCNFAnOInu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JLeFMio1dJrGEX1lBBiFoHih9IMPB8mkdccKZ3eUoMDl3wxKrJS6RToLFVg/UwsdV 7LakXLre2b8orTtp8vkKxFzoLB4n/MVwusnJAr8u/dYVydvf/n1HAon7PHcQ0izb6L K20DaHQLDdQc9oj7CkJPnbymd2YmRWPG/stjOTNNL1FKAz25bikpkcoFUfbZ6+C1oL NifGSOn/74nHqTICrMNyGjQWyP49iwfVv4eYfZ7l/08XB1h8S2qxhvO2VCxbbvvb2R KbBV4s+s/RYZOEmPDv5q5ZNvDGcxXViRB47g29sfQfUjRwJZVCJ1n0SmPdFwJGEsE8 vYowMLNwb/V/A== Received: (nullmailer pid 2946953 invoked by uid 1000); Tue, 09 Jan 2024 18:58:53 -0000 Date: Tue, 9 Jan 2024 12:58:53 -0600 From: Rob Herring To: "Christian A. Ehrhardt" Cc: Rob Herring , linux-kernel@vger.kernel.org, Frank Rowand , devicetree@vger.kernel.org, Stephen Boyd Subject: Re: [PATCH] of: Fix double free in of_parse_phandle_with_args_map Message-ID: <170482604952.2932213.7130104450063134715.robh@kernel.org> References: <20231229105411.1603434-1-lk@c--e.de> 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: <20231229105411.1603434-1-lk@c--e.de> On Fri, 29 Dec 2023 11:54:11 +0100, Christian A. Ehrhardt wrote: > In of_parse_phandle_with_args_map() the inner loop that > iterates through the map entries calls of_node_put(new) > to free the reference acquired by the previous iteration > of the inner loop. This assumes that the value of "new" is > NULL on the first iteration of the inner loop. > > Make sure that this is true in all iterations of the outer > loop by setting "new" to NULL after its value is assigned to "cur". > > Extend the unittest to detect the double free and add an additional > test case that actually triggers this path. > > Fixes: bd6f2fd5a1 ("of: Support parsing phandle argument lists through a nexus node") > Cc: Stephen Boyd > Signed-off-by: Christian A. Ehrhardt > --- > drivers/of/base.c | 1 + > drivers/of/unittest-data/tests-phandle.dtsi | 10 ++- > drivers/of/unittest.c | 74 ++++++++++++--------- > 3 files changed, 53 insertions(+), 32 deletions(-) > Applied, thanks!