From: Jiri Slaby <jirislaby@kernel.org>
To: Jing Wu <realwujing@gmail.com>
Cc: gregkh@linuxfoundation.org, avorontsov@ru.mvista.com,
alan@redhat.com, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, wangzhaolong@fnnas.com
Subject: Re: [PATCH v5] serial: 8250: fix use-after-free in IRQ chain handling
Date: Thu, 25 Jun 2026 06:38:35 +0200 [thread overview]
Message-ID: <80f44ace-9231-4b4e-9e47-cbe49b3e2d3e@kernel.org> (raw)
In-Reply-To: <20260624084352.2978059-1-realwujing@gmail.com>
On 24. 06. 26, 10:43, Jing Wu wrote:
> From: Qiliang Yuan <realwujing@gmail.com>
>
> On Wed, Jun 24, 2026 at 05:31:59AM +0200, Jiri Slaby wrote:
>> So what is the reason to switch from guards to manual locking?
>
> Scope-based guards release the lock at the end of the enclosing block,
> but the fix requires hash_mutex to be held across request_irq() and
> released at different exit points:
>
> 1. IS_ERR(i) -- release hash_mutex and return error.
> 2. Already in chain -- release i->lock, release hash_mutex, return 0.
> 3. First port, request_irq() fails -- cleanup under hash_mutex, then
> release it and return error.
> 4. First port, request_irq() succeeds -- release hash_mutex, return 0.
>
> These paths span different nesting levels and early returns, so scope
> guards cannot express the required lock lifecycle. The same applies to
> i->lock: it must be dropped before calling request_irq() (cannot hold a
> spinlock while sleeping), but hash_mutex must remain held across the
> call, which also breaks the guard model.
I don't follow, the function now looks like this:
mutex_lock(&hash_mutex);
i = serial_get_or_create_irq_info(up);
if (IS_ERR(i)) {
mutex_unlock(&hash_mutex);
return PTR_ERR(i);
}
/*
...
*/
spin_lock_irq(&i->lock);
if (i->head) {
list_add(&up->list, i->head);
spin_unlock_irq(&i->lock);
mutex_unlock(&hash_mutex);
return 0;
}
INIT_LIST_HEAD(&up->list);
i->head = &up->list;
spin_unlock_irq(&i->lock);
ret = request_irq(up->port.irq, serial8250_interrupt,
up->port.irqflags, up->port.name, i);
if (ret < 0) {
serial_do_unlink(i, up);
mutex_unlock(&hash_mutex);
return ret;
}
mutex_unlock(&hash_mutex);
return 0;
What am I missing?
thanks,
--
js
suse labs
prev parent reply other threads:[~2026-06-25 4:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 1:21 [PATCH v5] serial: 8250: fix use-after-free in IRQ chain handling Qiliang Yuan
2026-06-24 3:31 ` Jiri Slaby
2026-06-24 8:43 ` Jing Wu
2026-06-25 4:38 ` Jiri Slaby [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=80f44ace-9231-4b4e-9e47-cbe49b3e2d3e@kernel.org \
--to=jirislaby@kernel.org \
--cc=alan@redhat.com \
--cc=avorontsov@ru.mvista.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=realwujing@gmail.com \
--cc=wangzhaolong@fnnas.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