[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`

2026-06-13 Thread paulhua at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

Chenghua Xu  changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED

--- Comment #13 from Chenghua Xu  ---
Closed.

[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`

2026-06-13 Thread paulhua at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

Chenghua Xu  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 CC||paulhua at gcc dot gnu.org
 Status|ASSIGNED|RESOLVED

--- Comment #12 from Chenghua Xu  ---
Fixed on trunk and backport to gcc13\14\15\16.

[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`

2026-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

--- Comment #11 from GCC Commits  ---
The releases/gcc-13 branch has been updated by Xi Ruoyao :

https://gcc.gnu.org/g:4d7d4d282de299ab3f09134b880f9595f60db30a

commit r13-10356-g4d7d4d282de299ab3f09134b880f9595f60db30a
Author: Xi Ruoyao 
Date:   Tue Apr 28 20:32:38 2026 +0800

LoongArch: harden SSP canary set and test routines [PR 125049]

Add the stack_protect_combined_{set,test} expanders to expand the
routines as unsplitable insns which does not leave any sensitive data
(the canary value, the canary address, and all the intermediate values
used materializing the address) in a register.  This prevents the
attacker from defeating SSP by probing the canary value from the
register context or overwriting the address spilled onto the stack.

PR target/125049

gcc/

* config/loongarch/predicates.md (ssp_operand): New
define_predicate.
(ssp_normal_operand): New define_predicate.
* config/loongarch/constraints.md (ZE): New define_constraint.
(ZF): New define_constraint.
* config/loongarch/loongarch.md (UNSPEC_SSP): New unspec.
(cbranch4): Add "@" to create gen_cbranch4(machine_mode, ...).
(@stack_protect_combined_set_normal_): New define_insn.
(@stack_protect_combined_set_extreme_): New define_insn.
(@stack_protect_combined_test_internal_): New define_insn.
(stack_protect_combined_set): New define_expand.
(stack_protect_combined_test): New define_expand.
* config/loongarch/loongarch-protos.h
(loongarch_symbol_extreme_p): Declare.
(loongarch_output_asm_load_canary): Declare.
* config/loongarch/loongarch.cc (loongarch_print_operand): Allow
'v' to print d/w for DImode/SImode.
(loongarch_symbol_extreme_p): Remove static.
(loongarch_output_asm_load_canary): Implement.

gcc/testsuite/

* gcc.target/loongarch/pr125049.c: New test.

(cherry picked from commit 62fdbd084f7ab04cb7a97d6186ffe70acfc70f1b)

[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`

2026-06-03 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

--- Comment #10 from GCC Commits  ---
The releases/gcc-14 branch has been updated by Xi Ruoyao :

https://gcc.gnu.org/g:572318619e354711c97a5216d262d22e1d604657

commit r14-12637-g572318619e354711c97a5216d262d22e1d604657
Author: Xi Ruoyao 
Date:   Tue Apr 28 20:32:38 2026 +0800

LoongArch: harden SSP canary set and test routines [PR 125049]

Add the stack_protect_combined_{set,test} expanders to expand the
routines as unsplitable insns which does not leave any sensitive data
(the canary value, the canary address, and all the intermediate values
used materializing the address) in a register.  This prevents the
attacker from defeating SSP by probing the canary value from the
register context or overwriting the address spilled onto the stack.

PR target/125049

gcc/

* config/loongarch/predicates.md (ssp_operand): New
define_predicate.
(ssp_normal_operand): New define_predicate.
* config/loongarch/constraints.md (ZE): New define_constraint.
(ZF): New define_constraint.
* config/loongarch/loongarch.md (UNSPEC_SSP): New unspec.
(cbranch4): Add "@" to create gen_cbranch4(machine_mode, ...).
(@stack_protect_combined_set_normal_): New define_insn.
(@stack_protect_combined_set_extreme_): New define_insn.
(@stack_protect_combined_test_internal_): New define_insn.
(stack_protect_combined_set): New define_expand.
(stack_protect_combined_test): New define_expand.
* config/loongarch/loongarch-protos.h
(loongarch_output_asm_load_canary): Declare.
* config/loongarch/loongarch.cc (loongarch_print_operand): Allow
'v' to print d/w for DImode/SImode.
(loongarch_output_asm_load_canary): Implement.

gcc/testsuite/

* gcc.target/loongarch/pr125049.c: New test.

(cherry picked from commit 62fdbd084f7ab04cb7a97d6186ffe70acfc70f1b)

[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`

2026-05-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

--- Comment #9 from GCC Commits  ---
The releases/gcc-15 branch has been updated by Xi Ruoyao :

https://gcc.gnu.org/g:7704f03d8a65874cedfb0b29a155213dcd822283

commit r15-11185-g7704f03d8a65874cedfb0b29a155213dcd822283
Author: Xi Ruoyao 
Date:   Tue Apr 28 20:32:38 2026 +0800

LoongArch: harden SSP canary set and test routines [PR 125049]

Add the stack_protect_combined_{set,test} expanders to expand the
routines as unsplitable insns which does not leave any sensitive data
(the canary value, the canary address, and all the intermediate values
used materializing the address) in a register.  This prevents the
attacker from defeating SSP by probing the canary value from the
register context or overwriting the address spilled onto the stack.

PR target/125049

gcc/

* config/loongarch/predicates.md (ssp_operand): New
define_predicate.
(ssp_normal_operand): New define_predicate.
* config/loongarch/constraints.md (ZE): New define_constraint.
(ZF): New define_constraint.
* config/loongarch/loongarch.md (UNSPEC_SSP): New unspec.
(cbranch4): Add "@" to create gen_cbranch4(machine_mode, ...).
(@stack_protect_combined_set_normal_): New define_insn.
(@stack_protect_combined_set_extreme_): New define_insn.
(@stack_protect_combined_test_internal_): New define_insn.
(stack_protect_combined_set): New define_expand.
(stack_protect_combined_test): New define_expand.
* config/loongarch/loongarch-protos.h
(loongarch_output_asm_load_canary): Declare.
* config/loongarch/loongarch.cc (loongarch_print_operand): Allow
'v' to print d/w for DImode/SImode.
(loongarch_output_asm_load_canary): Implement.

gcc/testsuite/

* gcc.target/loongarch/pr125049.c: New test.

(cherry picked from commit 62fdbd084f7ab04cb7a97d6186ffe70acfc70f1b)

[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`

2026-05-13 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

--- Comment #8 from GCC Commits  ---
The releases/gcc-16 branch has been updated by Xi Ruoyao :

https://gcc.gnu.org/g:690fc9dc78a8f5845cded281ec5aebf19ec94d56

commit r16-8902-g690fc9dc78a8f5845cded281ec5aebf19ec94d56
Author: Xi Ruoyao 
Date:   Tue Apr 28 20:32:38 2026 +0800

LoongArch: harden SSP canary set and test routines [PR 125049]

Add the stack_protect_combined_{set,test} expanders to expand the
routines as unsplitable insns which does not leave any sensitive data
(the canary value, the canary address, and all the intermediate values
used materializing the address) in a register.  This prevents the
attacker from defeating SSP by probing the canary value from the
register context or overwriting the address spilled onto the stack.

PR target/125049

gcc/

* config/loongarch/predicates.md (ssp_operand): New
define_predicate.
(ssp_normal_operand): New define_predicate.
* config/loongarch/constraints.md (ZE): New define_constraint.
(ZF): New define_constraint.
* config/loongarch/loongarch.md (UNSPEC_SSP): New unspec.
(cbranch4): Add "@" to create gen_cbranch4(machine_mode, ...).
(@stack_protect_combined_set_normal_): New define_insn.
(@stack_protect_combined_set_extreme_): New define_insn.
(@stack_protect_combined_test_internal_): New define_insn.
(stack_protect_combined_set): New define_expand.
(stack_protect_combined_test): New define_expand.
* config/loongarch/loongarch-protos.h
(loongarch_output_asm_load_canary): Declare.
* config/loongarch/loongarch.cc (loongarch_print_operand): Allow
'v' to print d/w for DImode/SImode.
(loongarch_output_asm_load_canary): Implement.

gcc/testsuite/

* gcc.target/loongarch/pr125049.c: New test.

(cherry picked from commit 62fdbd084f7ab04cb7a97d6186ffe70acfc70f1b)

[Bug target/125049] [loongarch] SSP fallback leaves __stack_chk_guard live in $r12 at `jr $r1`

2026-05-13 Thread 220245569 at seu dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125049

--- Comment #7 from JingYao Zhang <220245569 at seu dot edu.cn> ---
(In reply to Xi Ruoyao from comment #6)
> Fixed for trunk.  Will backport to all active branches if no complains in a
> few days.

cool