aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-declextract/testdata
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2025-04-03 13:01:49 +0200
committerDmitry Vyukov <dvyukov@google.com>2025-04-03 20:02:17 +0000
commit8d95605b891f89e61af902d2d4a85b1930fc6699 (patch)
treefbcb3d4b137ab9ae846ae8440390cbb871713ab0 /tools/syz-declextract/testdata
parent6dc47718fdbb634024bcfe47cbc4d7cc781b4cc4 (diff)
tools/syz-declextract: support attributes on types
Remove __attribute__ on types. Some kernels now use it on some syscall args as shown in the test. The __attribute__ may contain quotes and break json.
Diffstat (limited to 'tools/syz-declextract/testdata')
-rw-r--r--tools/syz-declextract/testdata/include/types.h2
-rw-r--r--tools/syz-declextract/testdata/types.c6
-rw-r--r--tools/syz-declextract/testdata/types.c.json65
-rw-r--r--tools/syz-declextract/testdata/types.c.txt2
4 files changed, 65 insertions, 10 deletions
diff --git a/tools/syz-declextract/testdata/include/types.h b/tools/syz-declextract/testdata/include/types.h
index 2e6a7d853..286d29089 100644
--- a/tools/syz-declextract/testdata/include/types.h
+++ b/tools/syz-declextract/testdata/include/types.h
@@ -10,6 +10,8 @@ typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
+#define __user __attribute__((btf_type_tag("user")))
+
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
static inline u32 atomic_load32(u32* p) {
diff --git a/tools/syz-declextract/testdata/types.c b/tools/syz-declextract/testdata/types.c
index 7a98394c1..be88269eb 100644
--- a/tools/syz-declextract/testdata/types.c
+++ b/tools/syz-declextract/testdata/types.c
@@ -2,6 +2,7 @@
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
#include "include/syscall.h"
+#include "include/types.h"
typedef struct { float f; } anon_t;
struct empty_struct {};
@@ -42,7 +43,7 @@ struct packed_t {
struct various {
struct various* recursive;
struct recursive* next;
- struct packed_t packed;
+ struct packed_t packed;
};
struct recursive {
@@ -50,7 +51,8 @@ struct recursive {
};
SYSCALL_DEFINE1(types_syscall, struct anon_struct* p, struct empty_struct* y,
- struct bitfields* b, int pid, fd_t f, struct various* v) {
+ struct bitfields* b, int pid, fd_t f, struct various __user* v,
+ int __user* pi, u32 __user* pu) {
return 0;
}
diff --git a/tools/syz-declextract/testdata/types.c.json b/tools/syz-declextract/testdata/types.c.json
index 90d3be2a9..da494969c 100644
--- a/tools/syz-declextract/testdata/types.c.json
+++ b/tools/syz-declextract/testdata/types.c.json
@@ -37,7 +37,7 @@
},
"dst": {
"field": {
- "struct": "11253655576479126316",
+ "struct": "11253655576479126317",
"field": "x"
}
}
@@ -51,7 +51,7 @@
},
"dst": {
"field": {
- "struct": "11253655576479126318",
+ "struct": "11253655576479126319",
"field": "y"
}
}
@@ -65,7 +65,7 @@
},
"dst": {
"field": {
- "struct": "11253655576479126319",
+ "struct": "11253655576479126320",
"field": "w"
}
}
@@ -79,7 +79,7 @@
},
"dst": {
"field": {
- "struct": "11253655576479126309",
+ "struct": "11253655576479126310",
"field": "f"
}
}
@@ -93,7 +93,7 @@
},
"dst": {
"field": {
- "struct": "11253655576479126322",
+ "struct": "11253655576479126323",
"field": "a"
}
}
@@ -107,7 +107,7 @@
},
"dst": {
"field": {
- "struct": "11253655576479126323",
+ "struct": "11253655576479126324",
"field": "a"
}
}
@@ -121,7 +121,7 @@
},
"dst": {
"field": {
- "struct": "11253655576479126324",
+ "struct": "11253655576479126325",
"field": "b"
}
}
@@ -129,6 +129,27 @@
]
}
]
+ },
+ {
+ "name": "atomic_load32",
+ "file": "include/types.h",
+ "is_static": true,
+ "scopes": [
+ {
+ "arg": -1,
+ "loc": 1
+ }
+ ]
+ },
+ {
+ "name": "atomic_load64",
+ "file": "include/types.h",
+ "scopes": [
+ {
+ "arg": -1,
+ "loc": 1
+ }
+ ]
}
],
"consts": [
@@ -941,6 +962,36 @@
}
}
}
+ },
+ {
+ "name": "pi",
+ "counted_by": -1,
+ "type": {
+ "ptr": {
+ "elem": {
+ "int": {
+ "byte_size": 4,
+ "name": "int",
+ "base": "int"
+ }
+ }
+ }
+ }
+ },
+ {
+ "name": "pu",
+ "counted_by": -1,
+ "type": {
+ "ptr": {
+ "elem": {
+ "int": {
+ "byte_size": 4,
+ "name": "u32",
+ "base": "unsigned int"
+ }
+ }
+ }
+ }
}
],
"source_file": "types.c"
diff --git a/tools/syz-declextract/testdata/types.c.txt b/tools/syz-declextract/testdata/types.c.txt
index 085aee017..216200384 100644
--- a/tools/syz-declextract/testdata/types.c.txt
+++ b/tools/syz-declextract/testdata/types.c.txt
@@ -11,7 +11,7 @@ type auto_aligner[N] {
bitfield_enum$auto = a, b, c
align_syscall$auto(a1 ptr[inout, align1$auto], a2 ptr[inout, align2$auto], a3 ptr[inout, align3$auto], a4 ptr[inout, align4$auto])
-types_syscall$auto(p ptr[inout, anon_struct$auto], y ptr[inout, auto_aligner[1]], b ptr[inout, bitfields$auto], pid pid, f int32, v ptr[inout, various$auto])
+types_syscall$auto(p ptr[inout, anon_struct$auto], y ptr[inout, auto_aligner[1]], b ptr[inout, bitfields$auto], pid pid, f int32, v ptr[inout, various$auto], pi ptr[inout, int32], pu ptr[inout, int32])
align1$auto {
f1 int8