Currently the keyctl helper makes silent assumption that either all
expected arguments are being provided or otherwise it's somewhat
safe to access beyond the actual va arg list. With AAPCS64-cap this
will no longer slide through, as reading more arguments than provided
will trigger capability bound fault. Empty va_list is another issue
there (see KEYCTL_SESSION_TO_PARENT).
Introduce dedicated macro to handle the variadic-ness instead, making
sure that at any point all arguments are being provided, whether
explicitly or through default values.
Additionally move the keyctl_join_session_keyring opening brace to the
beginning of next line to align with coding style.
Reported-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
Suggested-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
Signed-off-by: Beata Michalska <beata.michalska(a)arm.com>
---
changes available at:
https://git.morello-project.org/Bea/morello-linux-ltp/-/tree/morello/keyctl…
v3:
- Fixed alignment
- Addded info in the commit msg on unrelevant change
- Dropped a section on mapping command to nr of args
v2:
- define keyctl as macro so that the kectl users can remain unaware of the
changes (thanks to @Tudor)
include/lapi/keyctl.h | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
index 9c847a429..e1af4d302 100644
--- a/include/lapi/keyctl.h
+++ b/include/lapi/keyctl.h
@@ -39,22 +39,20 @@ static inline key_serial_t request_key(const char *type,
type, description, callout_info, destringid);
}
-static inline long keyctl(int cmd, ...)
-{
- va_list va;
- uintptr_t arg2, arg3, arg4, arg5;
+#define __keyctl(cmd, arg2, arg3, arg4, arg5, ...) \
+({ \
+ long result; \
+ result = tst_syscall(__NR_keyctl, (cmd), \
+ (arg2), (arg3), (arg4), (arg5)); \
+ result; \
+})
- va_start(va, cmd);
- arg2 = va_arg(va, uintptr_t);
- arg3 = va_arg(va, uintptr_t);
- arg4 = va_arg(va, uintptr_t);
- arg5 = va_arg(va, uintptr_t);
- va_end(va);
+#define keyctl(cmd, ...) \
+ __keyctl((cmd), ##__VA_ARGS__, 0, 0, 0, 0)
- return tst_syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
-}
-static inline key_serial_t keyctl_join_session_keyring(const char *name) {
+static inline key_serial_t keyctl_join_session_keyring(const char *name)
+{
return keyctl(KEYCTL_JOIN_SESSION_KEYRING, name);
}
--
2.25.1
Currently the keyctl helper makes silent assumption that either all
expected arguments are being provided or otherwise it's somewhat
safe to access beyond the actual va arg list. With AAPCS64-cap this
will no longer slide through, as reading more arguments than provided
will trigger capability bound fault. Empty va_list is another issue
there (see KEYCTL_SESSION_TO_PARENT).
Introduce dedicated macro to handle the variadic-ness instead, making
sure that at any point all arguments are being provided, whether
explicitly or through default
values.
Note that depicting number of arguments to be fetched from va_list based
on provided command will not solve the problem as some (like
KEYCTL_SEARCH) still allow optional ones.
Reported-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
Suggested-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
Signed-off-by: Beata Michalska <beata.michalska(a)arm.com>
---
changes available at:
https://git.morello-project.org/Bea/morello-linux-ltp/-/tree/morello/keyctl…
v2:
- define keyctl as macro so that the kectl users can remain unaware of the
changes (thanks to @Tudor)
include/lapi/keyctl.h | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
index 9c847a429..97440e50a 100644
--- a/include/lapi/keyctl.h
+++ b/include/lapi/keyctl.h
@@ -39,22 +39,19 @@ static inline key_serial_t request_key(const char *type,
type, description, callout_info, destringid);
}
-static inline long keyctl(int cmd, ...)
-{
- va_list va;
- uintptr_t arg2, arg3, arg4, arg5;
+#define __keyctl(cmd, arg2, arg3, arg4, arg5, ...) \
+({ \
+ long result; \
+ result = tst_syscall(__NR_keyctl, (cmd), (arg2), (arg3), (arg4), (arg5)); \
+ result; \
+})
- va_start(va, cmd);
- arg2 = va_arg(va, uintptr_t);
- arg3 = va_arg(va, uintptr_t);
- arg4 = va_arg(va, uintptr_t);
- arg5 = va_arg(va, uintptr_t);
- va_end(va);
+#define keyctl(cmd, ...) \
+ __keyctl((cmd), ##__VA_ARGS__, 0, 0, 0, 0)
- return tst_syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
-}
-static inline key_serial_t keyctl_join_session_keyring(const char *name) {
+static inline key_serial_t keyctl_join_session_keyring(const char *name)
+{
return keyctl(KEYCTL_JOIN_SESSION_KEYRING, name);
}
--
2.25.1
Clean-up the instructions for building LTP syscall testcases, as those
have become bit stale. Also add some additional details on the required
setup.
Signed-off-by: Beata Michalska <beata.michalska(a)arm.com>
---
Changes available at:
https://git.morello-project.org/Bea/morello-linux-ltp/-/tree/morello/dev
README.rst | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/README.rst b/README.rst
index 342901f4d..fc07d3b64 100644
--- a/README.rst
+++ b/README.rst
@@ -21,7 +21,7 @@ https://op-lists.linaro.org/mailman3/lists/linux-morello-ltp.op-lists.linar…
Building (cross-compiling) & running relevant tests (purecap mode)
-------------------------------------------------------------------
-Dependencies/requirements: (additional to what's required to build base LTP):
+Dependencies/requirements: (additional to what's required to build base LTP)
- Morello LLVM toolchain (version >= 1.4)
@@ -29,7 +29,7 @@ Dependencies/requirements: (additional to what's required to build base LTP):
Binary releases: https://git.morello-project.org/morello/llvm-project-releases
- - **morello/baremetal-release-1.4** + **morello/linux-aarch64-release-1.4** for Morello
+ - **morello/baremetal-release-1.*** + **morello/linux-aarch64-release-1.*** for Morello
purecap crt objects
@@ -37,6 +37,8 @@ Dependencies/requirements: (additional to what's required to build base LTP):
- Kernel uAPI header files: https://git.morello-project.org/morello/morello-linux-headers
+\* All based on the same release/tag version.
+
Building Musl:
--------------
@@ -72,27 +74,24 @@ Assumptions:
.. code-block::
clang - Morello Clang (see Dependencies) configured for current environment
- KHDR_DIR - kernel uAPI headers
- MUSL - Musl build (see above)
- MORELLO_CRT_OBJS - as per https://git.morello-project.org/morello/llvm-project-releases/-/tree/morell…
- -> $(clang -print-resource-dir)/lib/aarch64-unknown-linux-musl_purecap
-
+ KHDR_DIR - kernel uAPI headers (see Dependencies or alternatively
+ headers installed for Morello Linux kernel through make headers_install)
+ MUSL - installed Musl libc for Morello (see section above: Building Musl);
+ this will serve as a location for --sysroot option
+ LTP_BUILD - location for the out-of-tree build (generated automatically)
+ OUTPUT_DIR - pre-existing location where LTP tests are to be installed
+ TARGETS - build targets, currently only pan and testcases/kernel/syscalls
+ are supported, it can be further narrowed down for
+ specific syscall testcases:
+ TARGETS="pan testcases/kernel/syscalls/${syscall}"
.. code-block::
- CLANG_RES_DIR=$(clang -print-resource-dir)
-
- CFLAGS_COMMON="--target=aarch64-linux-gnu -integrated-as -g -static -nostdinc -pthread \
- -isystem $KHDR_DIR/usr/include"
-
- CFLAGS_PURECAP="$CFLAGS_COMMON -march=morello+c64 -mabi=purecap \
- -isystem $CLANG_RES_DIR/include -isystem $MUSL/include -Wall"
+ CFLAGS="--target=aarch64-linux-musl_purecap -march=morello+c64 --sysroot=${MUSL} \
+ -isystem $KHDR_DIR/usr/include -g -pthread -Wall"
- LDFLAGS_COMMON="--target=aarch64-linux-gnu -fuse-ld=lld -static -nostdlib"
-
- LDFLAGS_PURECAP="$LDFLAGS_COMMON $MUSL/lib/crt1.o $MUSL/lib/crti.o \
- $MORELLO_CRT_OBJS/clang_rt.crtbegin.o $MORELLO_CRT_OBJS/libclang_rt.builtins.a \
- $MORELLO_CRT_OBJS/clang_rt.crtend.o $MUSL/lib/crtn.o -L$MUSL/lib/ -lc -L$LTP_BUILD/lib"
+ LDFLAGS="--target=aarch64-linux-musl_purecap -rtlib=compiler-rt --sysroot=${MUSL} \
+ -fuse-ld=lld -static -L${LTP_BUILD}/lib"
export CC=clang
export HOST_CFLAGS="-O2 -Wall"
@@ -101,9 +100,17 @@ Assumptions:
MAKE_OPTS="TST_NEWER_64_SYSCALL=no TST_COMPAT_16_SYSCALL=no" \
TARGETS="pan testcases/kernel/syscalls" BUILD_DIR="$LTP_BUILD" \
- CFLAGS="$CFLAGS_PURECAP" LDFLAGS="$LDFLAGS_PURECAP" \
+ CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
./build.sh -t cross -o out -ip "${OUTPUT_DIR}/opt/ltp"
+This can be split into separate steps for ``configure``, ``build`` and ``install`` by
+specifying additional parameter to build.sh detailing each step:
+
+.. code-block::
+
+ -r configure - run cunfigure only
+ -r build - run build only
+ -r install - run install only
Running tests:
--------------
--
2.25.1
The ptrace tests pass (for both purecap and compat), so add them to
the extended Morello transitional syscalls list.
Do not add ptrace04, ptrace07, ptrace08, ptrace09 or ptrace10 as they
are not run (TCONF) on arm64.
Signed-off-by: Kristina Martsenko <kristina.martsenko(a)arm.com>
---
Changes in v2:
- removed the tests that are not run on arm64
runtest/morello_transitional_extended | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/runtest/morello_transitional_extended b/runtest/morello_transitional_extended
index 067fe82da..464e5d00f 100644
--- a/runtest/morello_transitional_extended
+++ b/runtest/morello_transitional_extended
@@ -44,6 +44,14 @@ keyctl07 keyctl07
keyctl08 keyctl08
keyctl09 keyctl09
+ptrace01 ptrace01
+ptrace02 ptrace02
+ptrace03 ptrace03
+ptrace05 ptrace05
+# Broken test; See: testcases/kernel/syscalls/ptrace/Makefile for more details.
+#ptrace06 ptrace06
+ptrace11 ptrace11
+
semctl01 semctl01
semctl02 semctl02
semctl03 semctl03
--
2.30.2