Re: [PATCH 7/8] powerpc/rtas: warn on unsafe argument to rtas_call_unlocked()
From: Andrew Donnellan <hidden>
Date: 2023-03-23 04:26:28
On Mon, 2023-03-06 at 15:33 -0600, Nathan Lynch via B4 Relay wrote:
From: Nathan Lynch <redacted> Any caller of rtas_call_unlocked() must provide an rtas_args parameter block distinct from the core rtas_args buffer used by the rtas_call() path. It's an unlikely error to make, but the potential consequences are grim, and it's trivial to check. Signed-off-by: Nathan Lynch <redacted>
call_rtas_display_status() seems to do exactly this, or am I missing something?
quoted hunk ↗ jump to hunk
--- arch/powerpc/kernel/rtas.c | 7 +++++++ 1 file changed, 7 insertions(+)diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index 633c925164e7..47a2aa43d7d4 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c@@ -1042,6 +1042,13 @@ void rtas_call_unlocked(struct rtas_args*args, int token, int nargs, int nret, { va_list list; + /* + * Callers must not use rtas_args; otherwise they risk + * corrupting the state of the rtas_call() path, which is + * serialized by rtas_lock. + */ + WARN_ON(args == &rtas_args); + va_start(list, nret); va_rtas_call(args, token, nargs, nret, list); va_end(list);
-- Andrew Donnellan OzLabs, ADL Canberra ajd@linux.ibm.com IBM Australia Limited