From 1aed810c86069f8b9b117ccccf083e98bf0da74c Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 8 Apr 2025 14:11:26 +0200 Subject: tools/syz-declextract: extend test data Add few interesting cases for scope analysis. Move functions related to resource to the header file, they must be visible in every file to work. --- tools/syz-declextract/testdata/scopes.c.json | 174 +++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) (limited to 'tools/syz-declextract/testdata/scopes.c.json') diff --git a/tools/syz-declextract/testdata/scopes.c.json b/tools/syz-declextract/testdata/scopes.c.json index 2a497dbe1..ab03673b0 100644 --- a/tools/syz-declextract/testdata/scopes.c.json +++ b/tools/syz-declextract/testdata/scopes.c.json @@ -111,6 +111,59 @@ ], "loc": 3 }, + { + "arg": 1, + "values": [ + "FOO_IOCTL7", + "FOO_IOCTL8" + ], + "loc": 4, + "calls": [ + "scopes_helper" + ], + "facts": [ + { + "src": { + "return": { + "func": "scopes_helper" + } + }, + "dst": { + "local": { + "name": "tmp" + } + } + }, + { + "src": { + "argument": { + "func": "__do_sys_scopes0", + "arg": 1 + } + }, + "dst": { + "argument": { + "func": "scopes_helper", + "arg": 0 + } + } + }, + { + "src": { + "argument": { + "func": "__do_sys_scopes0", + "arg": 0 + } + }, + "dst": { + "argument": { + "func": "scopes_helper", + "arg": 1 + } + } + } + ] + }, { "arg": 1, "values": [ @@ -140,6 +193,99 @@ ] } ] + }, + { + "name": "__fget_light", + "file": "include/fs.h", + "is_static": true, + "scopes": [ + { + "arg": -1 + } + ] + }, + { + "name": "alloc_fd", + "file": "include/fs.h", + "is_static": true, + "scopes": [ + { + "arg": -1, + "loc": 1 + } + ] + }, + { + "name": "from_kuid", + "file": "include/fs.h", + "is_static": true, + "scopes": [ + { + "arg": -1, + "loc": 1 + } + ] + }, + { + "name": "scopes_helper", + "file": "scopes.c", + "is_static": true, + "scopes": [ + { + "arg": -1, + "loc": 2 + }, + { + "arg": 0, + "values": [ + "FOO_IOCTL7" + ], + "loc": 2, + "calls": [ + "alloc_fd" + ], + "facts": [ + { + "src": { + "return": { + "func": "alloc_fd" + } + }, + "dst": { + "return": { + "func": "scopes_helper" + } + } + } + ] + }, + { + "arg": 0, + "values": [ + "FOO_IOCTL8" + ], + "loc": 3, + "calls": [ + "__fget_light" + ], + "facts": [ + { + "src": { + "argument": { + "func": "scopes_helper", + "arg": 1 + } + }, + "dst": { + "argument": { + "func": "__fget_light", + "arg": 0 + } + } + } + ] + } + ] } ], "consts": [ @@ -162,6 +308,16 @@ "name": "FOO_IOCTL4", "filename": "include/uapi/file_operations.h", "value": 1074291460 + }, + { + "name": "FOO_IOCTL7", + "filename": "include/uapi/file_operations.h", + "value": 25351 + }, + { + "name": "FOO_IOCTL8", + "filename": "include/uapi/file_operations.h", + "value": 25352 } ], "structs": [ @@ -281,6 +437,24 @@ } } } + }, + { + "name": "FOO_IOCTL7", + "type": { + "int": { + "byte_size": 1, + "is_const": true + } + } + }, + { + "name": "FOO_IOCTL8", + "type": { + "int": { + "byte_size": 1, + "is_const": true + } + } } ] } \ No newline at end of file -- cgit mrf-deployment