Bug 1802689 - glibc: x86/CET: Legacy bitmap doesn't cover jitted code
Summary: glibc: x86/CET: Legacy bitmap doesn't cover jitted code
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Carlos O'Donell
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1802686 1802674
TreeView+ depends on / blocked
 
Reported: 2020-02-13 17:37 UTC by H.J. Lu
Modified: 2020-12-21 17:02 UTC (History)
11 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-04-07 13:23:34 UTC
Type: Bug
Embargoed:
codonell: mirror+


Attachments (Terms of Use)
Replace ARCH_CET_LEGACY_BITMAP with ARCH_CET_MARK_LEGACY_CODE (9.23 KB, patch)
2020-02-13 17:37 UTC, H.J. Lu
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Sourceware 25397 0 P2 RESOLVED Legacy bitmap doesn't cover jitted code 2020-04-16 04:40:26 UTC

Description H.J. Lu 2020-02-13 17:37:52 UTC
Created attachment 1662993 [details]
Replace ARCH_CET_LEGACY_BITMAP with  ARCH_CET_MARK_LEGACY_CODE

The current CET kernel on cet branch at:

https://github.com/yyu168/linux_cet

replaced ARCH_CET_LEGACY_BITMAP with ARCH_CET_MARK_LEGACY_CODE to mark
legacy code region.  This patch updates glibc with:

 /* Mark legacy code region in legacy bitmap with unsigned long long *addr:
     address: addr[0].
     size: addr[1].
     set: addr[2].
  */
 # define ARCH_CET_MARK_LEGACY_CODE 0x3007

It uses ARCH_CET_MARK_LEGACY_CODE to mark legacy code region when mmapping
executable PT_LOAD segments and clear the region when munmapping them.

Comment 1 Florian Weimer 2020-02-13 17:50:32 UTC
What's the timeline for the upstream kernel merge?

We want to switch to the final ABI in all Fedora releases once that becomes available upstream. My feeling was that shipping draft APIs would just create duplicate work. Please let me know if you disagree.

Comment 2 Carlos O'Donell 2020-02-25 14:06:15 UTC
H.J,

Do you want a Fedora Rawhide patched glibc with this fix?

We can do that if you want to test things out with more-or-less official packages.

Are you using Fedora Rawhide or do you want this in other Fedora releases for testing?

Comment 3 H.J. Lu 2020-02-25 14:29:41 UTC
(In reply to Florian Weimer from comment #1)
> What's the timeline for the upstream kernel merge?
> 
> We want to switch to the final ABI in all Fedora releases once that becomes
> available upstream. My feeling was that shipping draft APIs would just
> create duplicate work. Please let me know if you disagree.

We have been testing this kernel interface, based on feedbacks from kernel
developers, for more than 6 months. Without this glibc change, we can't test
CET kernel on Tiger Lake.  We hope to upstream CET kernel support to kernel 5.8.
Yu-cheng, our CET kernel developer, would like to get some help on kernel
patch review.

Comment 4 H.J. Lu 2020-02-25 14:38:52 UTC
(In reply to Carlos O'Donell from comment #2)
> H.J,
> 
> Do you want a Fedora Rawhide patched glibc with this fix?

Yes.  Please also include CET kernel patches.

> We can do that if you want to test things out with more-or-less official
> packages.

This sounds good.

> Are you using Fedora Rawhide or do you want this in other Fedora releases
> for testing?

I am using Fedora 31 + patched rpms to test CET.  I can use Rawhide if CET is
enabled in its libffi.

Comment 5 Carlos O'Donell 2020-04-07 13:23:34 UTC
This bug is fixed by the following commit:

commit 1fabdb99084df004f7f4cdc7068d1be209a258be
Author: H.J. Lu <hjl.tools>
Date:   Wed Mar 18 04:35:54 2020 -0700

    x86: Remove ARCH_CET_LEGACY_BITMAP [BZ #25397]
    
    Since legacy bitmap doesn't cover jitted code generated by legacy JIT
    engine, it isn't very useful.  This patch removes ARCH_CET_LEGACY_BITMAP
    and treats indirect branch tracking similar to shadow stack by removing
    legacy bitmap support.
    
    Tested on CET Linux/x86-64 and non-CET Linux/x86-64.
    
    Reviewed-by: Carlos O'Donell <carlos>

Legacy bitmap support has been removed because it doesn't cover JIT'd code.

The legacy bitmap was envisioned as way to allow legacy code to be inter-mixed with hardened code, but this mixed state turns out to be more difficult to manage than it's worth.

Thus we simplify the implementation to just hardened or non-hardened by CET.

Legacy JIT's cannot run with Intel CET turned on, they must be fixed first to use the appropriate ENDBR and then everything will work.


Note You need to log in before you can comment on or make changes to this bug.