public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "H.J. Lu via Gcc-patches" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] x86: Document -mno-cet-switch
Date: Wed, 11 May 2022 20:45:36 +0200	[thread overview]
Message-ID: <87fslfdi27.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAMe9rOo2Lp6d3aGpQx1GCG0ZNbcg14J8aL+wBQShZZxMXkjg0Q@mail.gmail.com> (H. J. Lu's message of "Wed, 11 May 2022 11:36:05 -0700")

* H. J. Lu:

>> NOTRACK avoids the need for ENDBR instructions, right?  That's a
>> hardening improvement, so it should be used by default.
>
> NOTRACK weakens IBT since it disables IBT on the indirect jump instruction.
> GCC uses it in the jump table to avoid ENDBR.

Typical jump table code looks like this:

Dump of assembler code for function __cache_sysconf:
   0x00000000000f7a80 <+0>:	endbr64 
   0x00000000000f7a84 <+4>:	sub    $0xb9,%edi
   0x00000000000f7a8a <+10>:	cmp    $0xc,%edi
   0x00000000000f7a8d <+13>:	ja     0xf7b70 <__cache_sysconf+240>
   0x00000000000f7a93 <+19>:	lea    0xba926(%rip),%rdx        # 0x1b23c0
   0x00000000000f7a9a <+26>:	movslq (%rdx,%rdi,4),%rax
   0x00000000000f7a9e <+30>:	add    %rdx,%rax
   0x00000000000f7aa1 <+33>:	notrack jmp *%rax

There's no ENDBR instruction between range check, the address
computation, and the NOTRACK JMP, so it's not possible to redirect that
JMP to some other place.

I don't know if GCC systematically enforces this in its optimizers,
though.

Thanks,
Florian


  reply	other threads:[~2022-05-11 18:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 16:20 H.J. Lu
2022-05-11  7:15 ` Uros Bizjak
2022-05-11  8:12 ` Florian Weimer
2022-05-11 14:20   ` H.J. Lu
2022-05-11 15:58     ` Florian Weimer
2022-05-11 18:00       ` H.J. Lu
2022-05-11 18:22         ` Florian Weimer
2022-05-11 18:36           ` H.J. Lu
2022-05-11 18:45             ` Florian Weimer [this message]
2022-05-11 18:57               ` H.J. Lu
2022-05-11 19:02                 ` Florian Weimer
2022-05-11 20:04                   ` H.J. Lu
2022-05-12  7:15                   ` Richard Biener
2022-05-12 16:42                     ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fslfdi27.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).