From patchwork Mon Sep 23 14:19:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 13809669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D918CF9C69 for ; Mon, 23 Sep 2024 14:20:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE5C96B0092; Mon, 23 Sep 2024 10:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E96916B0093; Mon, 23 Sep 2024 10:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D361A6B0095; Mon, 23 Sep 2024 10:20:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B8F7B6B0092 for ; Mon, 23 Sep 2024 10:20:11 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 68AD81413AF for ; Mon, 23 Sep 2024 14:20:11 +0000 (UTC) X-FDA: 82596212622.03.588FEF5 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id A1A82160010 for ; Mon, 23 Sep 2024 14:20:09 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of vincenzo.frascino@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727101175; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WnOCHp36Q6JihrxxvZmj8QU5R2HrAmjfFlnctnQM/d8=; b=0e7VIi4myOyU5SxhvKSHeA2R1H5j2+U3/ceo4Y6ncjHhhIZLl3qdviE8ZdfF6SpHqD3mYG U+BUv3w9j4kZtCXtBBWuFauf2Zk9UNb80jwPw4etLKc+5Z9Ja0hL/eiMC6XpVBH9XVKCKo CPQhficZDFCPnwUpG3jC5whgK0P2Tt0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of vincenzo.frascino@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727101175; a=rsa-sha256; cv=none; b=r37VU7sKuU1cEIegxJIDoC/qR0mc7jNSVjibZSVOha/cHdAaR1LlfPhlg9Pmc3G6w9fA4w lLwmrhg9vDCmD9gWqytBS7A4scltexrwZdGA4jnaQ9Mh+2lgJCQL/xj9KV54MKjJWVH4K/ 2cKWzfSq3BKXhks9VabOJJdLD56sLuw= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6BCCB11FB; Mon, 23 Sep 2024 07:20:38 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 82CB13F64C; Mon, 23 Sep 2024 07:20:06 -0700 (PDT) From: Vincenzo Frascino To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Vincenzo Frascino , Andy Lutomirski , Thomas Gleixner , "Jason A . Donenfeld" , Christophe Leroy , Michael Ellerman , Nicholas Piggin , Naveen N Rao , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Theodore Ts'o , Arnd Bergmann , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Subject: [PATCH v2 7/8] vdso: Introduce uapi/vdso/random.h Date: Mon, 23 Sep 2024 15:19:42 +0100 Message-Id: <20240923141943.133551-8-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240923141943.133551-1-vincenzo.frascino@arm.com> References: <20240923141943.133551-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 793z4kr5e4ky7bg4gtzutj9moxogky7s X-Rspamd-Queue-Id: A1A82160010 X-Rspamd-Server: rspam11 X-HE-Tag: 1727101209-844748 X-HE-Meta: U2FsdGVkX18CxZH/vd8Sq8yoeTyvz8qqQNLfckcZzPmJjQbLN78pJB0LE5LTigY4P1t60PAQ9LNMDahIJJLhTABEdFtESJ+eeVMIVAHUtpIR735ZhqXucwRh0D5YsGeeDY30rkMFDRe5+2G1TRkAb+4NqjHFrnaSe9j/ko/0+Jxpd7FLqIS06mf9jlW0QqM8ElM0lWapzMK3HiJfQg/gqQsn//kwdZTpc+VpKFpsmLaEKMbDl9tFnohVFU2CdwmREZPM0VZnakb0srXi8j3eDkJoYyssjeQLy1BHrZ1VDTpapebv8gP3VmaqJWRS26XQZkIb1HAcYmxcqjw2mZIDGhAmIKHFbqUwVLXieRK1FS1bv2M+aAEInxrWUC9ZyPVFB3C8CDpvpHnmWL8XBxdPSItuYCbK2Rj69yDnWsuUu8kKG2GjK5fVdmmRtooi2tl1rm4G14NP6lO5pWamgmF73npsX1Uz1QAIxBYQAwFDDjJiYasA4ZMHbbD5fKyFkXhE3S17520QZaPiGCN1ZqWiGREG/OnWXrlHxCpazxCCGmFMHZ8sgUjlRut+auVacL/HCwF5G6dUAM+VG2/DpCsBog/FeDyx/280zG1OTdn5+lH2lNTFrwZfK+E4PaFNUbEZZ78BaMXJrv1FHukQExSeFVI3eIpMnbSOKcrJN6rvFleJ+q/H4rQgFAdzOeDsboGgg93SXTvDptL67ckcsGaZJh1a70fT0lU3IJws67HqfqnnqRQjFxrg7cz8u3DMTyBaAwP75Yp9cYU+c3IGxqq7+oeSvtnaJsDe9xiUP1KigYUMwyxE/uw5eT+3Y2zID0OvJVRE22QkTdzSlhIvJZ6RItQBW0WBAezU9RqPzVNv3X4BgkrwP5gbrAymPsyl/jmyT+KkYzgL7WUFpygxWEo5STJWOUNUEnMv5RyhXeAmetLtHSxD8Q7KazGO1dlkVgH64hH8azdrM3WJO+kamFh Hqlm5c/S 3rZEYYbjsb4gVyZXaAxPGDpSfJD1N1X3LJv7ia8o0Qz4gzp2gB2RrQyOsdxaJ3ycrcq0IkuZ6OI7s34UgrPRgEzVJTfWCZa/a/B5xYVlmn1l7s704ymEJ+fwLdE0JO77EJ/R3Qy88o2OWmVc2PnQC4lu/zc58JSmmEzujamXiZbD9h1EtHtmsxA5KcG9euCEl6ku1+ZaMg/uDgxTHESr718RpZpeU3dG/k8NX6npnVCJEPsI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The VDSO implementation includes headers from outside of the vdso/ namespace. Introduce uapi/vdso/random.h to make sure that the generic library uses only the allowed namespace. Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Jason A. Donenfeld Signed-off-by: Vincenzo Frascino --- include/uapi/linux/random.h | 26 +------------------------ include/uapi/vdso/random.h | 38 +++++++++++++++++++++++++++++++++++++ include/vdso/datapage.h | 1 + 3 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 include/uapi/vdso/random.h diff --git a/include/uapi/linux/random.h b/include/uapi/linux/random.h index 1dd047ec98a1..dc43ed800212 100644 --- a/include/uapi/linux/random.h +++ b/include/uapi/linux/random.h @@ -44,30 +44,6 @@ struct rand_pool_info { __u32 buf[]; }; -/* - * Flags for getrandom(2) - * - * GRND_NONBLOCK Don't block and return EAGAIN instead - * GRND_RANDOM No effect - * GRND_INSECURE Return non-cryptographic random bytes - */ -#define GRND_NONBLOCK 0x0001 -#define GRND_RANDOM 0x0002 -#define GRND_INSECURE 0x0004 - -/** - * struct vgetrandom_opaque_params - arguments for allocating memory for vgetrandom - * - * @size_per_opaque_state: Size of each state that is to be passed to vgetrandom(). - * @mmap_prot: Value of the prot argument in mmap(2). - * @mmap_flags: Value of the flags argument in mmap(2). - * @reserved: Reserved for future use. - */ -struct vgetrandom_opaque_params { - __u32 size_of_opaque_state; - __u32 mmap_prot; - __u32 mmap_flags; - __u32 reserved[13]; -}; +#include #endif /* _UAPI_LINUX_RANDOM_H */ diff --git a/include/uapi/vdso/random.h b/include/uapi/vdso/random.h new file mode 100644 index 000000000000..5c80995129c2 --- /dev/null +++ b/include/uapi/vdso/random.h @@ -0,0 +1,38 @@ + +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * include/vdso/random.h + * + * Include file for the random number generator. + */ + +#ifndef _UAPI_VDSO_RANDOM_H +#define _UAPI_VDSO_RANDOM_H + +/* + * Flags for getrandom(2) + * + * GRND_NONBLOCK Don't block and return EAGAIN instead + * GRND_RANDOM No effect + * GRND_INSECURE Return non-cryptographic random bytes + */ +#define GRND_NONBLOCK 0x0001 +#define GRND_RANDOM 0x0002 +#define GRND_INSECURE 0x0004 + +/** + * struct vgetrandom_opaque_params - arguments for allocating memory for vgetrandom + * + * @size_per_opaque_state: Size of each state that is to be passed to vgetrandom(). + * @mmap_prot: Value of the prot argument in mmap(2). + * @mmap_flags: Value of the flags argument in mmap(2). + * @reserved: Reserved for future use. + */ +struct vgetrandom_opaque_params { + __u32 size_of_opaque_state; + __u32 mmap_prot; + __u32 mmap_flags; + __u32 reserved[13]; +}; + +#endif /* _UAPI_VDSO_RANDOM_H */ diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h index b85f24cac3f5..b7d6c71f20c1 100644 --- a/include/vdso/datapage.h +++ b/include/vdso/datapage.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include