mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tty: ttynull: implement console write
@ 2023-02-14 10:23 Michael Thalmeier
  2023-02-14 10:50 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Thalmeier @ 2023-02-14 10:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Vincent Whitchurch; +Cc: linux-kernel

Since commit 3579b59c7edc475013ae769a2d26d99733c95f13 ("printk: refactor
and rework printing logic"), con->write is called without checking if it
is implemented in the console driver. This does make some sense, because
for all "normal" consoles it is vital to have a write function.
As the ttynull console driver does not need any console output the write
function was not implemented. This caused a "unable to handle kernel NULL
pointer dereference" when the write function is called now.

To fix this issue, implement an empty write function.

Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
Cc: stable@vger.kernel.org
---
 drivers/tty/ttynull.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/tty/ttynull.c b/drivers/tty/ttynull.c
index 1d4438472442..6e9323544a7d 100644
--- a/drivers/tty/ttynull.c
+++ b/drivers/tty/ttynull.c
@@ -40,6 +40,12 @@ static unsigned int ttynull_write_room(struct tty_struct *tty)
 	return 65536;
 }
 
+
+static void ttynull_console_write(struct console *co, const char *buf,
+				  unsigned count)
+{
+}
+
 static const struct tty_operations ttynull_ops = {
 	.open = ttynull_open,
 	.close = ttynull_close,
@@ -56,6 +62,7 @@ static struct tty_driver *ttynull_device(struct console *c, int *index)
 
 static struct console ttynull_console = {
 	.name = "ttynull",
+	.write = ttynull_console_write,
 	.device = ttynull_device,
 };
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tty: ttynull: implement console write
  2023-02-14 10:23 [PATCH] tty: ttynull: implement console write Michael Thalmeier
@ 2023-02-14 10:50 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-14 10:50 UTC (permalink / raw)
  To: Michael Thalmeier; +Cc: Jiri Slaby, Vincent Whitchurch, linux-kernel

On Tue, Feb 14, 2023 at 11:23:17AM +0100, Michael Thalmeier wrote:
> Since commit 3579b59c7edc475013ae769a2d26d99733c95f13 ("printk: refactor

Nit, sha ids should only be 12 digits, as per the kernel documentation,
can you fix that up?

And wait, that's not even a commit id, are you sure that is correct?

> and rework printing logic"), con->write is called without checking if it
> is implemented in the console driver. This does make some sense, because
> for all "normal" consoles it is vital to have a write function.
> As the ttynull console driver does not need any console output the write
> function was not implemented. This caused a "unable to handle kernel NULL
> pointer dereference" when the write function is called now.
> 
> To fix this issue, implement an empty write function.
> 
> Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
> Cc: stable@vger.kernel.org

Adding a Fixes: tag here would also be good to have.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-14 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 10:23 [PATCH] tty: ttynull: implement console write Michael Thalmeier
2023-02-14 10:50 ` Greg Kroah-Hartman

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®