[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bjl2anrb.ffs@tglx>
Date: Sun, 16 Nov 2025 00:18:16 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: Haotian Zhang <vulab@...as.ac.cn>, Andrew Morton
<akpm@...ux-foundation.org>, Kuan-Wei Chiu <visitorckw@...il.com>
Cc: linux-kernel@...r.kernel.org, Haotian Zhang <vulab@...as.ac.cn>
Subject: Re: [PATCH v3] debugobjects: Fix inconsistent return handling and
potential ERR_PTR dereference
On Fri, Nov 14 2025 at 09:56, Haotian Zhang wrote:
> The lookup_object_or_alloc() function can return NULL on memory
> allocation failure, while returning an error pointer for other errors.
> Call sites such as __debug_object_init() and debug_object_activate()
> only check for errors using IS_ERR(), which does not evaluate to true
> for a NULL pointer. This can lead to a NULL pointer dereference if
> memory allocation fails.
Nice fairy tale. Let's look at the facts.
__debug_object_init():
obj = lookup_object_or_alloc(addr, db, descr, onstack, false);
if (unlikely(!obj)) {
....
Does not use IS_ERR() at all and _is_ completely correct because
lookup_object_or_alloc() can only return NULL or a valid object but
never an error pointer because the 'alloc_ifstatic' argument is NULL.
debug_object_activate():
obj = lookup_object_or_alloc(addr, db, descr, false, true);
if (unlikely(!obj)) {
....
} else if (likely(!IS_ERR(obj))) {
....
handles both the NULL pointer and the error pointer case correctly.
I have no idea which code you were analyzing or which tool halluzinated
about it.
> Fixes: 63a759694eed ("debugobject: Prevent init race with static objects")
There is nothing broken, so this fixes nothing.
Thanks,
tglx
Powered by blists - more mailing lists