Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/tools/testing/selftests/arm64/pauth/exec_target.c
29270 views
1
// SPDX-License-Identifier: GPL-2.0
2
// Copyright (C) 2020 ARM Limited
3
4
#include <stdio.h>
5
#include <stdlib.h>
6
#include <sys/auxv.h>
7
8
#include "helper.h"
9
10
int main(void)
11
{
12
struct signatures signed_vals;
13
unsigned long hwcaps;
14
size_t val;
15
16
size_t size = fread(&val, sizeof(size_t), 1, stdin);
17
18
if (size != 1) {
19
fprintf(stderr, "Could not read input from stdin\n");
20
return EXIT_FAILURE;
21
}
22
23
/* don't try to execute illegal (unimplemented) instructions) caller
24
* should have checked this and keep worker simple
25
*/
26
hwcaps = getauxval(AT_HWCAP);
27
28
if (hwcaps & HWCAP_PACA) {
29
signed_vals.keyia = keyia_sign(val);
30
signed_vals.keyib = keyib_sign(val);
31
signed_vals.keyda = keyda_sign(val);
32
signed_vals.keydb = keydb_sign(val);
33
}
34
signed_vals.keyg = (hwcaps & HWCAP_PACG) ? keyg_sign(val) : 0;
35
36
fwrite(&signed_vals, sizeof(struct signatures), 1, stdout);
37
38
return 0;
39
}
40
41