From 2d9fa31cf7abaddf944824814053e67b4d5c478e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 9 Apr 2025 10:38:03 +0200 Subject: pkg/declextract: export syscall variants as separate interfaces Export each syscall variant (e.g. fcnt$*) as a separate interface. Effectively these are separate syscalls. We will want this for ioctl as well (it's not 1 interface). --- .../testdata/file_operations.c.json | 47 ++++++++++++++++------ tools/syz-declextract/testdata/functions.c.json | 42 ++++++++++++------- tools/syz-declextract/testdata/io_uring.c.json | 14 +++++++ tools/syz-declextract/testdata/netlink.c.json | 20 +++++++-- tools/syz-declextract/testdata/scopes.c.info | 15 ++++++- tools/syz-declextract/testdata/scopes.c.json | 45 +++++++++++++-------- tools/syz-declextract/testdata/syscall.c.json | 10 +++-- tools/syz-declextract/testdata/types.c.info | 2 +- tools/syz-declextract/testdata/types.c.json | 23 ++++++----- 9 files changed, 157 insertions(+), 61 deletions(-) (limited to 'tools/syz-declextract/testdata') diff --git a/tools/syz-declextract/testdata/file_operations.c.json b/tools/syz-declextract/testdata/file_operations.c.json index dd0415fd2..9fcd64ce4 100644 --- a/tools/syz-declextract/testdata/file_operations.c.json +++ b/tools/syz-declextract/testdata/file_operations.c.json @@ -3,6 +3,8 @@ { "name": "__fget_light", "file": "include/fs.h", + "start_line": 18, + "end_line": 19, "is_static": true, "scopes": [ { @@ -13,22 +15,24 @@ { "name": "alloc_fd", "file": "include/fs.h", + "start_line": 14, + "end_line": 16, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "foo_ioctl", "file": "file_operations.c", + "start_line": 21, + "end_line": 30, "is_static": true, "scopes": [ { "arg": -1, - "loc": 2, "calls": [ "foo_ioctl2" ], @@ -72,18 +76,19 @@ "FOO_IOCTL4", "FOO_IOCTL5" ], - "loc": 5 + "start_line": 23 } ] }, { "name": "foo_ioctl2", "file": "file_operations.c", + "start_line": 13, + "end_line": 19, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 }, { "arg": 0, @@ -91,13 +96,15 @@ "FOO_IOCTL6", "FOO_IOCTL7" ], - "loc": 3 + "start_line": 15 } ] }, { "name": "foo_mmap", "file": "file_operations.c", + "start_line": 11, + "end_line": 11, "is_static": true, "scopes": [ { @@ -108,6 +115,8 @@ { "name": "foo_open", "file": "file_operations.c", + "start_line": 8, + "end_line": 8, "is_static": true, "scopes": [ { @@ -118,6 +127,8 @@ { "name": "foo_read", "file": "file_operations.c", + "start_line": 9, + "end_line": 9, "is_static": true, "scopes": [ { @@ -128,6 +139,8 @@ { "name": "foo_write", "file": "file_operations.c", + "start_line": 10, + "end_line": 10, "is_static": true, "scopes": [ { @@ -138,17 +151,20 @@ { "name": "from_kuid", "file": "include/fs.h", + "start_line": 21, + "end_line": 23, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "proc_ioctl", "file": "file_operations.c", + "start_line": 43, + "end_line": 43, "is_static": true, "scopes": [ { @@ -159,6 +175,8 @@ { "name": "proc_open", "file": "file_operations.c", + "start_line": 40, + "end_line": 40, "is_static": true, "scopes": [ { @@ -169,6 +187,8 @@ { "name": "proc_read", "file": "file_operations.c", + "start_line": 41, + "end_line": 41, "is_static": true, "scopes": [ { @@ -179,6 +199,8 @@ { "name": "proc_write", "file": "file_operations.c", + "start_line": 42, + "end_line": 42, "is_static": true, "scopes": [ { @@ -189,11 +211,12 @@ { "name": "unused_ioctl", "file": "file_operations.c", + "start_line": 59, + "end_line": 64, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 }, { "arg": 1, @@ -201,7 +224,7 @@ "UNUSED_IOCTL1", "UNUSED_IOCTL2" ], - "loc": 2 + "start_line": 61 } ] } diff --git a/tools/syz-declextract/testdata/functions.c.json b/tools/syz-declextract/testdata/functions.c.json index 6d636233e..b4766e73e 100644 --- a/tools/syz-declextract/testdata/functions.c.json +++ b/tools/syz-declextract/testdata/functions.c.json @@ -3,10 +3,11 @@ { "name": "__do_sys_functions", "file": "functions.c", + "start_line": 31, + "end_line": 34, "scopes": [ { "arg": -1, - "loc": 2, "calls": [ "__fget_light", "func_baz" @@ -45,6 +46,8 @@ { "name": "__fget_light", "file": "include/fs.h", + "start_line": 18, + "end_line": 19, "is_static": true, "scopes": [ { @@ -55,54 +58,59 @@ { "name": "alloc_fd", "file": "include/fs.h", + "start_line": 14, + "end_line": 16, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "atomic_load32", "file": "include/types.h", + "start_line": 17, + "end_line": 19, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "atomic_load64", "file": "include/types.h", + "start_line": 21, + "end_line": 23, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "from_kuid", "file": "include/fs.h", + "start_line": 21, + "end_line": 23, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "func_bar", "file": "functions.c", + "start_line": 11, + "end_line": 13, "is_static": true, "scopes": [ { "arg": -1, - "loc": 1, "calls": [ "func_foo" ] @@ -112,10 +120,11 @@ { "name": "func_baz", "file": "functions.c", + "start_line": 15, + "end_line": 24, "scopes": [ { "arg": -1, - "loc": 8, "calls": [ "func_foo", "func_bar", @@ -155,6 +164,8 @@ { "name": "func_foo", "file": "functions.c", + "start_line": 8, + "end_line": 9, "is_static": true, "scopes": [ { @@ -165,10 +176,11 @@ { "name": "func_qux", "file": "functions.c", + "start_line": 26, + "end_line": 29, "scopes": [ { "arg": -1, - "loc": 2, "calls": [ "alloc_fd" ], @@ -204,10 +216,11 @@ { "name": "typing", "file": "functions.c", + "start_line": 46, + "end_line": 52, "scopes": [ { "arg": -1, - "loc": 5, "calls": [ "typing1" ], @@ -298,10 +311,11 @@ { "name": "typing1", "file": "functions.c", + "start_line": 42, + "end_line": 44, "scopes": [ { "arg": -1, - "loc": 1, "facts": [ { "src": { diff --git a/tools/syz-declextract/testdata/io_uring.c.json b/tools/syz-declextract/testdata/io_uring.c.json index 60ac44818..e82cf6c8c 100644 --- a/tools/syz-declextract/testdata/io_uring.c.json +++ b/tools/syz-declextract/testdata/io_uring.c.json @@ -3,6 +3,8 @@ { "name": "io_eopnotsupp_prep", "file": "io_uring.c", + "start_line": 11, + "end_line": 11, "scopes": [ { "arg": -1 @@ -12,6 +14,8 @@ { "name": "io_nop", "file": "io_uring.c", + "start_line": 13, + "end_line": 13, "scopes": [ { "arg": -1 @@ -21,6 +25,8 @@ { "name": "io_nop_prep", "file": "io_uring.c", + "start_line": 12, + "end_line": 12, "scopes": [ { "arg": -1 @@ -30,6 +36,8 @@ { "name": "io_read", "file": "io_uring.c", + "start_line": 15, + "end_line": 15, "scopes": [ { "arg": -1 @@ -39,6 +47,8 @@ { "name": "io_readv_prep", "file": "io_uring.c", + "start_line": 14, + "end_line": 14, "scopes": [ { "arg": -1 @@ -48,6 +58,8 @@ { "name": "io_write", "file": "io_uring.c", + "start_line": 17, + "end_line": 17, "scopes": [ { "arg": -1 @@ -57,6 +69,8 @@ { "name": "io_writev_prep", "file": "io_uring.c", + "start_line": 16, + "end_line": 16, "scopes": [ { "arg": -1 diff --git a/tools/syz-declextract/testdata/netlink.c.json b/tools/syz-declextract/testdata/netlink.c.json index 9571730f7..95fcc7e5d 100644 --- a/tools/syz-declextract/testdata/netlink.c.json +++ b/tools/syz-declextract/testdata/netlink.c.json @@ -3,27 +3,31 @@ { "name": "atomic_load32", "file": "include/types.h", + "start_line": 17, + "end_line": 19, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "atomic_load64", "file": "include/types.h", + "start_line": 21, + "end_line": 23, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "bar_cmd", "file": "netlink.c", + "start_line": 43, + "end_line": 43, "is_static": true, "scopes": [ { @@ -34,6 +38,8 @@ { "name": "bar_doit", "file": "netlink.c", + "start_line": 76, + "end_line": 76, "is_static": true, "scopes": [ { @@ -44,6 +50,8 @@ { "name": "bar_post_doit", "file": "netlink.c", + "start_line": 77, + "end_line": 77, "is_static": true, "scopes": [ { @@ -54,6 +62,8 @@ { "name": "bar_pre_doit", "file": "netlink.c", + "start_line": 75, + "end_line": 75, "is_static": true, "scopes": [ { @@ -64,6 +74,8 @@ { "name": "foo_cmd", "file": "netlink.c", + "start_line": 42, + "end_line": 42, "is_static": true, "scopes": [ { diff --git a/tools/syz-declextract/testdata/scopes.c.info b/tools/syz-declextract/testdata/scopes.c.info index aeee09ace..1841dcf14 100644 --- a/tools/syz-declextract/testdata/scopes.c.info +++ b/tools/syz-declextract/testdata/scopes.c.info @@ -1 +1,14 @@ -SYSCALL scopes0 func:__do_sys_scopes0 loc:35 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0 func:__do_sys_scopes0 loc:37 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$100 func:__do_sys_scopes0 loc:11 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$101 func:__do_sys_scopes0 loc:11 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$102 func:__do_sys_scopes0 loc:11 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$1074291461 func:__do_sys_scopes0 loc:11 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$1074291462 func:__do_sys_scopes0 loc:11 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$FOO_IOCTL1 func:__do_sys_scopes0 loc:11 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$FOO_IOCTL2 func:__do_sys_scopes0 loc:13 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$FOO_IOCTL3 func:__do_sys_scopes0 loc:13 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$FOO_IOCTL4 func:__do_sys_scopes0 loc:11 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$FOO_IOCTL7 func:__do_sys_scopes0 loc:21 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$FOO_IOCTL8 func:__do_sys_scopes0 loc:21 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$LARGE_SINT func:__do_sys_scopes0 loc:8 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel +SYSCALL scopes0$LARGE_UINT func:__do_sys_scopes0 loc:8 access:unknown manual_desc:false auto_desc:true file:scopes.c subsystem:kernel diff --git a/tools/syz-declextract/testdata/scopes.c.json b/tools/syz-declextract/testdata/scopes.c.json index b5921869c..dd0e54a99 100644 --- a/tools/syz-declextract/testdata/scopes.c.json +++ b/tools/syz-declextract/testdata/scopes.c.json @@ -3,10 +3,11 @@ { "name": "__do_sys_scopes0", "file": "scopes.c", + "start_line": 25, + "end_line": 51, "scopes": [ { "arg": -1, - "loc": 4, "calls": [ "__fget_light" ], @@ -44,7 +45,8 @@ "values": [ "FOO_IOCTL1" ], - "loc": 3, + "start_line": 29, + "end_line": 32, "calls": [ "__fget_light" ], @@ -71,7 +73,8 @@ "FOO_IOCTL2", "FOO_IOCTL3" ], - "loc": 4, + "start_line": 32, + "end_line": 36, "calls": [ "alloc_fd" ], @@ -109,7 +112,8 @@ "1074291461", "1074291462" ], - "loc": 3 + "start_line": 36, + "end_line": 39 }, { "arg": 1, @@ -117,7 +121,8 @@ "FOO_IOCTL7", "FOO_IOCTL8" ], - "loc": 4, + "start_line": 39, + "end_line": 43, "calls": [ "scopes_helper" ], @@ -171,11 +176,12 @@ "101", "102" ], - "loc": 3 + "start_line": 43, + "end_line": 46 }, { "arg": 1, - "loc": 3, + "start_line": 46, "facts": [ { "src": { @@ -197,6 +203,8 @@ { "name": "__fget_light", "file": "include/fs.h", + "start_line": 18, + "end_line": 19, "is_static": true, "scopes": [ { @@ -207,40 +215,44 @@ { "name": "alloc_fd", "file": "include/fs.h", + "start_line": 14, + "end_line": 16, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "from_kuid", "file": "include/fs.h", + "start_line": 21, + "end_line": 23, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "scopes_helper", "file": "scopes.c", + "start_line": 11, + "end_line": 23, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 2 + "arg": -1 }, { "arg": 0, "values": [ "FOO_IOCTL7" ], - "loc": 2, + "start_line": 13, + "end_line": 15, "calls": [ "alloc_fd" ], @@ -264,7 +276,8 @@ "values": [ "FOO_IOCTL8" ], - "loc": 3, + "start_line": 15, + "end_line": 18, "calls": [ "__fget_light" ], @@ -291,7 +304,7 @@ "LARGE_UINT", "LARGE_SINT" ], - "loc": 3 + "start_line": 18 } ] } diff --git a/tools/syz-declextract/testdata/syscall.c.json b/tools/syz-declextract/testdata/syscall.c.json index 4e466a3ae..371fe183b 100644 --- a/tools/syz-declextract/testdata/syscall.c.json +++ b/tools/syz-declextract/testdata/syscall.c.json @@ -3,20 +3,22 @@ { "name": "__do_sys_chmod", "file": "syscall.c", + "start_line": 10, + "end_line": 12, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "__do_sys_open", "file": "syscall.c", + "start_line": 6, + "end_line": 8, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] } diff --git a/tools/syz-declextract/testdata/types.c.info b/tools/syz-declextract/testdata/types.c.info index 7c4e66ca1..0e5da0671 100644 --- a/tools/syz-declextract/testdata/types.c.info +++ b/tools/syz-declextract/testdata/types.c.info @@ -1,2 +1,2 @@ SYSCALL align_syscall func:__do_sys_align_syscall loc:1 access:unknown manual_desc:false auto_desc:true file:types.c subsystem:kernel -SYSCALL types_syscall func:__do_sys_types_syscall loc:1 access:unknown manual_desc:false auto_desc:true file:types.c subsystem:kernel +SYSCALL types_syscall func:__do_sys_types_syscall loc:3 access:unknown manual_desc:false auto_desc:true file:types.c subsystem:kernel diff --git a/tools/syz-declextract/testdata/types.c.json b/tools/syz-declextract/testdata/types.c.json index da494969c..558d0d5f4 100644 --- a/tools/syz-declextract/testdata/types.c.json +++ b/tools/syz-declextract/testdata/types.c.json @@ -3,30 +3,33 @@ { "name": "__do_sys_align_syscall", "file": "types.c", + "start_line": 97, + "end_line": 99, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "__do_sys_types_syscall", "file": "types.c", + "start_line": 53, + "end_line": 57, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "anon_flow", "file": "types.c", + "start_line": 59, + "end_line": 68, "scopes": [ { "arg": -1, - "loc": 8, "facts": [ { "src": { @@ -133,21 +136,23 @@ { "name": "atomic_load32", "file": "include/types.h", + "start_line": 17, + "end_line": 19, "is_static": true, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] }, { "name": "atomic_load64", "file": "include/types.h", + "start_line": 21, + "end_line": 23, "scopes": [ { - "arg": -1, - "loc": 1 + "arg": -1 } ] } -- cgit mrf-deployment