From patchwork Thu Nov 3 20:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 15155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp741936wru; Thu, 3 Nov 2022 13:05:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62HCpj5IA8tgSBnXoA9nNqXevSgSILhb+151RR3/qGmSwyc6iQP+fhlh44+b+hG5lBYGjg X-Received: by 2002:a63:85c8:0:b0:46e:c387:c85f with SMTP id u191-20020a6385c8000000b0046ec387c85fmr27392650pgd.105.1667505930218; Thu, 03 Nov 2022 13:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667505930; cv=none; d=google.com; s=arc-20160816; b=mJwKvWmXiVbEjVZnDQ/szpGFUH4Z/A6jzY3Ora683F742nRbFbURq21RbZqi9yfGDO Ctb0h4scaHTuvyMl422lc9O1RCqyzlquh+vq+FyZnRbr9klsohfK7ULmvs575RCOemwh 2+CwXdy4Q+g1PQUNmQHzc0IYrnEPbJfE+ZlFOblt4xQx8DSJmL0Y+JdyzQDao+aYAQlL CJeN9AoWVhKncVpvP8zOCoFifvz0bBMlSG1QA/gjPCfSxLdQePtCL3vulgMQvfgb3+pU b/VxLoUtXMwaPiH0Vs+yvY39ZvQoRLomtr/wOZpt0Wm5zjakK7D13/VM6A4cVpYrES67 lrfA== 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=GvccEFpbOxkOKJkLTzF7FtGQHr2da8aaiFLwZrbA8NIXEhvnrUxMBkvR9+DkzC5jaT 9gE1kCQ/uWy3S92Sd3urZ6HcTTQ9vp5obNL22dGyAc3c4D34FZLiD+3GJFyH+EHY0Yp8 zuFu1WtlRV+otsp+mV4Ts1liWQR0PIAHQiXbY8DoBitSLP+fgvA0arivP11vTeF3C6+y CxoBzYoiDnl8AMsCzL1ACAApDUpAvcPBBbTNQayGz8zAbdHK1Yr1GJgZRvCcfU6zVFtP O7GOPLk26e/h+dUV8Qc5uXMiEBONWGK9CCGkLVBf7CGSROzcV4TKAYfUINfwCOPfCJwl HVzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=dAmf0mXn; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a170902ed0b00b001868a61d507si1538828pld.180.2022.11.03.13.05.16; Thu, 03 Nov 2022 13:05:30 -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; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=dAmf0mXn; 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 S231215AbiKCUFD (ORCPT + 99 others); Thu, 3 Nov 2022 16:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbiKCUE6 (ORCPT ); Thu, 3 Nov 2022 16:04:58 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C8D720341; Thu, 3 Nov 2022 13:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1667505895; bh=3FQzak7NFQCeQ17sM6xyWBPLJooy+CEjUwRxboNNo2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAmf0mXn5RkJ3x6/KHkopdNJXvvg2iobvcOjLiAfAsqWc/33JXzDgWwpOQqfJWfbf oGyzaCqlz2ksF+qFWZnjm6wKXPg8OtJtbLDp4o+Em1BaqgM7MbIhddYe0O/NwPiVJe N0I2On7stcX1xBs9vX45gnhiZBSeeOdpwxOYQT7j9kGxU0WbusCImSkt7P6KS9dmCh ZDvT7OH7QoTUfVQY329rInsldiBI7wXmRcf+M2P2ziYG98jQlFUHBcLz7DjlpeYFDQ YIQPjSg6SXXzqcbpur378S0JQ1CpRZjlRSXFSl98bKi6/IrGplV5pgk1IR+5d/5uNk oxDOghXPopc0Q== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4N3F93273NzfW5; Thu, 3 Nov 2022 16:04:55 -0400 (EDT) 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 v5 01/24] rseq: Introduce feature size and alignment ELF auxiliary vector entries Date: Thu, 3 Nov 2022 16:03:36 -0400 Message-Id: <20221103200359.328736-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103200359.328736-1-mathieu.desnoyers@efficios.com> References: <20221103200359.328736-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748506697893122386?= X-GMAIL-MSGID: =?utf-8?q?1748506697893122386?= 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 */