Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2201970rwi; Thu, 3 Nov 2022 14:03:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4VfHfPi2SG/nx2SBaMYlywYnz3TsmKj92HCpOs1U58qfJIv19r57Qp4iIj9ERTAytm7ZyQ X-Received: by 2002:a17:90b:1212:b0:213:a3a4:4d97 with SMTP id gl18-20020a17090b121200b00213a3a44d97mr32591297pjb.225.1667509390081; Thu, 03 Nov 2022 14:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667509390; cv=none; d=google.com; s=arc-20160816; b=w0LAl9vYKhvync0hA3FnggtV6WRt80UL9mYSkCcYVzrG/SHL/x61TG8ncpX5O//fYN PNF91Ch5Rcu0BRNe/sQKD8N+A20CYyi64IQClCVC4igM9anx4j8ELo4HO33fy03OGGLW bsecs/U71xto7zfXAXflDRBh3fLh53ptx8QngljqLrIitDeLwnPF9NGFNcnd3sQVntrK Chjy/BINY6B3iMkcjpXUqqCfvh3U6T2JT8BUbUvGPEl0IAju/0n6NrA+1Jp+d39qOdnN qnAFfcEe38nY+df2Nmg7Y3O2QTHD/FDnmiPND0jQyYVyywzdyXclHR/qg+BA4AwYtDY/ DNeA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a170903244a00b00187075ae5f6si2265834pls.461.2022.11.03.14.02.52; Thu, 03 Nov 2022 14:03:10 -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 + 97 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 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