From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 5F656383F850; Wed, 13 Jan 2021 13:06:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5F656383F850 Received: by mail-ot1-x32e.google.com with SMTP id d20so1811406otl.3; Wed, 13 Jan 2021 05:06:49 -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:cc; bh=VN3t764qtQfEsuhLpTbXWxSLvDGTnfG1Fgk+R5r8ikQ=; b=Gp1ESRq555qsb6P9XI+fUG+BDqzeJkq5mSy+EgOpRgWNBdGYY3CH34xwamzAQ7vCer 7feeHL65oNfyz4U70Cm0LsYzJpZF/AhC5pLnfE9Gvvt/Hk2fytZINUwRViCingi7BVde IWutuuS3pHi8XStDhCLeyUiYpIi284KmTVOcRW0p2jMj0XrVWAFPOPHKfpZ5+F3RjQAy PANQ8haXboLoIrFrnLPyOT5+XxFdeMm05sRChQAKhYlsfaOstmXRBWTI4D4n0wgsk5j5 3rRzfUEFqIkIVEyeTJlwPnfO3T3sHOJ+j73fECp2nphOOUtmvvWMUnipr8ZSqm3iUak+ KABQ== X-Gm-Message-State: AOAM530vTNgmKF1UbCgEoPx9Lj4gpJZ3/uKz0VhMMByMPeRB5/H59ipt NcUPGqrTBrv+aBz2cHLdh4vPYstlazx7AccmRQo= X-Google-Smtp-Source: ABdhPJylKrJx+Sca14tm9fzRhzD+rL6e+l3ZJQxXYV0/i8zm3e0aKy83XaYfQQszITQkDjGvCqcOpi9u6qk9IZ7g50Q= X-Received: by 2002:a05:6830:1d71:: with SMTP id l17mr1096219oti.269.1610543208747; Wed, 13 Jan 2021 05:06:48 -0800 (PST) MIME-Version: 1.0 References: <20210113120910.1258769-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Wed, 13 Jan 2021 05:06:12 -0800 Message-ID: Subject: [BACKPORT] [PATCH] x86: Set header.feature_1 in TCB for always-on CET To: Adhemerval Zanella , Libc-stable Mailing List Cc: GNU C Library , Adhemerval Zanella Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3036.7 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-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 13:06:52 -0000 On Wed, Jan 13, 2021 at 4:58 AM Adhemerval Zanella wrote: > > > > On 13/01/2021 09:14, H.J. Lu wrote: > > 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. > > > > Ok for 2.33. I am backporting it to release branches. Thanks. -- H.J.