Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3597165pxb; Fri, 4 Feb 2022 12:01:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy50jMAaq0SNsTje/2ljAUozGT9FfmJ5yyIvKmL5dUK3LpCG5XN4V4w4MrhrPNa28nnPR3O X-Received: by 2002:a05:6402:2683:: with SMTP id w3mr777553edd.405.1644004870010; Fri, 04 Feb 2022 12:01:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644004870; cv=none; d=google.com; s=arc-20160816; b=Rc5r7zlWOhjvmI/oyo0KKaclsFUZTv7PuWFkuvcj6+Q/KgWN7idWC4C4vvAJ+fHJkf by/rNIEXzLXnV4ZvykXnfm/eMVOjKZ4YKJ0fAstCVBoOH8b5ie6vEA8KC1B/cqgSRcfC MmpOLTMXO8C5a/PblmkoEW/3tXwQO+9iDB88R4eXupFh5m/JijM/fZ6BOPEcPDxNrbrP NmMSzJnuyFyhRIu7abZ7nsiJECfgM0zfQ7lX1EnHPmRGxaPfYB3+wm6cMKn6BW0UFpmL v0lxl+i/+HUdbfAgNajlNBEqC4jWAxCHt5Quu8jjFG3q/17bqzkYLP9vnWPuXnkywZUy W0wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=BioWaSozmqqbtmvJnfrlpWvhCFvnAXGhaRyjzgR7bfg=; b=E7AYBQdLDMlE6VC0dPpatU4w+Ixx+sfDz2hHlyiZIRmATYMH60FpTMFIvs+RjLufx4 c2Js2dMOUhAY2/DTAme4e4c3FS+Qbzl+FqFfTCosdxPZAtwJXypvtflHAWS7Ar36uoN+ WF0OychZZvvO5k3eWqcsmybjUpoPVmHoeUUCq02xIYeFjeRzV6niiv1G8chI7Clc7+We Kq1EpD4iaDDpsEgX6a1atQQ8Ii1QExEzoPp3iAF7IwisEVcBvwYOvd/c1a/oLXRceF3H Z3yimMaPapLFJiFlr3Kv5ZLPBZGYjeDegeIn3hUbMw4w6ahxrUj6BMhqvSndXZt0j+Yh 2iKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=SdFEHycY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e26si1707297ejm.605.2022.02.04.12.00.44; Fri, 04 Feb 2022 12:01:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=SdFEHycY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353787AbiBCTjF (ORCPT + 99 others); Thu, 3 Feb 2022 14:39:05 -0500 Received: from mail.efficios.com ([167.114.26.124]:53806 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346461AbiBCTjD (ORCPT ); Thu, 3 Feb 2022 14:39:03 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 8C288392552; Thu, 3 Feb 2022 14:39:02 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id nkHqmIsvE4lW; Thu, 3 Feb 2022 14:39:02 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 20E603923B7; Thu, 3 Feb 2022 14:39:02 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 20E603923B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1643917142; bh=BioWaSozmqqbtmvJnfrlpWvhCFvnAXGhaRyjzgR7bfg=; h=From:To:Date:Message-Id; b=SdFEHycYEa+7Z+NvBVlJriTZEZCOLwAI/dARqBJOqu8OQVxuxI57nfQQFvSQqjvCw igf57TiKyM5ClrmmJnSqYObALWB+meoH8Ah9dAhDCKiLjOcp+pw4OLOkSSskHJDRjG U4gmLy2CniAb8rhEPjTTosPc+63pMlvLBpYdHomm9ESFY4MugkbmQGqJkAt3xeAb6C t30aifEdvnAsPv77LVwhbxVYofNRhvlVQf+jsJFCEAKkafUNE2UkPYdiy18iuE3sFR bAHBrJRRRHmyRYl6FJIgYOT+B9Ga6u0KRWOJP+bCA/2H4aj7x9d2ihLV8wymWrRTlQ vfXIatugqgwXQ== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6JglWsGeGj90; Thu, 3 Feb 2022 14:39:02 -0500 (EST) Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by mail.efficios.com (Postfix) with ESMTPSA id 993B7392172; Thu, 3 Feb 2022 14:39:01 -0500 (EST) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , libc-coord@lists.openwall.com, Mathieu Desnoyers Subject: [RFC PATCH 1/3] rseq: Introduce feature size and alignment ELF auxiliary vector entries Date: Thu, 3 Feb 2022 14:38:51 -0500 Message-Id: <20220203193853.21511-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Export the rseq feature size supported by the kernel as well as the required allocation alignment for the rseq per-thread area to user-space through ELF auxiliary vector entries. This is part of the extensible rseq ABI. Signed-off-by: Mathieu Desnoyers --- fs/binfmt_elf.c | 5 +++++ include/uapi/linux/auxvec.h | 2 ++ include/uapi/linux/rseq.h | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 605017eb9349..77776582e76d 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -286,6 +287,10 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, if (bprm->have_execfd) { NEW_AUX_ENT(AT_EXECFD, bprm->execfd); } +#ifdef CONFIG_RSEQ + NEW_AUX_ENT(AT_RSEQ_FEATURE_SIZE, offsetof(struct rseq, end)); + NEW_AUX_ENT(AT_RSEQ_ALIGN, __alignof__(struct rseq)); +#endif #undef NEW_AUX_ENT /* AT_NULL is zero; clear the rest too */ memset(elf_info, 0, (char *)mm->saved_auxv + diff --git a/include/uapi/linux/auxvec.h b/include/uapi/linux/auxvec.h index c7e502bf5a6f..6991c4b8ab18 100644 --- a/include/uapi/linux/auxvec.h +++ b/include/uapi/linux/auxvec.h @@ -30,6 +30,8 @@ * differ from AT_PLATFORM. */ #define AT_RANDOM 25 /* address of 16 random bytes */ #define AT_HWCAP2 26 /* extension of AT_HWCAP */ +#define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size */ +#define AT_RSEQ_ALIGN 28 /* rseq allocation alignment */ #define AT_EXECFN 31 /* filename of program */ diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index 77ee207623a9..05d3c4cdeb40 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -130,6 +130,11 @@ struct rseq { * this thread. */ __u32 flags; + + /* + * Flexible array member at end of structure, after last feature field. + */ + char end[]; } __attribute__((aligned(4 * sizeof(__u64)))); #endif /* _UAPI_LINUX_RSEQ_H */ -- 2.17.1