public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/101276] New: [i386] Keylocker output should be cleared when instruction reports runtime error.
@ 2021-07-01  3:24 wwwhhhyyy333 at gmail dot com
  2021-07-01  4:48 ` [Bug target/101276] " crazylht at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: wwwhhhyyy333 at gmail dot com @ 2021-07-01  3:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101276

            Bug ID: 101276
           Summary: [i386] Keylocker output should be cleared when
                    instruction reports runtime error.
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wwwhhhyyy333 at gmail dot com
  Target Milestone: ---

Some keylocker instruction will set ZF when runtime occurs, and the output data
should be invalid. 

Current intrinsic just copy the input data to output regardless of the ZF, like

 movdqa  k2(%rip), %xmm0
 aesdec128kl     h1(%rip), %xmm0
 sete    %al
 movups  %xmm0, k1(%rip)

It could bring safety issue that return the unencrypted data when runtime error
occurs. So the code should be like

        movdqa  k2(%rip), %xmm0
        aesdec128kl     h1(%rip), %xmm0
        je      .L4
.L2:
        sete    %al
        movups  %xmm0, k1(%rip)
        ret
.L4:
        pxor    %xmm0, %xmm0
        jmp     .L2

To clear the output data.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/101276] [i386] Keylocker output should be cleared when instruction reports runtime error.
  2021-07-01  3:24 [Bug target/101276] New: [i386] Keylocker output should be cleared when instruction reports runtime error wwwhhhyyy333 at gmail dot com
@ 2021-07-01  4:48 ` crazylht at gmail dot com
  2021-07-01  7:19 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2021-07-01  4:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101276

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |crazylht at gmail dot com

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
Note this is not a bug, but a re-implementation of the keylocker intrinsic from
a security perspective.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/101276] [i386] Keylocker output should be cleared when instruction reports runtime error.
  2021-07-01  3:24 [Bug target/101276] New: [i386] Keylocker output should be cleared when instruction reports runtime error wwwhhhyyy333 at gmail dot com
  2021-07-01  4:48 ` [Bug target/101276] " crazylht at gmail dot com
@ 2021-07-01  7:19 ` rguenth at gcc dot gnu.org
  2021-07-01  7:34 ` crazylht at gmail dot com
  2021-07-02  7:30 ` wwwhhhyyy333 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-01  7:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101276

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
It might slow down things when data is encrypted in a loop and the error state
is accumulated and checked afterwards?

Maybe warrants a -msecured-kl option or so?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/101276] [i386] Keylocker output should be cleared when instruction reports runtime error.
  2021-07-01  3:24 [Bug target/101276] New: [i386] Keylocker output should be cleared when instruction reports runtime error wwwhhhyyy333 at gmail dot com
  2021-07-01  4:48 ` [Bug target/101276] " crazylht at gmail dot com
  2021-07-01  7:19 ` rguenth at gcc dot gnu.org
@ 2021-07-01  7:34 ` crazylht at gmail dot com
  2021-07-02  7:30 ` wwwhhhyyy333 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2021-07-01  7:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101276

--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Richard Biener from comment #2)
> It might slow down things when data is encrypted in a loop and the error
> state
> is accumulated and checked afterwards?

This is the exact case that the user mentioned, by the time the state is
checked, idata has been already written to odata. They hope when intructions
failed to encrpt idata, 0 would used for odata.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/101276] [i386] Keylocker output should be cleared when instruction reports runtime error.
  2021-07-01  3:24 [Bug target/101276] New: [i386] Keylocker output should be cleared when instruction reports runtime error wwwhhhyyy333 at gmail dot com
                   ` (2 preceding siblings ...)
  2021-07-01  7:34 ` crazylht at gmail dot com
@ 2021-07-02  7:30 ` wwwhhhyyy333 at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: wwwhhhyyy333 at gmail dot com @ 2021-07-02  7:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101276

Hongyu Wang <wwwhhhyyy333 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Hongyu Wang <wwwhhhyyy333 at gmail dot com> ---
Fixed by
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1aeefa5720a71e622e2f26bf10ec8e7ecbd76f4c

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-02  7:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01  3:24 [Bug target/101276] New: [i386] Keylocker output should be cleared when instruction reports runtime error wwwhhhyyy333 at gmail dot com
2021-07-01  4:48 ` [Bug target/101276] " crazylht at gmail dot com
2021-07-01  7:19 ` rguenth at gcc dot gnu.org
2021-07-01  7:34 ` crazylht at gmail dot com
2021-07-02  7:30 ` wwwhhhyyy333 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).