Skip to contentSkip to conversation

printk: finalize records with trailing newlines

PATCH In review John Ogness 3 participants 3 messages Nov 26, 2020 – Nov 27, 2020 Printk

lore
Share & tools
lore

John Ogness

author maintainer
#0 lore raw

PATCH 1/1 printk: finalize records with trailing newlines

Any record with a trailing newline (LOG_NEWLINE flag) cannot be continued because the newline has been stripped and will not be visible if the message is appended. This was already handled correctly when committing in log_output() but was not handled correctly when committing in log_store().

Fixes f5f022e53b87 ("printk: reimplement log_cont using record extension")

---
This is an important bugfix for continuous messages and should be part of the 5.10 release.

If not applied, newlines will vanish when concatenating continuous with trailing newlines.

 kernel/printk/printk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/printk/printk.c +2 -2
index fe64a49344bf..bc1e3b5a97bd 100644
@@ -528,8 +528,8 @@ static int log_store(u32 caller_id, int facility, int level,
 	if (dev_info)
 		memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info));
 
-	/* insert message */
-	if ((flags & LOG_CONT) || !(flags & LOG_NEWLINE))
+	/* A message without a trailing newline can be continued. */
+	if (!(flags & LOG_NEWLINE))
 		prb_commit(&e);
 	else
 		prb_final_commit(&e);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 6 lines · John Ogness

Any record with a trailing newline (LOG_NEWLINE flag) cannot be continued because the newline has been stripped and will not be visible if the message is appended. This was already handled correctly when committing in log_output() but was not handled correctly when committing in log_store().

Quoted 8 lines
Fixes f5f022e53b87 ("printk: reimplement log_cont using record extension")

---
This is an important bugfix for continuous messages and should be part of the 5.10 release.

If not applied, newlines will vanish when concatenating continuous with trailing newlines.

Thanks for you quick fix.

Reported-and-tested-by Kefeng Wang <[email protected]>
Quoted 18 lines
  kernel/printk/printk.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
kernel/printk/printk.c +2 -2
index fe64a49344bf..bc1e3b5a97bd 100644
@@ -528,8 +528,8 @@ static int log_store(u32 caller_id, int facility, int level,
  	if (dev_info)
  		memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info));
 
-	/* insert message */
-	if ((flags & LOG_CONT) || !(flags & LOG_NEWLINE))
+	/* A message without a trailing newline can be continued. */
+	if (!(flags & LOG_NEWLINE))
  		prb_commit(&e);
  	else
  		prb_final_commit(&e);
maintainer
#2 lore raw
Quoted 14 lines · Kefeng Wang
Quoted 12 lines · John Ogness

Any record with a trailing newline (LOG_NEWLINE flag) cannot be continued because the newline has been stripped and will not be visible if the message is appended. This was already handled correctly when committing in log_output() but was not handled correctly when committing in log_store().

Fixes f5f022e53b87 ("printk: reimplement log_cont using record extension")

---
This is an important bugfix for continuous messages and should be part of the 5.10 release.

Quoted 5 lines
Quoted 2 lines

If not applied, newlines will vanish when concatenating continuous with trailing newlines.

Thanks for you quick fix.

Reported-and-tested-by Kefeng Wang <[email protected]>

The patch is committed in printk/linux.git, branch for-5.10-pr_cont-fixup.

I do not have much experience with pushing fixes this late in the release cycle.

Normally, I would prefer to give it few days in linux-next. But the fix is quite trivial. And it would be better to have it in 10-rc6 rather than in rc7 that might be the last rc before release.

Thanks a lot for report, fix, and testing.

Best Regards,
Petr