linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] s390: Warn if kernel command line contains non-printable EBCDIC characters
@ 2026-08-26 15:06 Ilya Leoshkevich
  2026-08-26 15:18 ` sashiko-bot
  2026-08-26 15:38 ` Heiko Carstens
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2026-08-26 15:06 UTC (permalink / raw)
  To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
  Cc: David Laight, linux-s390, linux-kernel, Ilya Leoshkevich

Users may accidentally add multi-byte UTF-8 characters to zipl.conf
parmline, for example, by copying snippets containing non-breaking
spaces (\xC2\xA0) from web pages.

The kernel will then interpret the entire command line as EBCDIC,
making it unusable. Distinguish this situation from the legitimate
EBCDIC conversion by looking for non-printable characters and issue
a warning.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---

v1: https://lore.kernel.org/all/20260825150840.537653-1-iii@linux.ibm.com/
v1 -> v2: Account for newlines (Heiko).
          Minor stylistic improvements: inline int i, bool return type,
          comment modality.

 arch/s390/boot/ipl_parm.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
index 6bc950b92be76..6ea800ed98258 100644
--- a/arch/s390/boot/ipl_parm.c
+++ b/arch/s390/boot/ipl_parm.c
@@ -173,12 +173,30 @@ static inline int has_ebcdic_char(const char *str)
 	return 0;
 }
 
+static inline bool has_nonprintable_char(const char *str)
+{
+	for (int i = 0; str[i]; i++) {
+		unsigned char c = (unsigned char)str[i];
+
+		/*
+		 * Open-code ASCII range comparisons, since isprint() accepts
+		 * high Latin-1 bytes
+		 */
+		if ((c < 0x09 || c > 0x0d) && (c < 0x20 || c > 0x7e))
+			return true;
+	}
+	return false;
+}
+
 void setup_boot_command_line(void)
 {
 	parmarea.command_line[COMMAND_LINE_SIZE - 1] = 0;
 	/* convert arch command line to ascii if necessary */
-	if (has_ebcdic_char(parmarea.command_line))
+	if (has_ebcdic_char(parmarea.command_line)) {
 		EBCASC(parmarea.command_line, COMMAND_LINE_SIZE);
+		if (has_nonprintable_char(parmarea.command_line))
+			boot_warn("Kernel command line was treated as EBCDIC, but contains non-printable characters\n");
+	}
 	/* copy arch command line */
 	strscpy(early_command_line, strim(parmarea.command_line));
 
-- 
2.55.0


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

* Re: [PATCH v2] s390: Warn if kernel command line contains non-printable EBCDIC characters
  2026-08-26 15:06 [PATCH v2] s390: Warn if kernel command line contains non-printable EBCDIC characters Ilya Leoshkevich
@ 2026-08-26 15:18 ` sashiko-bot
  2026-08-26 15:38 ` Heiko Carstens
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-08-26 15:18 UTC (permalink / raw)
  To: Ilya Leoshkevich
  Cc: Alexander Gordeev, linux-s390, Vasily Gorbik,
	Christian Borntraeger, Heiko Carstens

> Users may accidentally add multi-byte UTF-8 characters to zipl.conf
> parmline, for example, by copying snippets containing non-breaking
> spaces (\xC2\xA0) from web pages.
> 
> The kernel will then interpret the entire command line as EBCDIC,
> making it unusable. Distinguish this situation from the legitimate
> EBCDIC conversion by looking for non-printable characters and issue
> a warning.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260826150702.949956-1-iii@linux.ibm.com?part=1


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

* Re: [PATCH v2] s390: Warn if kernel command line contains non-printable EBCDIC characters
  2026-08-26 15:06 [PATCH v2] s390: Warn if kernel command line contains non-printable EBCDIC characters Ilya Leoshkevich
  2026-08-26 15:18 ` sashiko-bot
@ 2026-08-26 15:38 ` Heiko Carstens
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Carstens @ 2026-08-26 15:38 UTC (permalink / raw)
  To: Ilya Leoshkevich
  Cc: Vasily Gorbik, Alexander Gordeev, David Laight, linux-s390,
	linux-kernel

On Wed, Aug 26, 2026 at 05:06:00PM +0200, Ilya Leoshkevich wrote:
> +static inline bool has_nonprintable_char(const char *str)
> +{
> +	for (int i = 0; str[i]; i++) {
> +		unsigned char c = (unsigned char)str[i];

What is the cast good for? Maybe this could be removed when applying.
Anyway, thanks!

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>

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

end of thread, other threads:[~2026-08-26 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 15:06 [PATCH v2] s390: Warn if kernel command line contains non-printable EBCDIC characters Ilya Leoshkevich
2026-08-26 15:18 ` sashiko-bot
2026-08-26 15:38 ` Heiko Carstens

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).