* [PATCH v1] powerpc: Fix off-by-one bug
@ 2026-11-14 20:10 Alejandro Colomar
2026-11-15 5:47 ` Ritesh Harjani
0 siblings, 1 reply; 3+ messages in thread
From: Alejandro Colomar @ 2026-11-14 20:10 UTC (permalink / raw)
To: linuxppc-dev
Cc: Alejandro Colomar, linux-hardening, alx+linux-hardening,
Nicholas Piggin, Mauricio Faria de Oliveira, Michael Neuling,
Michal Suchánek, Michael Ellerman, Linus Torvalds
[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]
From the surrounding similar calls, the intention seems obvious: this
seems intended to check for a prefix.
However, I do not understand this code, so take my reading with a grain
of salt.
Fixes: a048a07d7f453 ("powerpc/64s: Add support for a store forwarding barrier at kernel entry/exit")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
I found this while looking into replacing this code with calls to
strprefix().
arch/powerpc/kernel/security.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
index 600596cb4ffb..37999555bfe6 100644
--- a/arch/powerpc/kernel/security.c
+++ b/arch/powerpc/kernel/security.c
@@ -273,7 +273,7 @@ enum stf_barrier_type stf_barrier_type_get(void)
/* This is the generic flag used by other architectures */
static int __init handle_ssbd(char *p)
{
- if (!p || strncmp(p, "auto", 5) == 0 || strncmp(p, "on", 2) == 0 ) {
+ if (!p || strncmp(p, "auto", 4) == 0 || strncmp(p, "on", 2) == 0 ) {
/* Until firmware tells us, we have the barrier with auto */
return 0;
} else if (strncmp(p, "off", 3) == 0) {
--
2.55.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1] powerpc: Fix off-by-one bug
2026-11-14 20:10 [PATCH v1] powerpc: Fix off-by-one bug Alejandro Colomar
@ 2026-11-15 5:47 ` Ritesh Harjani
2026-11-15 8:09 ` Alejandro Colomar
0 siblings, 1 reply; 3+ messages in thread
From: Ritesh Harjani @ 2026-11-15 5:47 UTC (permalink / raw)
To: Alejandro Colomar, linuxppc-dev
Cc: Alejandro Colomar, linux-hardening, alx+linux-hardening,
Nicholas Piggin, Mauricio Faria de Oliveira, Michael Neuling,
Michal Suchánek, Michael Ellerman, Linus Torvalds
Alejandro Colomar <alx@kernel.org> writes:
> From the surrounding similar calls, the intention seems obvious: this
> seems intended to check for a prefix.
>
Could be, however the existing code is not functionally wrong either.
I agree it would have been nicer if all three were consistent. However,
x86 handles the same parameters with exact matches, so if anything "auto"
is the one doing the right thing here :)
But making "on"/"off" exact matches on powerpc now could change
behaviour for someone passing e.g. "offline" today, so I'd rather leave
those alone too.
> However, I do not understand this code, so take my reading with a grain
> of salt.
>
> Fixes: a048a07d7f453 ("powerpc/64s: Add support for a store forwarding barrier at kernel entry/exit")
IMHO, I don't think this patch fixes anything functional. So, I don't
think it will be correct to call this as: "Fix off-by-one bug" or
add fixes tag to it.
And so, I would suggest, we leave leave today's code as is, based on the
previous reasoning.
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
> ---
>
> I found this while looking into replacing this code with calls to
> strprefix().
>
For your conversion, I think, we should keep today's behaviour as is.
Maybe streq() for "auto" and strprefix() for "on" and "off", which means
there is is nothing to change or fix.
-ritesh
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] powerpc: Fix off-by-one bug
2026-11-15 5:47 ` Ritesh Harjani
@ 2026-11-15 8:09 ` Alejandro Colomar
0 siblings, 0 replies; 3+ messages in thread
From: Alejandro Colomar @ 2026-11-15 8:09 UTC (permalink / raw)
To: Ritesh Harjani
Cc: Alejandro Colomar, linuxppc-dev, linux-hardening, Nicholas Piggin,
Mauricio Faria de Oliveira, Michael Neuling, Michal Suchánek,
Michael Ellerman, Linus Torvalds
[-- Attachment #1: Type: text/plain, Size: 1673 bytes --]
Hi Ritesh,
> Date: 2026-11-15 11:17:37+0530
> From: Ritesh Harjani <ritesh.list@gmail.com>
>
> Alejandro Colomar <alx@kernel.org> writes:
>
> > From the surrounding similar calls, the intention seems obvious: this
> > seems intended to check for a prefix.
> >
>
> Could be, however the existing code is not functionally wrong either.
>
> I agree it would have been nicer if all three were consistent. However,
> x86 handles the same parameters with exact matches, so if anything "auto"
> is the one doing the right thing here :)
>
> But making "on"/"off" exact matches on powerpc now could change
> behaviour for someone passing e.g. "offline" today, so I'd rather leave
> those alone too.
>
> > However, I do not understand this code, so take my reading with a grain
> > of salt.
> >
> > Fixes: a048a07d7f453 ("powerpc/64s: Add support for a store forwarding barrier at kernel entry/exit")
>
> IMHO, I don't think this patch fixes anything functional. So, I don't
> think it will be correct to call this as: "Fix off-by-one bug" or
> add fixes tag to it.
> And so, I would suggest, we leave leave today's code as is, based on the
> previous reasoning.
>
> > Signed-off-by: Alejandro Colomar <alx@kernel.org>
> > ---
> >
> > I found this while looking into replacing this code with calls to
> > strprefix().
> >
>
> For your conversion, I think, we should keep today's behaviour as is.
> Maybe streq() for "auto" and strprefix() for "on" and "off", which means
> there is is nothing to change or fix.
Thanks! I'll do that.
Have a lovely day!
Alex
>
> -ritesh
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-15 8:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-14 20:10 [PATCH v1] powerpc: Fix off-by-one bug Alejandro Colomar
2026-11-15 5:47 ` Ritesh Harjani
2026-11-15 8:09 ` Alejandro Colomar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.