Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1308861rbb; Mon, 26 Feb 2024 05:39:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX+7OcOY6AyTG8NjNVpAqb9Edc5bEiifGWQSUmAMf/2Z8WaywaNl2Ij6Uzil0ssvTXZiUzxRU9oSbdj2KKpFgbtlAd6p0R0WMxoI2dJJw== X-Google-Smtp-Source: AGHT+IGGF+EG4hHIRJD5IaCztBTC0hPmJcbAZUECBBWZgspp7SZ9XQRmSHwIAtsxcV8mCPLnA3ho X-Received: by 2002:a62:d119:0:b0:6e4:59aa:93a2 with SMTP id z25-20020a62d119000000b006e459aa93a2mr7385355pfg.2.1708954780066; Mon, 26 Feb 2024 05:39:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708954780; cv=pass; d=google.com; s=arc-20160816; b=TPeDKlujKItEU4IARZUCRM7l8epPdTh5S0cv/lnRhRB3fpN5PY+h+KFo2fmnJwhb9W 71ubldm9LXekXASL3GuPxTU6e92+TleubtkTpZAqiWflZS5TLvvvWUH2mk7pyWEXUsAi gjODx+cSS/WIVVB7exRme6CSF3EH/VNzHwGLEN8sdd8ZJ2J9D+jCwjjw1vx/gxSiNssa Cq3HHkF7f9g34L5QM66i3/iWMF15QDHr64aBfFA799WAHbneiw4Ad+6PHvGFbTwXlOR0 pMqV2wKRXioZuahnE8y39UYfsu3YJhAUSoK8BDnSo6GrwGo2cdCwN+GF0XvydunYA+XV 1puw== ARC-Message-Signature: i=2; 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=t8m8HYOpU/lqomilwTOtXcWOBIIrR/NPUPE8VHST/Ko=; fh=XAccJXLVnVp/1oeb19ZjFp4Pkq76ixur61QAtrlOi8A=; b=O998xsyPSIGF91OE2OhtXDo5ExcIbz0BqlA1wm/BnOhRb+TeFC525Vh7BzValrUpBO cn4tsOvdcTY7HcNs7e5g0nwk8WSDg7LG50ht7Cvfn9N72GNyndwrsc7hkrZg2Ip3Z2oG Ev9jaVKYzjyaj/ZskX83pqmwmuEK9pG4q4j43DAN94nS35VKr6TWfhcBmWSdknBG4O2t 59FJHLhOQjQuOjzDnxxSrP+DMp77uk6ma0i5uBBUOWFJ3A9aIgLjeP/rgWUUkAT08zb/ S67qvcxlaN1BfCyc4gqJ/rDc6dVyPORSTSQ/uZ4RGywZ1HL/0TN1d9n2Lc9CtWFtNsi7 cFhw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="EZTFU3f/"; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-81499-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cw16-20020a056a00451000b006e482acf186si3765786pfb.73.2024.02.26.05.39.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:39:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81499-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="EZTFU3f/"; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-81499-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1CF752883DF for ; Mon, 26 Feb 2024 13:39:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41B3712883D; Mon, 26 Feb 2024 13:39:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="EZTFU3f/" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (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 C92761AACC for ; Mon, 26 Feb 2024 13:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954774; cv=none; b=IpzSnQRXMC6dGLWOhKku/NOlsCTZ2OtmGFLiXzvj8SWyiuyoVy/FKyGjcV5bToYqTxX4Y2wU9c33EGJTX2LCZ0tDL0kD3f++sAnb6tAoD5dXUIg3f1D7Tve9iz7ENliPa1B06wey5QDAHQ0WMduPh0O1cluSTvpzhGPQoq2+kRM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708954774; c=relaxed/simple; bh=MWmAbB8K5MLgMEvoZoZEs0OnXomLIkT8UJsdf2JB0zk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KrQGxiO3DMxaC9gcEWrF3IteFBbKkQnvP1Co6QjxtHGxZ/Z2L5MuIIpUFvH80f2R1CvMgaRuXDIvp7yjQ5JmDuyJ+Uy6DVl8T3Aq5Ix7+nQbYt+ZNBHt0bQihP2vsaiHPaCWnBNzzxEeYv2Fp2KPitDptwg/E3eA7r066PXHMq0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=EZTFU3f/; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=t8m8HYOpU/lqomilwTOtXcWOBIIrR/NPUPE8VHST/Ko=; b=EZTFU3f/2QzTSCqHScnAwR3o5s 6WESfBCmc5g6hxfZ9bznelLm8wW61U3xcbbk7niVEWtpEkONX4uh0XQKh7oTMA698ppCx/ZirLlvi /Wi4AiMw+xJ/dgpdemnlhllBJ8WeteAoHraZuXP8HZ4JtkYaeWt1DEqCPf0GjbX9ieR8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rebCj-008j3N-JL; Mon, 26 Feb 2024 14:39:37 +0100 Date: Mon, 26 Feb 2024 14:39:37 +0100 From: Andrew Lunn To: Duoming Zhou Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, linux@armlinux.org.uk Subject: Re: [PATCH] ARM: mvebu: Add check in coherency.c to prevent null pointer dereference Message-ID: References: <20240225060450.53044-1-duoming@zju.edu.cn> 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: <20240225060450.53044-1-duoming@zju.edu.cn> On Sun, Feb 25, 2024 at 02:04:50PM +0800, Duoming Zhou wrote: > The kzalloc() in armada_375_380_coherency_init() will return > null if the physical memory has run out. As a result, if we > dereference the property pointer, the null pointer dereference > bug will happen. > > This patch adds a check to avoid null pointer dereference. > > Fixes: 497a92308af8 ("ARM: mvebu: implement L2/PCIe deadlock workaround") > Signed-off-by: Duoming Zhou I have to wounder how we can run out of memory here. This code is being called from: postcore_initcall(coherency_late_init); If you look at: https://elixir.bootlin.com/linux/latest/source/include/linux/init.h#L299 You can see that only true kernel core stuff has been called before that. If that has consumed all the available memory, something is very seriously wrong, and the machine is not going to last another couple of milliseconds before it crashes no matter what checking you do. So i do wounder if your time could be better spent in other places? Andrew