From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 44D0C386F450 for ; Wed, 13 Jan 2021 12:14:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 44D0C386F450 Received: by mail-ot1-x32d.google.com with SMTP id j12so1661703ota.7 for ; Wed, 13 Jan 2021 04:14:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=lyq9d6Y3ehsFTT8vKTJht0NbXpwv5GvYRpX6YkqUaIw=; b=bVUA3iR9H13eBo+XRwkaVlqmJdXkY9lBzwew/gvisov3yC4zw/90gVFIGTCe4ZT5Tb Y4ky/4/L7guRAcIaa31CGTMcSYKuwW9WSOA2akXQrNSZFY3JqcZnCfc9PL0aQ987o5Zi Xov1qq3qAKSusuknrBsg2gPkORp00Pv/FXrFexZtiXdlwetwKTIhSn+zDYVMKYeuaxrS bFKUwo9xQq1xqdt2iRz4XNhiCj9+ZbSCMHpuq+JoFX4pLYs/LyjjiTmivYrbnBvbOldN 9vuwXyb6krBSgEmeoU3YKpPXtQSj4dxky5qolUluqe5DnpZylLqlfTDAuVNwWckNAWO3 Rrsg== X-Gm-Message-State: AOAM531ok883DQEevLKlAsuvey5sf/VbkYmNF5XR10xdQ+0GdhZ7r91/ UKzHlHYbpQbK7iIBwQNCk6wExXUo2ImftPMHpr4wf1lAcTs= X-Google-Smtp-Source: ABdhPJxLH0xzUKuhEtAel/lRVbf3uB4aH1jEZl7FE3EKwRyI5XdLJsLXAxyRrMrUOTXbAi9FxLSrRP9YHwBfocKMqCo= X-Received: by 2002:a05:6830:10d2:: with SMTP id z18mr1006403oto.90.1610540094506; Wed, 13 Jan 2021 04:14:54 -0800 (PST) MIME-Version: 1.0 References: <20210113120910.1258769-1-hjl.tools@gmail.com> In-Reply-To: <20210113120910.1258769-1-hjl.tools@gmail.com> From: "H.J. Lu" Date: Wed, 13 Jan 2021 04:14:18 -0800 Message-ID: Subject: Re: [PATCH] x86: Set header.feature_1 in TCB for always-on CET To: GNU C Library , Adhemerval Zanella Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3036.9 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 12:14:57 -0000 On Wed, Jan 13, 2021 at 4:09 AM H.J. Lu 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 > -- > 2.29.2 > This fixed: https://sourceware.org/bugzilla/show_bug.cgi?id=27177 I'd like to fix it for 2.33. Thanks. -- H.J.