Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5806198rwb; Wed, 21 Sep 2022 12:42:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UlwGT5ikyvdjarRdZ61PdUf83ASXLWSMc2g8OJjBlwqGY49XM47MqFfhoeHpOYflK7KjO X-Received: by 2002:a17:906:5a5a:b0:770:86d0:fd8 with SMTP id my26-20020a1709065a5a00b0077086d00fd8mr22487859ejc.164.1663789377183; Wed, 21 Sep 2022 12:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663789377; cv=none; d=google.com; s=arc-20160816; b=DEYHBY+6Go20rie6NlCyttdtTaBtb3zWUsOcc1fnvk2NL78eO7NcyCYRJfp8jNNsyK eMmXlB8JqsUCeAb+O15dDB4mNbcjOjVkObPadcx33bMP2naMM53WWzPmdVB/gpJxHh3a bplLmSuenfewFzazWvBWG5jlMvdBKeLo37AXe9TckbbyAlrYYxnrR5I1gmBc4vMncVyR S7UVKbZa0vi5PTz9vN08nTWDrS5QZNU2gDoOiiEoecmNr9tClo03oepXXjqWR6R98QQR SxmSKh31heVkai9Nd01qSdVeZtwptke/4rvAFlmWvakPgLxvC7RGWiVbZXXOZGu7Cfum QA7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=i6XTSsk7DOXSZF3ceW0m6RsyJxZFbIzbQ8FhLufxsXs=; b=fhR4SsCMJjv0MxlD8imKYLGv+OHZ3uhEDYAs7O6Qt8jfNOxD21nIe9w9LphzY/p2ys ovhuPiECedDBBViQbwhS7TyeryToeYAEYnQju+78qt+kdarjJIB/S0jfA+PxjS/nEsYn 5yuIgPHtp44m2g8a7nRl1hdAhV5U6OpvQq6KGkIJR/5mgw2wUlRCT3Qish9iFiuEpbpd 7FG64iP8CRiQ0QmalcWorTmsZSglwr+6AkaSmtCff6Jlok0Ej8AOtzhZclclbJYKkHNi cHEgxVw+PwO+dbAHiUca/Sr9f456CjN0GDCE84ZznX0+8snu+ZIQbzysj+MM5WG8Vf1n 43Hg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 j9-20020a170906254900b007741ea197c4si2823540ejb.172.2022.09.21.12.42.30; Wed, 21 Sep 2022 12:42:57 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbiIUTiS (ORCPT + 99 others); Wed, 21 Sep 2022 15:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiIUTiE (ORCPT ); Wed, 21 Sep 2022 15:38:04 -0400 Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48CBD9E693 for ; Wed, 21 Sep 2022 12:38:02 -0700 (PDT) X-ASG-Debug-ID: 1663788303-0c856e13fd3500a0001-xx1T2L Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id vKxaDsCJ59XdehvH (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Wed, 21 Sep 2022 15:25:03 -0400 (EDT) X-Barracuda-Envelope-From: mathieu.desnoyers@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 4B86D441D64; Wed, 21 Sep 2022 15:25:03 -0400 (EDT) From: Mathieu Desnoyers X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 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 , Alexander Mikhalitsyn , Mathieu Desnoyers Subject: [RFC PATCH v4 01/25] rseq: Introduce feature size and alignment ELF auxiliary vector entries Date: Wed, 21 Sep 2022 15:24:30 -0400 X-ASG-Orig-Subj: [RFC PATCH v4 01/25] rseq: Introduce feature size and alignment ELF auxiliary vector entries Message-Id: <20220921192454.231662-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220921192454.231662-1-mathieu.desnoyers@efficios.com> References: <20220921192454.231662-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1663788303 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2197 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.100943 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 63c7ebb0da89..04fca1e4cbd2 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -288,6 +289,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.25.1