From: Markus Probst <markus.probst@posteo.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Ayush Singh" <ayush@beagleboard.org>,
"Johan Hovold" <johan@kernel.org>,
"Alex Elder" <elder@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Eric Biggers" <ebiggers@kernel.org>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Uladzislau Rezki" <urezki@gmail.com>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
greybus-dev@lists.linaro.org, linux-serial@vger.kernel.org,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
driver-core@lists.linux.dev
Subject: Re: [PATCH v4 1/4] tty: serdev: Add mutex lock
Date: Thu, 22 Oct 2026 12:45:37 +0000 [thread overview]
Message-ID: <c7b9e8ccbf41410a5ac13fc4d78104e595a5fbbd.camel@posteo.de> (raw)
In-Reply-To: <2026101758-confidant-comprised-e1c0@gregkh>
[-- Attachment #1: Type: text/plain, Size: 2431 bytes --]
On Sat, 2026-10-17 at 09:53 +0200, Greg Kroah-Hartman wrote:
> On Fri, Oct 16, 2026 at 06:00:32PM +0000, Markus Probst wrote:
> > Besides more predictable behaviour, this allows for several hardened
> > behaviour changes:
> >
> > Return -EALREADY in `serdev_device_open` if the device is already open
> > instead of causing undefined behaviour.
> >
> > Allow calling `serdev_device_close`, even if the device is already
> > closed instead of causing a null pointer dereference.
> >
> > If the device is left open by the driver after remove, close it and warn
> > instead of leaving it in a invalid state.
> >
> > Signed-off-by: Markus Probst <markus.probst@posteo.de>
> > ---
> > drivers/tty/serdev/core.c | 10 +++++---
> > drivers/tty/serdev/serdev-ttyport.c | 46 +++++++++++++++++++++++++++++++------
> > include/linux/serdev.h | 2 +-
> > 3 files changed, 47 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> > index 7500efcdfc21..77e8e1d4d2a6 100644
> > --- a/drivers/tty/serdev/core.c
> > +++ b/drivers/tty/serdev/core.c
> > @@ -142,6 +142,11 @@ void serdev_device_remove(struct serdev_device *serdev)
> > struct serdev_controller *ctrl = serdev->ctrl;
> >
> > device_unregister(&serdev->dev);
> > +
> > + /* Warn if driver did not close the serial device. */
> > + if (ctrl->ops->close && WARN_ON(ctrl->ops->close(ctrl)))
>
> I understand the want to give a big "splat" if this happens, but if it
> does somehow, you just crashed the box due to panic-on-warn, which will
> result in a CVE being given :)
>
> So, if this ever can happen, we should recover like you do:
>
> > + pm_runtime_put(&ctrl->dev);
>
> And you can warn about it in the kernel log, but just not with WARN_ON()
> please.
To be honest, I forgot about this review and sent v5 without taking it
into account.
Anyway, I looked into documentation.
"WARN*() is intended for unexpected, this-should-never-happen
situations. [...] However, the existence of panic_on_warn users is not
a valid reason to avoid the judicious use WARN*()." [1]
I think this is a valid case.
It is an event that should never happen, and it might cause a use-
after-free vulnerability on data reception.
Thanks
- Markus Probst
[1] https://docs.kernel.org/process/coding-style.html
>
> thanks,
>
> greg k-h
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 870 bytes --]
next prev parent reply other threads:[~2026-10-22 12:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 18:00 [PATCH v4 0/4] rust: serdev: Refactor Markus Probst
2026-10-16 18:00 ` [PATCH v4 1/4] tty: serdev: Add mutex lock Markus Probst
2026-10-17 7:53 ` Greg Kroah-Hartman
2026-10-22 12:45 ` Markus Probst [this message]
2026-10-17 7:55 ` Greg Kroah-Hartman
2026-10-17 10:49 ` Markus Probst
2026-10-16 18:00 ` [PATCH v4 2/4] tty: serdev: Export functions to pause receive_buf callback calls Markus Probst
2026-10-16 18:00 ` [PATCH v4 3/4] rust: serdev: Replace `active` mutex with receive pause Markus Probst
2026-10-16 18:00 ` [PATCH v4 4/4] rust: serdev: Simplify callbacks Markus Probst
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=c7b9e8ccbf41410a5ac13fc4d78104e595a5fbbd.camel@posteo.de \
--to=markus.probst@posteo.de \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=ardb@kernel.org \
--cc=ayush@beagleboard.org \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=ebiggers@kernel.org \
--cc=elder@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=jirislaby@kernel.org \
--cc=johan@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=urezki@gmail.com \
--cc=vbabka@kernel.org \
--cc=work@onurozkan.dev \
/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
all inboxes | Powered by JetHome®