arm64: signal: don't force known signals to SIGKILL
Mark Rutland
reviewerPATCH 1/1 arm64: signal: don't force known signals to SIGKILL
Since commit:
a7e6f1ca90354a31 ("arm64: signal: Force SIGKILL for unknown signals in force_signal_inject")
... any signal which is not SIGKILL will be upgraded to a SIGKILL be force_signal_inject(). This includes signals we do expect, such as SIGILL triggered by do_undefinstr().
Fix the check to use a logical AND rather than a logical OR, permitting signals whose layout is SIL_FAULT.
--- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/traps.c +1 -1
@@ -366,7 +366,7 @@ void force_signal_inject(int signal, int code, unsigned long address) }/* Force signals we don't understand to SIGKILL */ -if (WARN_ON (signal !=SIGKILL || +if (WARN_ON (signal !=SIGKILL &&siginfo_layout (signal, code) !=SIL_FAULT )) { signal =SIGKILL ; }
Signature · 1 line
2.11.0
PATCH 1/1 arm64: signal: don't force known signals to SIGKILL
Quoted 25 lines · Mark Rutland
Since commit:
a7e6f1ca90354a31("arm64: signal: Force SIGKILL for unknown signals inforce_signal_inject")... any signal which is not SIGKILL will be upgraded to a SIGKILL be
force_signal_inject(). This includes signals we do expect, such as SIGILL triggered bydo_undefinstr().Fix the check to use a logical AND rather than a logical OR, permitting signals whose layout is
SIL_FAULT.Signed-off-by Mark Rutland <[email protected]>Fixes a7e6f1ca90354a31 ("arm64: signal: Force SIGKILL for unknown signals in force_signal_inject")Cc Catalin Marinas <[email protected]>Cc Dave Martin <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kernel/traps.c +0
-0
arch/arm64/kernel/traps.c void force_signal_inject(int signal, int code, unsigned long address) · line 368
Quoted 3 lines
arch/arm64/kernel/traps.c +0
-0@@ -366,7 +366,7 @@ void force_signal_inject(int signal, int code, unsigned long address) }/* Force signals we don't understand to SIGKILL */
Is it worth updating the comment here?
What's the rationale for this check?
IIRC the purpose of this is to ensure that any siginfo delivered to userspace through this path is initialised correctly: so, either the signal must be a SIL_FAULT signal (since that's what the subsequent code initialises for) or SIGKILL (since userspace can't inspect the siginfo post-mortem, so the initialisation doesn't matter in that case).
Maybe moving this check before the switch() would make the logic clearer. Not sure though.
arch/arm64/kernel/traps.c void force_signal_inject(int signal, int code, unsigned long address) · line 372
Quoted 5 lines
arch/arm64/kernel/traps.c +1
-1-if (WARN_ON (signal !=SIGKILL || +if (WARN_ON (signal !=SIGKILL &&siginfo_layout (signal, code) !=SIL_FAULT )) { signal =SIGKILL ; }
[...]
Cheers
---Dave
Mark Rutland
reviewerPATCH 1/1 arm64: signal: don't force known signals to SIGKILL
Quoted 28 lines · Dave Martin
Quoted 27 lines · Mark Rutland
Since commit:
a7e6f1ca90354a31("arm64: signal: Force SIGKILL for unknown signals inforce_signal_inject")... any signal which is not SIGKILL will be upgraded to a SIGKILL be
force_signal_inject(). This includes signals we do expect, such as SIGILL triggered bydo_undefinstr().Fix the check to use a logical AND rather than a logical OR, permitting signals whose layout is
SIL_FAULT.Signed-off-by Mark Rutland <[email protected]>Fixes a7e6f1ca90354a31 ("arm64: signal: Force SIGKILL for unknown signals in force_signal_inject")Cc Catalin Marinas <[email protected]>Cc Dave Martin <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kernel/traps.c +0
-0@@ -366,7 +366,7 @@ void force_signal_inject(int signal, int code, unsigned long address) }
Quoted 5 lines
arch/arm64/kernel/traps.c void force_signal_inject(int signal, int code, unsigned long address) · line 368
Quoted 1 line
arch/arm64/kernel/traps.c +0
-0/* Force signals we don't understand to SIGKILL */ Is it worth updating the comment here?
What's the rationale for this check?
Per the commit log for a7e6f1ca90354a31:
----
arm64: signal: Force SIGKILL for unknown signals in force_signal_inject
For signals other than SIGKILL or those with siginfo_layout(signal, code) == SIL_FAULT then force_signal_inject does not initialise the siginfo_t properly. Since the signal number is determined solely by the caller, simply WARN on unknown signals and force to SIGKILL.
----
Quoted 6 lines
IIRC the purpose of this is to ensure that any siginfo delivered to userspace through this path is initialised correctly: so, either the signal must be a
SIL_FAULTsignal (since that's what the subsequent code initialises for) or SIGKILL (since userspace can't inspect the siginfo post-mortem, so the initialisation doesn't matter in that case).
Per the commit log and code, that seems to be the case, yes.
Quoted 2 lines
Maybe moving this check before the
switch()would make the logic clearer. Not sure though.
I don't have a strong feeling either way, but I think that can be punted to a separate cleanup.
Quoted 5 lines
arch/arm64/kernel/traps.c void force_signal_inject(int signal, int code, unsigned long address) · line 371
Quoted 5 lines
arch/arm64/kernel/traps.c +1
-1-if (WARN_ON (signal !=SIGKILL || +if (WARN_ON (signal !=SIGKILL &&siginfo_layout (signal, code) !=SIL_FAULT )) { signal =SIGKILL ;
Do you have a concern with the logical change here, or can I ask for your ack? ;)
Thanks,
Mark.
PATCH 1/1 arm64: signal: don't force known signals to SIGKILL
Quoted 65 lines · Mark Rutland
Quoted 28 lines · Dave Martin
Quoted 27 lines · Mark Rutland
Since commit:
a7e6f1ca90354a31("arm64: signal: Force SIGKILL for unknown signals inforce_signal_inject")... any signal which is not SIGKILL will be upgraded to a SIGKILL be
force_signal_inject(). This includes signals we do expect, such as SIGILL triggered bydo_undefinstr().Fix the check to use a logical AND rather than a logical OR, permitting signals whose layout is
SIL_FAULT.Signed-off-by Mark Rutland <[email protected]>Fixes a7e6f1ca90354a31 ("arm64: signal: Force SIGKILL for unknown signals in force_signal_inject")Cc Catalin Marinas <[email protected]>Cc Dave Martin <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kernel/traps.c +0
-0@@ -366,7 +366,7 @@ void force_signal_inject(int signal, int code, unsigned long address) }Quoted 5 lines
arch/arm64/kernel/traps.c void force_signal_inject(int signal, int code, unsigned long address) · line 368
Quoted 1 line
arch/arm64/kernel/traps.c +0
-0/* Force signals we don't understand to SIGKILL */ Is it worth updating the comment here?
What's the rationale for this check?
Per the commit log for
a7e6f1ca90354a31:----
arm64: signal: Force SIGKILL for unknown signals inforce_signal_injectFor signals other than SIGKILL or those with
siginfo_layout(signal, code)==SIL_FAULTthenforce_signal_injectdoes not initialise thesiginfo_tproperly. Since the signal number is determined solely by the caller, simply WARN on unknown signals and force to SIGKILL.Reported-by Dave Martin <[email protected]>Signed-off-by Will Deacon <[email protected]>----
Quoted 6 lines
IIRC the purpose of this is to ensure that any siginfo delivered to userspace through this path is initialised correctly: so, either the signal must be a
SIL_FAULTsignal (since that's what the subsequent code initialises for) or SIGKILL (since userspace can't inspect the siginfo post-mortem, so the initialisation doesn't matter in that case).Per the commit log and code, that seems to be the case, yes.
Quoted 2 lines
Maybe moving this check before the
switch()would make the logic clearer. Not sure though.I don't have a strong feeling either way, but I think that can be punted to a separate cleanup.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
arch/arm64/kernel/traps.c void force_signal_inject(int signal, int code, unsigned long address) · line 371
Quoted 4 lines
arch/arm64/kernel/traps.c +1
-1-if (WARN_ON (signal !=SIGKILL || +if (WARN_ON (signal !=SIGKILL &&siginfo_layout (signal, code) !=SIL_FAULT )) { signal =SIGKILL ;Do you have a concern with the logical change here, or can I ask for your ack? ;)
No concern, I just wanted to make sure I'd understood the background right. The commit message for this patch doesn't fully explain why the original code was wrong and why the new code is right, and my memory of the context for this was a bit fuzzy.
I should probably have followed the Fixes tag for context, but I was lazy :P
Anyway, FWIW
Out of interest, what were you seeing in userspace prior to this fix? Please don't tell me systemd is functionally reliant on SIGILL :(
Cheers
---Dave
Mark Rutland
reviewerPATCH 1/1 arm64: signal: don't force known signals to SIGKILL
Quoted 16 lines · Dave Martin
Quoted 9 lines · Mark Rutland
Quoted 5 lines · Dave Martin
arch/arm64/kernel/traps.c void force_signal_inject(int signal, int code, unsigned long address) · line 371
Quoted 4 lines · Mark Rutland
arch/arm64/kernel/traps.c +1
-1-if (WARN_ON (signal !=SIGKILL || +if (WARN_ON (signal !=SIGKILL &&siginfo_layout (signal, code) !=SIL_FAULT )) { signal =SIGKILL ;Do you have a concern with the logical change here, or can I ask for your ack? ;)
No concern, I just wanted to make sure I'd understood the background right. The commit message for this patch doesn't fully explain why the original code was wrong and why the new code is right, and my memory of the context for this was a bit fuzzy.
Quoted 7 lines
I should probably have followed the Fixes tag for context, but I was lazy :P
Anyway, FWIW
Reviewed-by Dave Martin <[email protected]>
Cheers!
Catalin, are you happy to queue this as a fix for v4.17-rc2?
Quoted 2 lines
Out of interest, what were you seeing in userspace prior to this fix? Please don't tell me systemd is functionally reliant on SIGILL :(
I spotted this with a pointer authentication test case I wrote, which I expected to receive SIGILL when using an instruction trapped and UNDEF'd by EL2.
Thanks,
Mark.
PATCH 1/1 arm64: signal: don't force known signals to SIGKILL
In reply to Mark RutlandQuoted 8 lines · Mark Rutland
Since commit:
a7e6f1ca90354a31("arm64: signal: Force SIGKILL for unknown signals inforce_signal_inject")... any signal which is not SIGKILL will be upgraded to a SIGKILL be
force_signal_inject(). This includes signals we do expect, such as SIGILL triggered bydo_undefinstr().
Quoted 8 lines
Fix the check to use a logical AND rather than a logical OR, permitting signals whose layout is
SIL_FAULT.Signed-off-by Mark Rutland <[email protected]>Fixes a7e6f1ca90354a31 ("arm64: signal: Force SIGKILL for unknown signals in force_signal_inject")Cc Catalin Marinas <[email protected]>Cc Dave Martin <[email protected]>Cc Will Deacon <[email protected]>
Queued for 4.17-rc2. Thanks.
Signature · 1 line
Catalin