-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FROMLIST: selftests, arm64: add a selftest for passing tagged pointer…
…s to kernel (from https://lore.kernel.org/patchwork/patch/994348) This patch adds a simple test, that calls the uname syscall with a tagged user pointer as an argument. Without the kernel accepting tagged user pointers the test fails with EFAULT. Bug: 112461694 Change-Id: Id23d66680a6bb55a098ef69bfa8af90c096fe53b Signed-off-by: Andrey Konovalov <[email protected]> Signed-off-by: Chenyang Zhong <[email protected]>
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tags_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# ARCH can be overridden by the user for cross compiling | ||
ARCH ?= $(shell uname -m 2>/dev/null || echo not) | ||
|
||
ifneq (,$(filter $(ARCH),aarch64 arm64)) | ||
TEST_GEN_PROGS := tags_test | ||
TEST_PROGS := run_tags_test.sh | ||
endif | ||
|
||
include ../lib.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
echo "--------------------" | ||
echo "running tags test" | ||
echo "--------------------" | ||
./tags_test | ||
if [ $? -ne 0 ]; then | ||
echo "[FAIL]" | ||
else | ||
echo "[PASS]" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
|
||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <stdint.h> | ||
#include <sys/utsname.h> | ||
|
||
#define SHIFT_TAG(tag) ((uint64_t)(tag) << 56) | ||
#define SET_TAG(ptr, tag) (((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \ | ||
SHIFT_TAG(tag)) | ||
|
||
int main(void) | ||
{ | ||
struct utsname utsname; | ||
void *ptr = &utsname; | ||
void *tagged_ptr = (void *)SET_TAG(ptr, 0x42); | ||
int err = uname(tagged_ptr); | ||
return err; | ||
} |