Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6406983rwb; Tue, 22 Nov 2022 12:58:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7OaI3IqufeXMpR+WvuvaIvC78iufyPQsQhp4ZTXLLDSFUZaN7HeKkqG+ljWMRqjvOh09r5 X-Received: by 2002:a17:902:e8c3:b0:187:3c31:fb3a with SMTP id v3-20020a170902e8c300b001873c31fb3amr5812172plg.38.1669150715341; Tue, 22 Nov 2022 12:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150715; cv=none; d=google.com; s=arc-20160816; b=xBGkAEH8+lzl6ryWbsUaBp/cENQuWK4zw+zzQiBmOALHaQyWroaDkg1UpvdG1iNGrP E58U6miNQcbCX4xbR7NS7OsI7t9Le2JWO7O693pKYtDi1uc2udTbRyWGllHo7Yy7kPWe 6sE+JjVZMFWoWQ8A49Dksp8LTmk2EucKvZlTLLsiut3QIaKrW3fBQ1LIVxRvqgDW/aXP JMdCSl6Vkx3wb+E2WNq568FtZlJSYJo0JX5k4R4RAcf/zCS7jmrwNe/vhm+w8WbLJ1M2 2hxQHzu9WIZFWKBLNu/aWnOcvUNwwvuvjdydfprDcbHzNEIYII0wVYoMjv/9jEnK1XY6 Uezw== 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 :dkim-signature; bh=i6XTSsk7DOXSZF3ceW0m6RsyJxZFbIzbQ8FhLufxsXs=; b=gbB/GnIcPouRMcoQ17OHFi7arhr2Bpy/NHz4hQUmMl/AhCpVODVOwbTm01/SoDmSyY s+OMTdeao57zmUsQMsum0b6wHqxusqfK/z78USBaoUxeJpbGapv29gUXHMvoRJcOTUxd /Lwkc0Yxl6wcoc38ahx1QeuzhPS+/WTZKOGMxQU07LSkdmNColzDic7zYgOLAkgLve4f eyRoeHdsGIJekZ6pzs8xfj4llb3AE7fu0gGUN6cH+NqUCFHCvCkRRY04IvFnIGJHDT1n apBopcmyOQ7hvKzjKSfc+PLpKRTmowNp2DcZ3nfRTx/t5TP8MrBi5P/iKX8elTjMDrL2 Jrmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=q9bdwhko; 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 ij28-20020a170902ab5c00b00182bccf6195si14139432plb.596.2022.11.22.12.58.24; Tue, 22 Nov 2022 12:58:35 -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=smtpout1 header.b=q9bdwhko; 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 S234933AbiKVUkE (ORCPT + 89 others); Tue, 22 Nov 2022 15:40:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbiKVUju (ORCPT ); Tue, 22 Nov 2022 15:39:50 -0500 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54873725E0; Tue, 22 Nov 2022 12:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1669149585; bh=3FQzak7NFQCeQ17sM6xyWBPLJooy+CEjUwRxboNNo2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9bdwhkoIOl3a0a7KUDXD2xTHcVGHLg70EzMk8dzd7kKvWoiP9zK1zw0uOUsB0w0Y 0gkW7B7aYlcWy75DJWmWiQ+yFiEF6zhGY0++WOyErXmhRKXD/3wNRgHZZ9zX2yA6+O ZAFi7p5Wr3/JKQY5OGjfZ7t0eKpB7H9J7+pylRJ2+FtSTP90X8j0Dp6j+jt7HZNi2l WNvM5bxlU5+wck+OMG26oaEgnPxB5tykmc5N8x5NO8mA3wbhVIPtuWaiEVH6pwt6tc FFZLxBfY6c3WY3fPNYkX7Jiw60mnAAMMdPR9n3u4/DP1EnBwxAv6Zxuka5JFLkRIK+ punpFFYFoLKmg== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4NGx2S6wLhzXR9; Tue, 22 Nov 2022 15:39:44 -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 , Alexander Mikhalitsyn , Chris Kennelly , Mathieu Desnoyers Subject: [PATCH 02/30] rseq: Introduce feature size and alignment ELF auxiliary vector entries Date: Tue, 22 Nov 2022 15:39:04 -0500 Message-Id: <20221122203932.231377-3-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> References: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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