linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Duoming Zhou <duoming@zju.edu.cn>,
	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
Date: Mon, 26 Feb 2024 14:08:31 +0000	[thread overview]
Message-ID: <ZdybX3aZo03iBduX@shell.armlinux.org.uk> (raw)
In-Reply-To: <eb036663-2109-4d75-8386-451fa5c34889@lunn.ch>

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 <duoming@zju.edu.cn>
> 
> 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

      reply	other threads:[~2024-02-26 14:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25  6:04 [PATCH] ARM: mvebu: Add check in coherency.c to prevent null pointer dereference Duoming Zhou
2024-02-25 11:30 ` Russell King (Oracle)
2024-02-25 13:20   ` duoming
2024-02-26 13:39 ` Andrew Lunn
2024-02-26 14:08   ` Russell King (Oracle) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZdybX3aZo03iBduX@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=duoming@zju.edu.cn \
    --cc=gregory.clement@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).