This rebases the patch on kernel 6.1 and slightly reworks it.
Indeed, it removes some defines that are now consolidated in the generic
compat header, and now takes advantage that COMPAT_MINSIGSTKSZ is defined
in linux/compat.h if it is not already.
Teo Couprie Diaz (2):
arm64: compat: Remove defines now in asm-generic
compat: update compat defines to 64-bits
arch/arm64/include/asm/compat.h | 6 ++----
include/asm-generic/compat.h | 10 ++++++++++
2 files changed, 12 insertions(+), 4 deletions(-)
--
2.25.1
Hi All,
This series are modifications in kselftests required to compile
with alpha version of Morello Gnu toochain recently released [1].
The whole series can also be found here [2].
Thanks,
Amit Daniel
[1]: https://developer.arm.com/downloads/-/arm-gnu-toolchain-for-morello-downloa…
[2]: git@git.morello-project.org:amitdaniel/linux.git gcc_kselftests_support_v1
Amit Daniel Kachhap (4):
kselftests/arm64: morello: Fix the operand mismatch error
kselftests/arm64: morello: Define uintcap_t if not defined
kselftests/arm64: morello: Initialize the dynamic relocations
kselftests/arm64: morello: Enable Gcc toolchain support
.../testing/selftests/arm64/morello/Makefile | 12 +-
.../selftests/arm64/morello/bootstrap.c | 4 +-
.../selftests/arm64/morello/freestanding.c | 7 +
.../selftests/arm64/morello/freestanding.h | 3 +
.../arm64/morello/freestanding_init_globals.c | 149 +++++++++++++++++-
.../arm64/morello/freestanding_start.S | 5 +-
6 files changed, 166 insertions(+), 14 deletions(-)
--
2.25.1
as_user_ptr() is intended to be used where an arbitrary integer e.g. an
error code is stored in a __user ptr.
The current implementation can be somewhat confusing in that it looks
like it can be used as direct replacement for u64_to_user_ptr e.g. in
PCuABI, where u64 addresses in the kernel-user interface are being
replaced with capability containing types such as __kernel_uintptr_t.
Currently, passing a valid capability represented as an integer e.g. any
__kernel_uintptr_t, __uintcap_t or user_uintptr_t to as_user_ptr() will
result in a cast to (void __user *) and a valid capability/pointer that
can be dereferenced. This is contrary to the code comment and intended
usage for as_user_ptr().
Add a cast to (u64) before the cast to (void __user *)(user_uintptr_t)
to make clearer the intended usage. This also always results in a null
capability that cannot be dereferenced.
Signed-off-by: Zachary Leaf <zachary.leaf(a)arm.com>
---
Documentation/core-api/user_ptr.rst | 6 +++---
include/linux/user_ptr.h | 5 +++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/Documentation/core-api/user_ptr.rst b/Documentation/core-api/user_ptr.rst
index 21e02d4bd11b..e4cc0676a92b 100644
--- a/Documentation/core-api/user_ptr.rst
+++ b/Documentation/core-api/user_ptr.rst
@@ -103,7 +103,7 @@ Each function covers a particular category of input integer:
* **Arbitrary integer**:
- - Integer of any type: ``as_user_ptr()``
+ - 64-bit or less integer, of any type: ``as_user_ptr()``
- ``u64`` (deprecated): ``u64_to_user_ptr()``
These functions are available in ``<linux/user_ptr.h>``, except
@@ -141,8 +141,8 @@ derived from in the PCuABI case.
| | | user-provided | | pointer to a native user pointer. |
| | | ``compat_*`` struct | | |
+------------------------------+--------------------+------------------------+-----------------------------------+------------------------------------------------------+
-| ``as_user_ptr()`` | Arbitrary integer | Error code | Null capability | This is a pure representation change, as suggested |
-| | | | | by the ``as_`` prefix. The resulting pointer cannot |
+| ``as_user_ptr()`` | Arbitrary 64-bit | Error code | Null capability | This is a pure representation change, as suggested |
+| | or less integer | | | by the ``as_`` prefix. The resulting pointer cannot |
| | | | | be dereferenced. |
+------------------------------+--------------------+------------------------+-----------------------------------+------------------------------------------------------+
| ``u64_to_user_ptr()`` | ``u64`` integer | [Deprecated] | Null capability | Legacy function, new callers should not be added. |
diff --git a/include/linux/user_ptr.h b/include/linux/user_ptr.h
index 0942b58cfb6a..183e40ccc51f 100644
--- a/include/linux/user_ptr.h
+++ b/include/linux/user_ptr.h
@@ -9,13 +9,14 @@
#endif
/**
- * as_user_ptr - convert an arbitrary integer value to a user pointer
+ * as_user_ptr - convert an arbitrary 64-bit or less integer value to a user
+ * pointer
* @x: the integer value to convert
*
* Returns @x represented as a user pointer. The result is not a valid pointer
* and shall not be dereferenced.
*/
-#define as_user_ptr(x) ((void __user *)(user_uintptr_t)(x))
+#define as_user_ptr(x) ((void __user *)(user_uintptr_t)(u64)(x))
/* Same semantics as as_user_ptr(), but also requires x to be of a given type */
#define as_user_ptr_strict(type, x) ( \
--
2.34.1
For arm64, COMPAT_RLIM_INFINITY was explicitly defined as a 0xffffffff,
which is 32-bits. This was fine when COMPAT was only 32-bits, but is too
restrictive for COMPAT64.
Add a new define in COMPAT64 which uses the same define as the regular
RLIM_INFINITY in asm-generic/resrouce.h, based on an unsigned long.
Signed-off-by: Teo Couprie Diaz <teo.coupriediaz(a)arm.com>
---
arch/arm64/include/asm/compat.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 9c6112ae942b..f5ebdd9600a5 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -100,7 +100,11 @@ struct compat_statfs {
compat_long_t f_spare[4];
};
+#ifdef CONFIG_COMPAT64
+#define COMPAT_RLIM_INFINITY (~0UL)
+#else
#define COMPAT_RLIM_INFINITY 0xffffffff
+#endif
#define COMPAT_OFF_T_MAX 0x7fffffff
--
2.25.1
Hi All,
This series adds capabilities support for clone3 syscall along with
set of testcases in morello clone kselftests.
Changes available at:
https://git.morello-project.org/Bea/linux/-/tree/morello/clone3_v5
LTP changes:
https://git.morello-project.org/Bea/morello-linux-ltp/-/tree/morello/clone3
To run clone3 tests:
./runltp -f syscalls -s clone3
v5:
[PATCH 3/3]
- improved handling of default size for clone3 args
- fixed alignment in code layout
- dropped redundant cast
v4:
[PATCH 1/3]
- fixed commit message referring to the wrong copy routine
[PATCH 3/3]
- dropped setting default size for clone3 args
- dropped stale comment regarding re-using bits from clone_args flags
- switched ASSERT_FALSE to ASSERT_EQ when comparing pids in child process
- added caching tls value to safely unmap memory
- added validation for both clone stack and tls
- switch from clone_args-> tls to actual thread data when checking for tag in
cloned process
v3:
[PATCH 1/3]:
- updated commit message to reflect actual changes
[PATCH 2/3]:
- fixed type casting and sizes for copy routines
- swapped order of args for clone_args_size_ver
[PATCH 3/3]:
- added dedicated field for test custom flags instead of 'borrowing' one from
clone_args struct
- added test for stack before calling munmap in failing test cases
- switched to WSTOPPED for waitid call
v2:
- add copy_struct_from_user_with_ptr variant
- drop explicit padding from clone_args struct
- switch __alignof__ to sizeof for struct sizing conditions
- use __clone_args_size_ver macro when validating struct layout
- cache the current compat mode instead of relying on compiler optimizations
- drop use of as_user_ptr in favour of explicit casting
- use clone_args struct directly for kselftest test fixture
- add signalling to better handle dependencies between test threads
Beata Michalska (3):
uaccess: Preserve capability tags with copy_struct_from_user_with_ptr
fork: clone3: Add support for architectural capabilities
kselftests/arm64: morello: Add clone3 test-cases
include/linux/uaccess.h | 60 ++++-
include/uapi/linux/sched.h | 30 ++-
kernel/fork.c | 139 ++++++++---
.../testing/selftests/arm64/morello/Makefile | 1 +
tools/testing/selftests/arm64/morello/clone.c | 223 +++++++++++++++++-
5 files changed, 401 insertions(+), 52 deletions(-)
--
2.25.1