* [PATCH 5.15-rt] printk: ignore consoles without write() callback
@ 2023-02-16 10:39 John Ogness
2023-02-16 16:54 ` Sebastian Siewior
2025-04-23 10:10 ` [PATCH 5.15-rt] " Krishanth Jagaduri
0 siblings, 2 replies; 10+ messages in thread
From: John Ogness @ 2023-02-16 10:39 UTC (permalink / raw)
To: Clark Williams
Cc: Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
Michael Thalmeier, Vincent Whitchurch, Sebastian Siewior,
linux-kernel, linux-rt-users
The ttynull driver does not provide an implementation for the write()
callback. This leads to a NULL pointer dereference in the related
printing kthread, which assumes it can call that callback.
Do not create kthreads for consoles that do not implement the write()
callback. Also, for pr_flush(), ignore consoles that do not implement
write() or write_atomic() since there is no way those consoles can
flush their output.
Link: https://lore.kernel.org/lkml/878rgy37f5.fsf@jogness.linutronix.de
Fixes: 8782b1ef4125 ("printk: move console printing to kthreads")
Reported-by: Michael Thalmeier <michael.thalmeier@hale.at>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
This is only a problem for the PREEMPT_RT tree. Mainline does not have
this problem.
kernel/printk/printk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 7f27cfee283e..752afe88b5b4 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2343,6 +2343,10 @@ static int printk_kthread_func(void *data)
/* Must be called within console_lock(). */
static void start_printk_kthread(struct console *con)
{
+ /* No need to start a printing thread if the console cannot print. */
+ if (!con->write)
+ return;
+
con->thread = kthread_run(printk_kthread_func, con,
"pr/%s%d", con->name, con->index);
if (IS_ERR(con->thread)) {
@@ -3737,6 +3741,8 @@ bool pr_flush(int timeout_ms, bool reset_on_progress)
for_each_console(con) {
if (!(con->flags & CON_ENABLED))
continue;
+ if (!con->write && !con->write_atomic)
+ continue;
printk_seq = read_console_seq(con);
if (printk_seq < seq)
diff += seq - printk_seq;
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 5.15-rt] printk: ignore consoles without write() callback
2023-02-16 10:39 [PATCH 5.15-rt] printk: ignore consoles without write() callback John Ogness
@ 2023-02-16 16:54 ` Sebastian Siewior
2023-02-17 8:45 ` John Ogness
2025-04-23 10:10 ` [PATCH 5.15-rt] " Krishanth Jagaduri
1 sibling, 1 reply; 10+ messages in thread
From: Sebastian Siewior @ 2023-02-16 16:54 UTC (permalink / raw)
To: John Ogness
Cc: Clark Williams, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
Michael Thalmeier, Vincent Whitchurch, linux-kernel,
linux-rt-users
On 2023-02-16 11:45:58 [+0106], John Ogness wrote:
> This is only a problem for the PREEMPT_RT tree. Mainline does not have
> this problem.
Is this 5.15 and less or current dev RT and less?
Sebastian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 5.15-rt] printk: ignore consoles without write() callback
2023-02-16 16:54 ` Sebastian Siewior
@ 2023-02-17 8:45 ` John Ogness
2023-02-17 8:47 ` [PATCH 5.10-rt] " John Ogness
0 siblings, 1 reply; 10+ messages in thread
From: John Ogness @ 2023-02-17 8:45 UTC (permalink / raw)
To: Sebastian Siewior
Cc: Clark Williams, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
Michael Thalmeier, Vincent Whitchurch, linux-kernel,
linux-rt-users
On 2023-02-16, Sebastian Siewior <bigeasy@linutronix.de> wrote:
>> This is only a problem for the PREEMPT_RT tree. Mainline does not have
>> this problem.
>
> Is this 5.15 and less or current dev RT and less?
5.10-rt is also affected. The changes for 5.10-rt are the same, but the
patch does not apply as-is. I will reply with a patch for 5.10-rt.
5.4-rt is not affected.
John Ogness
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5.10-rt] printk: ignore consoles without write() callback
2023-02-17 8:45 ` John Ogness
@ 2023-02-17 8:47 ` John Ogness
2023-02-17 11:55 ` Luis Claudio R. Goncalves
0 siblings, 1 reply; 10+ messages in thread
From: John Ogness @ 2023-02-17 8:47 UTC (permalink / raw)
To: Sebastian Siewior
Cc: Clark Williams, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
Michael Thalmeier, Vincent Whitchurch, linux-kernel,
linux-rt-users, Luis Claudio R. Goncalves
The ttynull driver does not provide an implementation for the write()
callback. This leads to a NULL pointer dereference in the related
printing kthread, which assumes it can call that callback.
Do not create kthreads for consoles that do not implement the write()
callback. Also, for pr_flush(), ignore consoles that do not implement
write() or write_atomic(), since there is no way those consoles can
flush their output.
Link: https://lore.kernel.org/lkml/1831554214.546921.1676479103702.JavaMail.zimbra@hale.at
Reported-by: Michael Thalmeier <michael.thalmeier@hale.at>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/printk/printk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index d2205872304d..64747c72fbea 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2267,6 +2267,10 @@ static int printk_kthread_func(void *data)
/* Must be called within console_lock(). */
static void start_printk_kthread(struct console *con)
{
+ /* No need to start a printing thread if the console cannot print. */
+ if (!con->write)
+ return;
+
con->thread = kthread_run(printk_kthread_func, con,
"pr/%s%d", con->name, con->index);
if (IS_ERR(con->thread)) {
@@ -3566,6 +3570,8 @@ bool pr_flush(int timeout_ms, bool reset_on_progress)
for_each_console(con) {
if (!(con->flags & CON_ENABLED))
continue;
+ if (!con->write && !con->write_atomic)
+ continue;
printk_seq = atomic64_read(&con->printk_seq);
if (printk_seq < seq)
diff += seq - printk_seq;
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 5.10-rt] printk: ignore consoles without write() callback
2023-02-17 8:47 ` [PATCH 5.10-rt] " John Ogness
@ 2023-02-17 11:55 ` Luis Claudio R. Goncalves
0 siblings, 0 replies; 10+ messages in thread
From: Luis Claudio R. Goncalves @ 2023-02-17 11:55 UTC (permalink / raw)
To: John Ogness
Cc: Sebastian Siewior, Clark Williams, Petr Mladek,
Sergey Senozhatsky, Steven Rostedt, Michael Thalmeier,
Vincent Whitchurch, linux-kernel, linux-rt-users
On Fri, Feb 17, 2023 at 09:53:44AM +0106, John Ogness wrote:
> The ttynull driver does not provide an implementation for the write()
> callback. This leads to a NULL pointer dereference in the related
> printing kthread, which assumes it can call that callback.
>
> Do not create kthreads for consoles that do not implement the write()
> callback. Also, for pr_flush(), ignore consoles that do not implement
> write() or write_atomic(), since there is no way those consoles can
> flush their output.
>
> Link: https://lore.kernel.org/lkml/1831554214.546921.1676479103702.JavaMail.zimbra@hale.at
> Reported-by: Michael Thalmeier <michael.thalmeier@hale.at>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
Thank you! I will apply that to the next 5.10-rt build.
Luis
> ---
> kernel/printk/printk.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index d2205872304d..64747c72fbea 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2267,6 +2267,10 @@ static int printk_kthread_func(void *data)
> /* Must be called within console_lock(). */
> static void start_printk_kthread(struct console *con)
> {
> + /* No need to start a printing thread if the console cannot print. */
> + if (!con->write)
> + return;
> +
> con->thread = kthread_run(printk_kthread_func, con,
> "pr/%s%d", con->name, con->index);
> if (IS_ERR(con->thread)) {
> @@ -3566,6 +3570,8 @@ bool pr_flush(int timeout_ms, bool reset_on_progress)
> for_each_console(con) {
> if (!(con->flags & CON_ENABLED))
> continue;
> + if (!con->write && !con->write_atomic)
> + continue;
> printk_seq = atomic64_read(&con->printk_seq);
> if (printk_seq < seq)
> diff += seq - printk_seq;
> --
> 2.30.2
>
---end quoted text---
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 5.15-rt] printk: ignore consoles without write() callback
2023-02-16 10:39 [PATCH 5.15-rt] printk: ignore consoles without write() callback John Ogness
2023-02-16 16:54 ` Sebastian Siewior
@ 2025-04-23 10:10 ` Krishanth Jagaduri
2025-04-28 14:45 ` [External] : " Joseph Salisbury
1 sibling, 1 reply; 10+ messages in thread
From: Krishanth Jagaduri @ 2025-04-23 10:10 UTC (permalink / raw)
To: John Ogness, Joseph Salisbury
Cc: Clark Williams, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
Michael Thalmeier, Vincent Whitchurch, Sebastian Siewior,
linux-kernel, linux-rt-users, Kento.A.Kobayashi, Daniel.Palmer
On Thu, Feb 16, 2023 at 11:45:58AM +0106, John Ogness wrote:
> The ttynull driver does not provide an implementation for the write()
> callback. This leads to a NULL pointer dereference in the related
> printing kthread, which assumes it can call that callback.
>
> Do not create kthreads for consoles that do not implement the write()
> callback. Also, for pr_flush(), ignore consoles that do not implement
> write() or write_atomic() since there is no way those consoles can
> flush their output.
>
> ---
> This is only a problem for the PREEMPT_RT tree. Mainline does not have
> this problem.
Sorry for resurrecting this old thread but we actually want this patch
in 5.15-rt.
I am not sure why this was not applied to 5.15-rt yet since it is already
applied to 5.10-rt.
Could you please consider to pick this for 5.15-rt?
Best regards,
Krishanth
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [External] : Re: [PATCH 5.15-rt] printk: ignore consoles without write() callback
2025-04-23 10:10 ` [PATCH 5.15-rt] " Krishanth Jagaduri
@ 2025-04-28 14:45 ` Joseph Salisbury
2025-05-21 12:30 ` Krishanth Jagaduri
0 siblings, 1 reply; 10+ messages in thread
From: Joseph Salisbury @ 2025-04-28 14:45 UTC (permalink / raw)
To: Krishanth Jagaduri, John Ogness
Cc: Clark Williams, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
Michael Thalmeier, Vincent Whitchurch, Sebastian Siewior,
linux-kernel, linux-rt-users, Kento.A.Kobayashi, Daniel.Palmer
On 4/23/25 06:10, Krishanth Jagaduri wrote:
> On Thu, Feb 16, 2023 at 11:45:58AM +0106, John Ogness wrote:
>> The ttynull driver does not provide an implementation for the write()
>> callback. This leads to a NULL pointer dereference in the related
>> printing kthread, which assumes it can call that callback.
>>
>> Do not create kthreads for consoles that do not implement the write()
>> callback. Also, for pr_flush(), ignore consoles that do not implement
>> write() or write_atomic() since there is no way those consoles can
>> flush their output.
>>
>> ---
>> This is only a problem for the PREEMPT_RT tree. Mainline does not have
>> this problem.
> Sorry for resurrecting this old thread but we actually want this patch
> in 5.15-rt.
>
> I am not sure why this was not applied to 5.15-rt yet since it is already
> applied to 5.10-rt.
>
> Could you please consider to pick this for 5.15-rt?
>
> Best regards,
> Krishanth
Hi Krishanth,
Thanks for pointing this out. I will investigate including this patch
in the next v5.15 patch set, which should be released this week.
Thanks,
Joe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [External] : Re: [PATCH 5.15-rt] printk: ignore consoles without write() callback
2025-04-28 14:45 ` [External] : " Joseph Salisbury
@ 2025-05-21 12:30 ` Krishanth Jagaduri
2025-05-21 15:32 ` Joseph Salisbury
0 siblings, 1 reply; 10+ messages in thread
From: Krishanth Jagaduri @ 2025-05-21 12:30 UTC (permalink / raw)
To: Joseph Salisbury
Cc: John Ogness, Clark Williams, Petr Mladek, Sergey Senozhatsky,
Steven Rostedt, Michael Thalmeier, Vincent Whitchurch,
Sebastian Siewior, linux-kernel, linux-rt-users,
Kento.A.Kobayashi, Daniel.Palmer
On Mon, Apr 28, 2025 at 10:45:08AM -0400, Joseph Salisbury wrote:
> Hi Krishanth,
>
> Thanks for pointing this out. I will investigate including this patch in
> the next v5.15 patch set, which should be released this week.
>
> Thanks,
>
> Joe
Thank you for including this patch in v5.15.183-rt85.
Best regards,
Krishanth
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [External] : Re: [PATCH 5.15-rt] printk: ignore consoles without write() callback
2025-05-21 12:30 ` Krishanth Jagaduri
@ 2025-05-21 15:32 ` Joseph Salisbury
2025-05-23 5:05 ` Krishanth Jagaduri
0 siblings, 1 reply; 10+ messages in thread
From: Joseph Salisbury @ 2025-05-21 15:32 UTC (permalink / raw)
To: Krishanth Jagaduri
Cc: John Ogness, Clark Williams, Petr Mladek, Sergey Senozhatsky,
Steven Rostedt, Michael Thalmeier, Vincent Whitchurch,
Sebastian Siewior, linux-kernel, linux-rt-users,
Kento.A.Kobayashi, Daniel.Palmer
On 5/21/25 08:30, Krishanth Jagaduri wrote:
> On Mon, Apr 28, 2025 at 10:45:08AM -0400, Joseph Salisbury wrote:
>> Hi Krishanth,
>>
>> Thanks for pointing this out. I will investigate including this patch in
>> the next v5.15 patch set, which should be released this week.
>>
>> Thanks,
>>
>> Joe
> Thank you for including this patch in v5.15.183-rt85.
>
> Best regards,
> Krishanth
Not a problem, Krishanth! Just let me know if you run into any issues.
Thanks,
Joe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [External] : Re: [PATCH 5.15-rt] printk: ignore consoles without write() callback
2025-05-21 15:32 ` Joseph Salisbury
@ 2025-05-23 5:05 ` Krishanth Jagaduri
0 siblings, 0 replies; 10+ messages in thread
From: Krishanth Jagaduri @ 2025-05-23 5:05 UTC (permalink / raw)
To: Joseph Salisbury
Cc: John Ogness, Clark Williams, Petr Mladek, Sergey Senozhatsky,
Steven Rostedt, Michael Thalmeier, Vincent Whitchurch,
Sebastian Siewior, linux-kernel, linux-rt-users,
Kento.A.Kobayashi, Daniel.Palmer
On Wed, May 21, 2025 at 11:32:54AM -0400, Joseph Salisbury wrote:
>
>
> On 5/21/25 08:30, Krishanth Jagaduri wrote:
> > On Mon, Apr 28, 2025 at 10:45:08AM -0400, Joseph Salisbury wrote:
> > > Hi Krishanth,
> > >
> > > Thanks for pointing this out. I will investigate including this patch in
> > > the next v5.15 patch set, which should be released this week.
> > >
> > > Thanks,
> > >
> > > Joe
> > Thank you for including this patch in v5.15.183-rt85.
> >
> > Best regards,
> > Krishanth
> Not a problem, Krishanth! Just let me know if you run into any issues.
>
> Thanks,
>
> Joe
>
Sure, I will let you know if any.
Best regards,
Krishanth
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-05-23 5:07 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16 10:39 [PATCH 5.15-rt] printk: ignore consoles without write() callback John Ogness
2023-02-16 16:54 ` Sebastian Siewior
2023-02-17 8:45 ` John Ogness
2023-02-17 8:47 ` [PATCH 5.10-rt] " John Ogness
2023-02-17 11:55 ` Luis Claudio R. Goncalves
2025-04-23 10:10 ` [PATCH 5.15-rt] " Krishanth Jagaduri
2025-04-28 14:45 ` [External] : " Joseph Salisbury
2025-05-21 12:30 ` Krishanth Jagaduri
2025-05-21 15:32 ` Joseph Salisbury
2025-05-23 5:05 ` Krishanth Jagaduri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).