Message ID | 20210113120910.1258769-1-hjl.tools@gmail.com |
---|---|
State | Committed |
Commit | 2ef23b520597f4ea1790a669b83e608f24f4cf12 |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F03238708AC; Wed, 13 Jan 2021 12:09:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F03238708AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610539768; bh=QCWAHjKQY7N0autxpxNTsKg1uRE46PVids+smC7xZt4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=thtgzv3CE/7qkeCqNB8Wmvf0HQUcMBz2i/G/GiFF44aaWxn7U+OwRVGgTwg+SFcIl 44ZllocQ5VU9ql1G4iByb09SpL2SsXds8XiiBkHsco4wM2BDzBq42A5kbGwSsTI7+d mXH3vVgW+u6KtLB0D5F5IhLvI1jnA+QghRmWKFg8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id CFDA1384A018 for <libc-alpha@sourceware.org>; Wed, 13 Jan 2021 12:09:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CFDA1384A018 Received: by mail-pj1-x102e.google.com with SMTP id cq1so1016801pjb.4 for <libc-alpha@sourceware.org>; Wed, 13 Jan 2021 04:09:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QCWAHjKQY7N0autxpxNTsKg1uRE46PVids+smC7xZt4=; b=CJwXchei9RYlz10QfsRO5wvywHR1V6OZ4syoPQyCJ9Y0+d9tKyvxe5WY59LU2S3ROL AQDTx+b7n9WzZeEjGlti0SxqDGfgBQvPpRgSTTvDAsPSD8Yb9UUnQaGR1di9cLcUSpeH nbneRZeNvOP88pP4IJ86jQoMqmzwtwAly22nAiqaiuvkugFdxe+JcSik0bGKx92XJ+8m clumVB8O4SDg77PZwrGdi5i3LJswtMykzcOZZs23zkCuk53/D/YeESloDW86ZREoO954 xPRA92gVdy9GOl1QqNLuM6nzmXCrqCQNKb0Cc+WPGnbJ7B2t7nQm3LIZWpdju3czkbmb 0Tew== X-Gm-Message-State: AOAM530+V4ggXsoGVbOmulBLAb1ubuOYhlgG1i8KForRztvJ16OWUzU5 wQD8QxmUbMRcN9jXGSe/kFBzLkbawxA= X-Google-Smtp-Source: ABdhPJxDc4YVBnYaJHqKxGnb/V8nzGt+YYTMXpMGQmmc1EiX/q/RJeo5vF8eOcLGC9FULciwrBzcYQ== X-Received: by 2002:a17:90a:db96:: with SMTP id h22mr2084628pjv.204.1610539754723; Wed, 13 Jan 2021 04:09:14 -0800 (PST) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id e5sm2425396pfc.76.2021.01.13.04.09.13 for <libc-alpha@sourceware.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 04:09:14 -0800 (PST) Received: from gnu-tgl-2.localdomain (unknown [192.168.1.53]) by gnu-cfl-2.localdomain (Postfix) with ESMTPS id 189201A013C for <libc-alpha@sourceware.org>; Wed, 13 Jan 2021 04:09:13 -0800 (PST) Received: from gnu-tgl-2.localdomain (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id 15C5A3001D9 for <libc-alpha@sourceware.org>; Wed, 13 Jan 2021 04:09:12 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH] x86: Set header.feature_1 in TCB for always-on CET Date: Wed, 13 Jan 2021 04:09:10 -0800 Message-Id: <20210113120910.1258769-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3039.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org> Reply-To: "H.J. Lu" <hjl.tools@gmail.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
x86: Set header.feature_1 in TCB for always-on CET
|
|
Commit Message
H.J. Lu
Jan. 13, 2021, 12:09 p.m. UTC
Update dl_cet_check() to set header.feature_1 in TCB when both IBT and SHSTK are always on. --- sysdeps/x86/Makefile | 6 ++++++ sysdeps/x86/dl-cet.c | 5 ++++- sysdeps/x86/tst-setjmp-cet.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 sysdeps/x86/tst-setjmp-cet.c
Comments
On Wed, Jan 13, 2021 at 4:09 AM H.J. Lu <hjl.tools@gmail.com> wrote: > > Update dl_cet_check() to set header.feature_1 in TCB when both IBT and > SHSTK are always on. > --- > sysdeps/x86/Makefile | 6 ++++++ > sysdeps/x86/dl-cet.c | 5 ++++- > sysdeps/x86/tst-setjmp-cet.c | 1 + > 3 files changed, 11 insertions(+), 1 deletion(-) > create mode 100644 sysdeps/x86/tst-setjmp-cet.c > > diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile > index c814d5a195..adaa2a92cd 100644 > --- a/sysdeps/x86/Makefile > +++ b/sysdeps/x86/Makefile > @@ -48,6 +48,12 @@ endif # $(subdir) == math > ifeq ($(subdir),setjmp) > gen-as-const-headers += jmp_buf-ssp.sym > sysdep_routines += __longjmp_cancel > +ifneq ($(enable-cet),no) > +ifneq ($(have-tunables),no) > +tests += tst-setjmp-cet > +tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on > +endif > +endif > endif > > ifeq ($(subdir),string) > diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c > index ed7fd6d10d..a63b9c7164 100644 > --- a/sysdeps/x86/dl-cet.c > +++ b/sysdeps/x86/dl-cet.c > @@ -47,7 +47,10 @@ dl_cet_check (struct link_map *m, const char *program) > /* No legacy object check if both IBT and SHSTK are always on. */ > if (enable_ibt_type == cet_always_on > && enable_shstk_type == cet_always_on) > - return; > + { > + THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1)); > + return; > + } > > /* Check if IBT is enabled by kernel. */ > bool ibt_enabled > diff --git a/sysdeps/x86/tst-setjmp-cet.c b/sysdeps/x86/tst-setjmp-cet.c > new file mode 100644 > index 0000000000..42c795d2a8 > --- /dev/null > +++ b/sysdeps/x86/tst-setjmp-cet.c > @@ -0,0 +1 @@ > +#include <setjmp/tst-setjmp.c> > -- > 2.29.2 > This fixed: https://sourceware.org/bugzilla/show_bug.cgi?id=27177 I'd like to fix it for 2.33. Thanks.
On 13/01/2021 09:14, H.J. Lu wrote: > On Wed, Jan 13, 2021 at 4:09 AM H.J. Lu <hjl.tools@gmail.com> wrote: >> >> Update dl_cet_check() to set header.feature_1 in TCB when both IBT and >> SHSTK are always on. >> --- >> sysdeps/x86/Makefile | 6 ++++++ >> sysdeps/x86/dl-cet.c | 5 ++++- >> sysdeps/x86/tst-setjmp-cet.c | 1 + >> 3 files changed, 11 insertions(+), 1 deletion(-) >> create mode 100644 sysdeps/x86/tst-setjmp-cet.c >> >> diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile >> index c814d5a195..adaa2a92cd 100644 >> --- a/sysdeps/x86/Makefile >> +++ b/sysdeps/x86/Makefile >> @@ -48,6 +48,12 @@ endif # $(subdir) == math >> ifeq ($(subdir),setjmp) >> gen-as-const-headers += jmp_buf-ssp.sym >> sysdep_routines += __longjmp_cancel >> +ifneq ($(enable-cet),no) >> +ifneq ($(have-tunables),no) >> +tests += tst-setjmp-cet >> +tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on >> +endif >> +endif >> endif >> >> ifeq ($(subdir),string) >> diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c >> index ed7fd6d10d..a63b9c7164 100644 >> --- a/sysdeps/x86/dl-cet.c >> +++ b/sysdeps/x86/dl-cet.c >> @@ -47,7 +47,10 @@ dl_cet_check (struct link_map *m, const char *program) >> /* No legacy object check if both IBT and SHSTK are always on. */ >> if (enable_ibt_type == cet_always_on >> && enable_shstk_type == cet_always_on) >> - return; >> + { >> + THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1)); >> + return; >> + } >> >> /* Check if IBT is enabled by kernel. */ >> bool ibt_enabled >> diff --git a/sysdeps/x86/tst-setjmp-cet.c b/sysdeps/x86/tst-setjmp-cet.c >> new file mode 100644 >> index 0000000000..42c795d2a8 >> --- /dev/null >> +++ b/sysdeps/x86/tst-setjmp-cet.c >> @@ -0,0 +1 @@ >> +#include <setjmp/tst-setjmp.c> >> -- >> 2.29.2 >> > > This fixed: > > https://sourceware.org/bugzilla/show_bug.cgi?id=27177 > > I'd like to fix it for 2.33. > > Thanks. > Ok for 2.33.
On Wed, Jan 13, 2021 at 4:58 AM Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote: > > > > On 13/01/2021 09:14, H.J. Lu wrote: > > On Wed, Jan 13, 2021 at 4:09 AM H.J. Lu <hjl.tools@gmail.com> wrote: > >> > >> Update dl_cet_check() to set header.feature_1 in TCB when both IBT and > >> SHSTK are always on. > >> --- > >> sysdeps/x86/Makefile | 6 ++++++ > >> sysdeps/x86/dl-cet.c | 5 ++++- > >> sysdeps/x86/tst-setjmp-cet.c | 1 + > >> 3 files changed, 11 insertions(+), 1 deletion(-) > >> create mode 100644 sysdeps/x86/tst-setjmp-cet.c > >> > >> diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile > >> index c814d5a195..adaa2a92cd 100644 > >> --- a/sysdeps/x86/Makefile > >> +++ b/sysdeps/x86/Makefile > >> @@ -48,6 +48,12 @@ endif # $(subdir) == math > >> ifeq ($(subdir),setjmp) > >> gen-as-const-headers += jmp_buf-ssp.sym > >> sysdep_routines += __longjmp_cancel > >> +ifneq ($(enable-cet),no) > >> +ifneq ($(have-tunables),no) > >> +tests += tst-setjmp-cet > >> +tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on > >> +endif > >> +endif > >> endif > >> > >> ifeq ($(subdir),string) > >> diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c > >> index ed7fd6d10d..a63b9c7164 100644 > >> --- a/sysdeps/x86/dl-cet.c > >> +++ b/sysdeps/x86/dl-cet.c > >> @@ -47,7 +47,10 @@ dl_cet_check (struct link_map *m, const char *program) > >> /* No legacy object check if both IBT and SHSTK are always on. */ > >> if (enable_ibt_type == cet_always_on > >> && enable_shstk_type == cet_always_on) > >> - return; > >> + { > >> + THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1)); > >> + return; > >> + } > >> > >> /* Check if IBT is enabled by kernel. */ > >> bool ibt_enabled > >> diff --git a/sysdeps/x86/tst-setjmp-cet.c b/sysdeps/x86/tst-setjmp-cet.c > >> new file mode 100644 > >> index 0000000000..42c795d2a8 > >> --- /dev/null > >> +++ b/sysdeps/x86/tst-setjmp-cet.c > >> @@ -0,0 +1 @@ > >> +#include <setjmp/tst-setjmp.c> > >> -- > >> 2.29.2 > >> > > > > This fixed: > > > > https://sourceware.org/bugzilla/show_bug.cgi?id=27177 > > > > I'd like to fix it for 2.33. > > > > Thanks. > > > > Ok for 2.33. I am backporting it to release branches. Thanks.
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index c814d5a195..adaa2a92cd 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -48,6 +48,12 @@ endif # $(subdir) == math ifeq ($(subdir),setjmp) gen-as-const-headers += jmp_buf-ssp.sym sysdep_routines += __longjmp_cancel +ifneq ($(enable-cet),no) +ifneq ($(have-tunables),no) +tests += tst-setjmp-cet +tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on +endif +endif endif ifeq ($(subdir),string) diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c index ed7fd6d10d..a63b9c7164 100644 --- a/sysdeps/x86/dl-cet.c +++ b/sysdeps/x86/dl-cet.c @@ -47,7 +47,10 @@ dl_cet_check (struct link_map *m, const char *program) /* No legacy object check if both IBT and SHSTK are always on. */ if (enable_ibt_type == cet_always_on && enable_shstk_type == cet_always_on) - return; + { + THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1)); + return; + } /* Check if IBT is enabled by kernel. */ bool ibt_enabled diff --git a/sysdeps/x86/tst-setjmp-cet.c b/sysdeps/x86/tst-setjmp-cet.c new file mode 100644 index 0000000000..42c795d2a8 --- /dev/null +++ b/sysdeps/x86/tst-setjmp-cet.c @@ -0,0 +1 @@ +#include <setjmp/tst-setjmp.c>