Re: [PATCH] x86/boot/compressed: Fix signedness of rdfs8()
From: H. Peter Anvin
Date: Wed Feb 18 2026 - 18:51:32 EST
On February 18, 2026 7:00:08 AM PST, redacherkaoui <redacherkaoui67@xxxxxxxxx> wrote:
>rdfs8() reads a raw byte from the decompressor command line buffer but
>returns it as 'char'. On toolchains where 'char' is signed, values in
>the range 0x80..0xff become negative when promoted, which can lead to
>incorrect comparisons while parsing.
>
>Return u8 from rdfs8() to preserve the correct byte value.
>
>Signed-off-by: redacherkaoui <redacherkaoui67@xxxxxxxxx>
>---
> arch/x86/boot/compressed/cmdline.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
>diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
>index e162d7f59cc5..d48ba959dbc5 100644
>--- a/arch/x86/boot/compressed/cmdline.c
>+++ b/arch/x86/boot/compressed/cmdline.c
>@@ -8,13 +8,16 @@ static inline void set_fs(unsigned long seg)
> {
> fs = seg << 4; /* shift it back */
> }
>+
> typedef unsigned long addr_t;
>-static inline char rdfs8(addr_t addr)
>+static inline u8 rdfs8(addr_t addr)
> {
>- return *((char *)(fs + addr));
>+ return *(u8 *)(fs + addr);
> }
>+
> #include "../cmdline.c"
>-unsigned long get_cmd_line_ptr(void)
>+
>+static unsigned long get_cmd_line_ptr(void)
> {
> unsigned long cmd_line_ptr = boot_params_ptr->hdr.cmd_line_ptr;
>
>@@ -22,10 +25,12 @@ unsigned long get_cmd_line_ptr(void)
>
> return cmd_line_ptr;
> }
>+
> int cmdline_find_option(const char *option, char *buffer, int bufsize)
> {
> return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize);
> }
>+
> int cmdline_find_option_bool(const char *option)
> {
> return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
What toolchains are that *for x86*?!
This code is about to change substantially, but it wouldn't hurt to make it "unsigned char" or to include the appropriate header.