@@ -223,10 +223,37 @@ bad_unknown_usage_update:
223223 ret
224224 .size bad_unknown_usage_update , . - bad_unknown_usage_update
225225
226+ .globl good_overwrite_with_constant
227+ .type good_overwrite_with_constant , @function
228+ good_overwrite_with_constant:
229+ // CHECK - NOT : good_overwrite_with_constant
230+ autia x0 , x1
231+ mov x0 , # 42
232+ ret
233+ .size good_overwrite_with_constant , . - good_overwrite_with_constant
234+
235+ // Overwriting sensitive data by instructions with unmodelled side - effects is
236+ // explicitly rejected , even though this particular MRS is safe.
237+ .globl bad_overwrite_with_side_effects
238+ .type bad_overwrite_with_side_effects , @function
239+ bad_overwrite_with_side_effects:
240+ // CHECK - LABEL: GS - PAUTH: authentication oracle found in function bad_overwrite_with_side_effects , basic block {{ [ ^ ,]+ }} , at address
241+ // CHECK - NEXT: The instruction is {{ [ 0 - 9a - f ]+ }}: autia x0 , x1
242+ // CHECK - NEXT: The 0 instructions th at leak the affected registers are:
243+ autia x0 , x1
244+ mrs x0 , CTR_EL0
245+ ret
246+ .size bad_overwrite_with_side_effects , . - bad_overwrite_with_side_effects
247+
248+ // Here the new value written by MUL to x0 is completely unrelated to the result
249+ // of authentication , so this is a false positive.
250+ // FIXME: Can/should we generalize overwriting by constant to handle such cases?
226251 .globl good_unknown_overwrite
227252 .type good_unknown_overwrite , @function
228253good_unknown_overwrite:
229- // CHECK - NOT : good_unknown_overwrite
254+ // CHECK - LABEL: GS - PAUTH: authentication oracle found in function good_unknown_overwrite , basic block {{ [ ^ ,]+ }} , at address
255+ // CHECK - NEXT: The instruction is {{ [ 0 - 9a - f ]+ }}: autia x0 , x1
256+ // CHECK - NEXT: The 0 instructions th at leak the affected registers are:
230257 autia x0 , x1
231258 mul x0 , x1 , x2
232259 ret
@@ -235,15 +262,15 @@ good_unknown_overwrite:
235262// This is a false positive: when a general - purpose register is written to as
236263// a 32 - bit register , its top 32 bits are zeroed , but according to LLVM
237264// representation , the instruction only overwrites the Wn register.
238- .globl good_unknown_wreg_overwrite
239- .type good_unknown_wreg_overwrite , @function
240- good_unknown_wreg_overwrite :
241- // CHECK - LABEL: GS - PAUTH: authentication oracle found in function good_unknown_wreg_overwrite , basic block {{ [ ^ ,]+ }} , at address
265+ .globl good_wreg_overwrite
266+ .type good_wreg_overwrite , @function
267+ good_wreg_overwrite :
268+ // CHECK - LABEL: GS - PAUTH: authentication oracle found in function good_wreg_overwrite , basic block {{ [ ^ ,]+ }} , at address
242269// CHECK - NEXT: The instruction is {{ [ 0 - 9a - f ]+ }}: autia x0 , x1
243270 autia x0 , x1
244- mul w0 , w1 , w2
271+ mov w0 , # 42
245272 ret
246- .size good_unknown_wreg_overwrite , . - good_unknown_wreg_overwrite
273+ .size good_wreg_overwrite , . - good_wreg_overwrite
247274
248275 .globl good_address_arith
249276 .type good_address_arith , @function
@@ -435,16 +462,16 @@ bad_unknown_usage_update_multi_bb:
435462 ret
436463 .size bad_unknown_usage_update_multi_bb , . - bad_unknown_usage_update_multi_bb
437464
438- .globl good_unknown_overwrite_multi_bb
439- .type good_unknown_overwrite_multi_bb , @function
440- good_unknown_overwrite_multi_bb :
441- // CHECK - NOT : good_unknown_overwrite_multi_bb
465+ .globl good_overwrite_with_constant_multi_bb
466+ .type good_overwrite_with_constant_multi_bb , @function
467+ good_overwrite_with_constant_multi_bb :
468+ // CHECK - NOT : good_overwrite_with_constant_multi_bb
442469 autia x0 , x1
443470 cbz x3 , 1f
4444711 :
445- mul x0 , x1 , x2
472+ mov x0 , # 42
446473 ret
447- .size good_unknown_overwrite_multi_bb , . - good_unknown_overwrite_multi_bb
474+ .size good_overwrite_with_constant_multi_bb , . - good_overwrite_with_constant_multi_bb
448475
449476 .globl good_address_arith_multi_bb
450477 .type good_address_arith_multi_bb , @function
@@ -638,20 +665,20 @@ bad_unknown_usage_update_nocfg:
638665 ret
639666 .size bad_unknown_usage_update_nocfg , . - bad_unknown_usage_update_nocfg
640667
641- .globl good_unknown_overwrite_nocfg
642- .type good_unknown_overwrite_nocfg , @function
643- good_unknown_overwrite_nocfg :
644- // CHECK - NOT : good_unknown_overwrite_nocfg
668+ .globl good_overwrite_with_constant_nocfg
669+ .type good_overwrite_with_constant_nocfg , @function
670+ good_overwrite_with_constant_nocfg :
671+ // CHECK - NOT : good_overwrite_with_constant_nocfg
645672 paciasp
646673 adr x2 , 1f
647674 br x2
6486751 :
649676 autia x0 , x1
650- mul x0 , x1 , x2
677+ mov x0 , # 42
651678
652679 autiasp
653680 ret
654- .size good_unknown_overwrite_nocfg , . - good_unknown_overwrite_nocfg
681+ .size good_overwrite_with_constant_nocfg , . - good_overwrite_with_constant_nocfg
655682
656683 .globl good_address_arith_nocfg
657684 .type good_address_arith_nocfg , @function
0 commit comments