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 91590C48BF6 for ; Mon, 26 Feb 2024 14:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q6Bf0pHu47sb/wDBUIdkVKDRiudW8Ki/FqCcjPp/8Qw=; b=h1SbF/puBVJ/CD A2iF8bnaIeyvZtTbDgKlKOMulQN3bwhmu9xO+o5aSbc0+ejSsgUz5zt8rbzaWQkfiF/RVOVSUNbaV VZWjlxcNu2yXmQEg8RVNCWc+OgwY4eFThSjs1eVkYWwBVWivhIpd+8kxY6iGKz4xdPVjxGdTWkZbM tjxpkkFIp5QwWADZtnQWXLNabJupM09Zkg7wwmZA/7FKxAlIuu9QVkjoOiuvWq44AzASWgDYCsn1s vQ9Nn6TDwFntUf9+Stm3dTe6oL30JFxOTCQzjMrC8HEarv69DvLJfkNT65JGnvrzgV/Xxyksq7Yy2 sT1nPM6V8DnYaK937sKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rebfH-000000011vF-3eRH; Mon, 26 Feb 2024 14:09:07 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rebeq-000000011jF-3TJu for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2024 14:08:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender: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-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=og2C+QX7RdSlbChapFxZDOWO2lHc9kddFG0iUeGvz80=; b=LMs55jDIZ7LjCFTkYTM16KODR0 rs+IF/4TFSxK38WAgChMtiHyk/uWUpg8ePGc2+PF74DCejyob9Ea1TCJXIgYlGbrnx5pYiSXk5kpB 9JqGM9d7qm/MTpkNQoaGkECzg27H4EmIwVeHKGdJ/HMvhTj3Z587BwloRthVY7Iz5vjgwFwPOUnwJ ogg1G1X5PWCxYWwWeKmTQ0zkc/O1nl7Ocqll5Lo19SuuugjUXfRib5NyjjBklYpYzTczPzwUJLLYe XVQTd8KMkMaVfyN/UCWLSq+8Xl6Vc+lG9BE32sKHBq3tnnhYRg5xPd2u2P/URDvCORm/K7YXItTmW UMTWwMnA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:33800) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rebel-0003jA-15; Mon, 26 Feb 2024 14:08:35 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rebeh-0006U3-UY; Mon, 26 Feb 2024 14:08:31 +0000 Date: Mon, 26 Feb 2024 14:08:31 +0000 From: "Russell King (Oracle)" To: Andrew Lunn Cc: Duoming Zhou , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240226_060840_964554_9E7F43B5 X-CRM114-Status: GOOD ( 26.03 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Feb 26, 2024 at 02:39:37PM +0100, Andrew Lunn wrote: > 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? Sadly, it's an easy patch generation target for newbies getting involved with kernel development. "Find all kzalloc()s and look to see whether they check for a NULL pointer, if not generate a patch". This results in people doing exactly that, not looking at the bigger picture, and not considering whether a NULL pointer could occur there. The other issue is that if a NULL pointer is returned at this point, the resulting oops at least allows a developer to debug it (maybe not a user if the console isn't up.) Adding this patch which basically just continues the loop silently means that there's no diagnostic that something went wrong, and it's up to someone to figure out "why does XYZ no longer work" to figure it out... -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel