diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2022-04-27 13:15:05 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2022-04-27 17:43:05 +0200 |
| commit | d6b461d9bcc04628b6e782d80e373469bccef743 (patch) | |
| tree | f1d097ce063bab8f3a413ffbe2242ebde2d87f03 | |
| parent | 1fa34c1b4ca31728acc7dfc7ec2f221443b8d40f (diff) | |
executor: allow external extensions of the setup phase
Allow common_ext.h to provide setup_ext() function that is called during VM setup.
| -rw-r--r-- | executor/common.h | 3 | ||||
| -rw-r--r-- | executor/common_ext.h | 3 | ||||
| -rw-r--r-- | executor/executor.cc | 4 | ||||
| -rw-r--r-- | pkg/csource/generated.go | 3 |
4 files changed, 13 insertions, 0 deletions
diff --git a/executor/common.h b/executor/common.h index ddb33bec7..b98dd3fc1 100644 --- a/executor/common.h +++ b/executor/common.h @@ -772,6 +772,9 @@ int main(void) /*{{{MMAP_DATA}}}*/ #endif +#if SYZ_HAVE_SETUP_EXT + setup_ext(); +#endif #if SYZ_SYSCTL setup_sysctl(); #endif diff --git a/executor/common_ext.h b/executor/common_ext.h index 4f6e7491a..6485852ef 100644 --- a/executor/common_ext.h +++ b/executor/common_ext.h @@ -4,3 +4,6 @@ // This file is included into executor and C reproducers and can be used to add // non-mainline pseudo-syscalls w/o changing any other files. // These syscalls should start with syz_ext_. + +// This file can also define SYZ_HAVE_SETUP_EXT to 1 and provide +// void setup_ext() function that will be called during VM setup. diff --git a/executor/executor.cc b/executor/executor.cc index 28ab72206..058e90b15 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -1617,6 +1617,10 @@ void setup_features(char** enable, int n) // This does any one-time setup for the requested features on the machine. // Note: this can be called multiple times and must be idempotent. flag_debug = true; +#if SYZ_HAVE_SETUP_EXT + // This can be defined in common_ext.h. + setup_ext(); +#endif #if SYZ_HAVE_FEATURES setup_sysctl(); setup_cgroups(); diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index b9bdc1341..3891c4700 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -10741,6 +10741,9 @@ int main(void) /*{{{MMAP_DATA}}}*/ #endif +#if SYZ_HAVE_SETUP_EXT + setup_ext(); +#endif #if SYZ_SYSCTL setup_sysctl(); #endif |
