[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87v7j997g8.ffs@tglx>
Date: Sun, 16 Nov 2025 19:08:07 +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 Sun, Nov 16 2025 at 00:18, Thomas Gleixner wrote:
> 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.
That said. You clearly failed to explain how you found that. I'm well
aware that you are deeply involved in LLM based code analysis, so don't
tell me that reviewing random code is your new hobby.
Thanks,
tglx
Powered by blists - more mailing lists