[GIT PULL] rseq fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 8a46580128a02bdc18d7dcc0cba19d3cea4fb9c4 rseq/selftests: cleanup: Update comment above rseq_prepare_unload Various rseq ABI fixes and cleanups: use get_user()/put_user(), validate parameters and use proper uapi types, etc. Thanks, Ingo --> Mathieu Desnoyers (6): rseq: Use __u64 for rseq_cs fields, validate user inputs rseq: Use get_user/put_user rather than __get_user/__put_user rseq: uapi: Update uapi comments rseq: uapi: Declare rseq_cs field as union, update includes rseq: Remove unused types_32_64.h uapi header rseq/selftests: cleanup: Update comment above rseq_prepare_unload include/uapi/linux/rseq.h | 102 include/uapi/linux/types_32_64.h| 50 -- kernel/rseq.c | 41 +-- tools/testing/selftests/rseq/rseq.h | 24 ++--- 4 files changed, 100 insertions(+), 117 deletions(-) delete mode 100644 include/uapi/linux/types_32_64.h diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index d620fa43756c..9a402fdb60e9 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -10,13 +10,8 @@ * Copyright (c) 2015-2018 Mathieu Desnoyers */ -#ifdef __KERNEL__ -# include -#else -# include -#endif - -#include +#include +#include enum rseq_cpu_id_state { RSEQ_CPU_ID_UNINITIALIZED = -1, @@ -52,10 +47,10 @@ struct rseq_cs { __u32 version; /* enum rseq_cs_flags */ __u32 flags; - LINUX_FIELD_u32_u64(start_ip); + __u64 start_ip; /* Offset from start_ip. */ - LINUX_FIELD_u32_u64(post_commit_offset); - LINUX_FIELD_u32_u64(abort_ip); + __u64 post_commit_offset; + __u64 abort_ip; } __attribute__((aligned(4 * sizeof(__u64; /* @@ -67,28 +62,30 @@ struct rseq_cs { struct rseq { /* * Restartable sequences cpu_id_start field. Updated by the -* kernel, and read by user-space with single-copy atomicity -* semantics. Aligned on 32-bit. Always contains a value in the -* range of possible CPUs, although the value may not be the -* actual current CPU (e.g. if rseq is not initialized). This -* CPU number value should always be compared against the value -* of the cpu_id field before performing a rseq commit or -* returning a value read from a data structure indexed using -* the cpu_id_start value. +* kernel. Read by user-space with single-copy atomicity +* semantics. This field should only be read by the thread which +* registered this data structure. Aligned on 32-bit. Always +* contains a value in the range of possible CPUs, although the +* value may not be the actual current CPU (e.g. if rseq is not +* initialized). This CPU number value should always be compared +* against the value of the cpu_id field before performing a rseq +* commit or returning a value read from a data structure indexed +* using the cpu_id_start value. */ __u32 cpu_id_start; /* -* Restartable sequences cpu_id field. Updated by the kernel, -* and read by user-space with single-copy atomicity semantics. -* Aligned on 32-bit. Values RSEQ_CPU_ID_UNINITIALIZED and -* RSEQ_CPU_ID_REGISTRATION_FAILED have a special semantic: the -* former means "rseq uninitialized", and latter means "rseq -* initialization failed". This value is meant to be read within -* rseq critical sections and compared with the cpu_id_start -* value previously read, before performing the commit instruction, -* or read and compared with the cpu_id_start value before returning -* a value loaded from a data structure indexed using the -* cpu_id_start value. +* Restartable sequences cpu_id field. Updated by the kernel. +* Read by user-space with single-copy atomicity semantics. This +* field should only be read by the thread which registered this +* data structure. Aligned on 32-bit. Values +* RSEQ_CPU_ID_UNINITIALIZED and RSEQ_CPU_ID_REGISTRATION_FAILED +* have a special semantic: the former means "rseq uninitialized", +* and latter means "rseq initialization failed". This value is +* meant to be read within rseq critical sections and compared +* with the cpu_id_start value previously read, before performing +* the commit instruction, or read and compared with the +* cpu_id_start value before returning a value loaded from a data +* structure indexed using the cpu_id_start value. */ __u32 cpu_id; /* @@ -105,27 +102,44 @@ struct rseq { *
[GIT PULL] rseq fixes
Linus, Please pull the latest core-urgent-for-linus git tree from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-urgent-for-linus # HEAD: 8a46580128a02bdc18d7dcc0cba19d3cea4fb9c4 rseq/selftests: cleanup: Update comment above rseq_prepare_unload Various rseq ABI fixes and cleanups: use get_user()/put_user(), validate parameters and use proper uapi types, etc. Thanks, Ingo --> Mathieu Desnoyers (6): rseq: Use __u64 for rseq_cs fields, validate user inputs rseq: Use get_user/put_user rather than __get_user/__put_user rseq: uapi: Update uapi comments rseq: uapi: Declare rseq_cs field as union, update includes rseq: Remove unused types_32_64.h uapi header rseq/selftests: cleanup: Update comment above rseq_prepare_unload include/uapi/linux/rseq.h | 102 include/uapi/linux/types_32_64.h| 50 -- kernel/rseq.c | 41 +-- tools/testing/selftests/rseq/rseq.h | 24 ++--- 4 files changed, 100 insertions(+), 117 deletions(-) delete mode 100644 include/uapi/linux/types_32_64.h diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index d620fa43756c..9a402fdb60e9 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -10,13 +10,8 @@ * Copyright (c) 2015-2018 Mathieu Desnoyers */ -#ifdef __KERNEL__ -# include -#else -# include -#endif - -#include +#include +#include enum rseq_cpu_id_state { RSEQ_CPU_ID_UNINITIALIZED = -1, @@ -52,10 +47,10 @@ struct rseq_cs { __u32 version; /* enum rseq_cs_flags */ __u32 flags; - LINUX_FIELD_u32_u64(start_ip); + __u64 start_ip; /* Offset from start_ip. */ - LINUX_FIELD_u32_u64(post_commit_offset); - LINUX_FIELD_u32_u64(abort_ip); + __u64 post_commit_offset; + __u64 abort_ip; } __attribute__((aligned(4 * sizeof(__u64; /* @@ -67,28 +62,30 @@ struct rseq_cs { struct rseq { /* * Restartable sequences cpu_id_start field. Updated by the -* kernel, and read by user-space with single-copy atomicity -* semantics. Aligned on 32-bit. Always contains a value in the -* range of possible CPUs, although the value may not be the -* actual current CPU (e.g. if rseq is not initialized). This -* CPU number value should always be compared against the value -* of the cpu_id field before performing a rseq commit or -* returning a value read from a data structure indexed using -* the cpu_id_start value. +* kernel. Read by user-space with single-copy atomicity +* semantics. This field should only be read by the thread which +* registered this data structure. Aligned on 32-bit. Always +* contains a value in the range of possible CPUs, although the +* value may not be the actual current CPU (e.g. if rseq is not +* initialized). This CPU number value should always be compared +* against the value of the cpu_id field before performing a rseq +* commit or returning a value read from a data structure indexed +* using the cpu_id_start value. */ __u32 cpu_id_start; /* -* Restartable sequences cpu_id field. Updated by the kernel, -* and read by user-space with single-copy atomicity semantics. -* Aligned on 32-bit. Values RSEQ_CPU_ID_UNINITIALIZED and -* RSEQ_CPU_ID_REGISTRATION_FAILED have a special semantic: the -* former means "rseq uninitialized", and latter means "rseq -* initialization failed". This value is meant to be read within -* rseq critical sections and compared with the cpu_id_start -* value previously read, before performing the commit instruction, -* or read and compared with the cpu_id_start value before returning -* a value loaded from a data structure indexed using the -* cpu_id_start value. +* Restartable sequences cpu_id field. Updated by the kernel. +* Read by user-space with single-copy atomicity semantics. This +* field should only be read by the thread which registered this +* data structure. Aligned on 32-bit. Values +* RSEQ_CPU_ID_UNINITIALIZED and RSEQ_CPU_ID_REGISTRATION_FAILED +* have a special semantic: the former means "rseq uninitialized", +* and latter means "rseq initialization failed". This value is +* meant to be read within rseq critical sections and compared +* with the cpu_id_start value previously read, before performing +* the commit instruction, or read and compared with the +* cpu_id_start value before returning a value loaded from a data +* structure indexed using the cpu_id_start value. */ __u32 cpu_id; /* @@ -105,27 +102,44 @@ struct rseq { *