mirror of
https://github.com/systemd/systemd
synced 2024-07-21 02:05:05 +00:00
meson: also merge declarations of fuzzers with other executables
This commit is contained in:
parent
130c87b16a
commit
cbc55c4cce
151
meson.build
151
meson.build
|
@ -2174,12 +2174,12 @@ man_page_depends = []
|
||||||
|
|
||||||
simple_tests = []
|
simple_tests = []
|
||||||
libsystemd_tests = []
|
libsystemd_tests = []
|
||||||
fuzzers = []
|
|
||||||
simple_fuzzers = []
|
simple_fuzzers = []
|
||||||
catalogs = []
|
catalogs = []
|
||||||
modules = [] # nss, pam, and other plugins
|
modules = [] # nss, pam, and other plugins
|
||||||
executables = []
|
executables = []
|
||||||
executables_by_name = {}
|
executables_by_name = {}
|
||||||
|
fuzzer_exes = []
|
||||||
|
|
||||||
# binaries that have --help and are intended for use by humans,
|
# binaries that have --help and are intended for use by humans,
|
||||||
# usually, but not always, installed in /bin.
|
# usually, but not always, installed in /bin.
|
||||||
|
@ -2354,6 +2354,29 @@ test_additional_kwargs = {
|
||||||
'link_depends' : runtest_env,
|
'link_depends' : runtest_env,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuzz_template = executable_template + {
|
||||||
|
'build_by_default' : fuzzer_build,
|
||||||
|
'install' : false,
|
||||||
|
}
|
||||||
|
|
||||||
|
if want_ossfuzz or (want_libfuzzer and fuzzing_engine.found())
|
||||||
|
fuzz_additional_kwargs = {
|
||||||
|
'dependencies' : fuzzing_engine,
|
||||||
|
}
|
||||||
|
elif want_libfuzzer and not fuzzing_engine.found()
|
||||||
|
fuzz_additional_kwargs = {
|
||||||
|
'link_args' : ['-fsanitize=fuzzer'],
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fuzz_additional_kwargs = {
|
||||||
|
'sources' : files('src/fuzz/fuzz-main.c'),
|
||||||
|
}
|
||||||
|
endif
|
||||||
|
fuzz_additional_kwargs += {
|
||||||
|
'include_directories' : include_directories('src/fuzz'),
|
||||||
|
'c_args' : test_cflags,
|
||||||
|
}
|
||||||
|
|
||||||
nss_template = {
|
nss_template = {
|
||||||
'version' : '2',
|
'version' : '2',
|
||||||
'include_directories' : includes,
|
'include_directories' : includes,
|
||||||
|
@ -2502,6 +2525,7 @@ subdir('src/systemd')
|
||||||
subdir('src/test')
|
subdir('src/test')
|
||||||
subdir('src/fuzz')
|
subdir('src/fuzz')
|
||||||
subdir('src/ukify/test') # needs to be last for test_env variable
|
subdir('src/ukify/test') # needs to be last for test_env variable
|
||||||
|
subdir('test/fuzz')
|
||||||
|
|
||||||
alias_target('devel', libsystemd_pc, libudev_pc, systemd_pc, udev_pc)
|
alias_target('devel', libsystemd_pc, libudev_pc, systemd_pc, udev_pc)
|
||||||
|
|
||||||
|
@ -2515,14 +2539,19 @@ foreach test : libsystemd_tests
|
||||||
executables += test_template + test
|
executables += test_template + test
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
foreach fuzzer : simple_fuzzers
|
||||||
|
executables += fuzz_template + { 'sources' : [fuzzer] }
|
||||||
|
endforeach
|
||||||
|
|
||||||
foreach dict : executables
|
foreach dict : executables
|
||||||
name = dict.get('name', '')
|
name = dict.get('name', '')
|
||||||
if name == ''
|
if name == ''
|
||||||
name = fs.stem(dict.get('sources')[0])
|
name = fs.stem(dict.get('sources')[0])
|
||||||
assert(name.split('-')[0] == 'test')
|
assert(name.split('-')[0] in ['test', 'fuzz'])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
is_test = name.startswith('test-')
|
is_test = name.startswith('test-')
|
||||||
|
is_fuzz = name.startswith('fuzz-')
|
||||||
|
|
||||||
build = true
|
build = true
|
||||||
foreach cond : dict.get('conditions', [])
|
foreach cond : dict.get('conditions', [])
|
||||||
|
@ -2556,6 +2585,12 @@ foreach dict : executables
|
||||||
endforeach
|
endforeach
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if is_fuzz
|
||||||
|
foreach key, val : fuzz_additional_kwargs
|
||||||
|
kwargs += { key : [ kwargs.get(key, []), val ] }
|
||||||
|
endforeach
|
||||||
|
endif
|
||||||
|
|
||||||
exe = executable(
|
exe = executable(
|
||||||
name,
|
name,
|
||||||
kwargs : kwargs,
|
kwargs : kwargs,
|
||||||
|
@ -2594,8 +2629,33 @@ foreach dict : executables
|
||||||
is_parallel : dict.get('parallel', true))
|
is_parallel : dict.get('parallel', true))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if is_fuzz
|
||||||
|
fuzzer_exes += exe
|
||||||
|
|
||||||
|
if want_tests != 'false'
|
||||||
|
# Run the fuzz regression tests without any sanitizers enabled.
|
||||||
|
# Additional invocations with sanitizers may be added below.
|
||||||
|
fuzz_ins = fuzz_regression_tests.get(name, {})
|
||||||
|
foreach directive : fuzz_ins.get('directives', [])
|
||||||
|
test('@0@_@1@'.format(name, fs.name(directive.full_path())),
|
||||||
|
exe,
|
||||||
|
suite : 'fuzz',
|
||||||
|
args : directive.full_path(),
|
||||||
|
depends : directive)
|
||||||
|
endforeach
|
||||||
|
foreach file : fuzz_ins.get('files', [])
|
||||||
|
test('@0@_@1@'.format(name, fs.name(file)),
|
||||||
|
exe,
|
||||||
|
suite : 'fuzz',
|
||||||
|
args : file)
|
||||||
|
endforeach
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
alias_target('fuzzers', fuzzer_exes)
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
test_dlopen = executables_by_name.get('test-dlopen')
|
test_dlopen = executables_by_name.get('test-dlopen')
|
||||||
|
@ -2677,71 +2737,6 @@ subdir('test')
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
foreach fuzzer : simple_fuzzers
|
|
||||||
fuzzers += { 'sources' : [fuzzer] }
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
fuzzer_exes = []
|
|
||||||
|
|
||||||
foreach fuzzer : fuzzers
|
|
||||||
sources = fuzzer.get('sources')
|
|
||||||
base = fuzzer.get('base', {})
|
|
||||||
dependencies = [base.get('dependencies', []), fuzzer.get('dependencies', [])]
|
|
||||||
link_args = []
|
|
||||||
|
|
||||||
if want_ossfuzz
|
|
||||||
dependencies += fuzzing_engine
|
|
||||||
elif want_libfuzzer
|
|
||||||
if fuzzing_engine.found()
|
|
||||||
dependencies += fuzzing_engine
|
|
||||||
else
|
|
||||||
link_args += ['-fsanitize=fuzzer']
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
sources += files('src/fuzz/fuzz-main.c')
|
|
||||||
endif
|
|
||||||
sources += fuzz_generated_directives
|
|
||||||
|
|
||||||
name = fs.stem(sources[0])
|
|
||||||
|
|
||||||
exe = executable(
|
|
||||||
name,
|
|
||||||
sources,
|
|
||||||
include_directories : [
|
|
||||||
base.get('includes', []),
|
|
||||||
fuzzer.get('includes', includes),
|
|
||||||
include_directories('src/fuzz'),
|
|
||||||
],
|
|
||||||
link_with : [base.get('link_with', []), fuzzer.get('link_with', libshared)],
|
|
||||||
dependencies : [
|
|
||||||
dependencies,
|
|
||||||
userspace,
|
|
||||||
],
|
|
||||||
c_args : [test_cflags, fuzzer.get('c_args', [])],
|
|
||||||
link_args: link_args,
|
|
||||||
install : false,
|
|
||||||
build_by_default : fuzzer_build)
|
|
||||||
fuzzer_exes += exe
|
|
||||||
|
|
||||||
if want_tests != 'false' and name in fuzz_regression_tests
|
|
||||||
# Run the fuzz regression tests without any sanitizers enabled.
|
|
||||||
# Additional invocations with sanitizers may be added below.
|
|
||||||
foreach tuple : fuzz_regression_tests[name]
|
|
||||||
fuzz_dir = tuple[0]
|
|
||||||
fuzz_in = tuple[1]
|
|
||||||
test('@0@_@1@'.format(name, fuzz_in),
|
|
||||||
exe,
|
|
||||||
suite : 'fuzz',
|
|
||||||
args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in
|
|
||||||
: fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)])
|
|
||||||
endforeach
|
|
||||||
endif
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
alias_target('fuzzers', fuzzer_exes)
|
|
||||||
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
subdir('docs/sysvinit')
|
subdir('docs/sysvinit')
|
||||||
subdir('docs/var-log')
|
subdir('docs/var-log')
|
||||||
subdir('hwdb.d')
|
subdir('hwdb.d')
|
||||||
|
@ -2841,24 +2836,28 @@ foreach tuple : fuzz_sanitizers
|
||||||
exe = custom_target(
|
exe = custom_target(
|
||||||
name,
|
name,
|
||||||
output : name,
|
output : name,
|
||||||
depends : [build] + fuzz_generated_directives,
|
depends : build,
|
||||||
command : [ln, '-fs',
|
command : [ln, '-fs',
|
||||||
build.full_path() / fuzzer,
|
build.full_path() / fuzzer,
|
||||||
'@OUTPUT@'],
|
'@OUTPUT@'],
|
||||||
build_by_default : true)
|
build_by_default : true)
|
||||||
|
|
||||||
foreach tuple : fuzz_ins
|
foreach directive : fuzz_ins.get('directives', [])
|
||||||
fuzz_dir = tuple[0]
|
test('@0@_@1@_@2@'.format(fuzzer, fs.name(directive.full_path()), sanitizer),
|
||||||
fuzz_in = tuple[1]
|
|
||||||
|
|
||||||
test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer),
|
|
||||||
env,
|
env,
|
||||||
suite : 'fuzz+san',
|
suite : 'fuzz+san',
|
||||||
env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
|
env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
|
||||||
timeout : 60,
|
timeout : 60,
|
||||||
args : [exe.full_path(),
|
args : [exe.full_path(), directive.full_path()],
|
||||||
fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in
|
depends : directive)
|
||||||
: fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)])
|
endforeach
|
||||||
|
foreach file : fuzz_ins.get('files', [])
|
||||||
|
test('@0@_@1@_@2@'.format(fuzzer, fs.name(file), sanitizer),
|
||||||
|
env,
|
||||||
|
suite : 'fuzz+san',
|
||||||
|
env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
|
||||||
|
timeout : 60,
|
||||||
|
args : [exe.full_path(), file])
|
||||||
endforeach
|
endforeach
|
||||||
endforeach
|
endforeach
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -24,6 +24,7 @@ if efi_arch != ''
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
efi_test_template = test_template + efitest_base
|
efi_test_template = test_template + efitest_base
|
||||||
|
efi_fuzz_template = fuzz_template + efitest_base
|
||||||
|
|
||||||
executables += [
|
executables += [
|
||||||
efi_test_template + {
|
efi_test_template + {
|
||||||
|
@ -34,19 +35,14 @@ if efi_arch != ''
|
||||||
efi_test_template + {
|
efi_test_template + {
|
||||||
'sources' : files('test-efi-string.c'),
|
'sources' : files('test-efi-string.c'),
|
||||||
},
|
},
|
||||||
]
|
efi_fuzz_template + {
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-bcd.c'),
|
'sources' : files('fuzz-bcd.c'),
|
||||||
'base' : efitest_base,
|
|
||||||
},
|
},
|
||||||
{
|
efi_fuzz_template + {
|
||||||
'sources' : files('fuzz-efi-string.c'),
|
'sources' : files('fuzz-efi-string.c'),
|
||||||
'base' : efitest_base,
|
|
||||||
},
|
},
|
||||||
{
|
efi_fuzz_template + {
|
||||||
'sources' : files('fuzz-efi-printf.c'),
|
'sources' : files('fuzz-efi-printf.c'),
|
||||||
'base' : efitest_base,
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -153,6 +153,21 @@ executables += [
|
||||||
],
|
],
|
||||||
'dependencies' : libseccomp,
|
'dependencies' : libseccomp,
|
||||||
},
|
},
|
||||||
|
fuzz_template + {
|
||||||
|
'sources' : files('fuzz-unit-file.c'),
|
||||||
|
'link_with' : [
|
||||||
|
libcore,
|
||||||
|
libshared
|
||||||
|
],
|
||||||
|
'dependencies' : libmount,
|
||||||
|
},
|
||||||
|
fuzz_template + {
|
||||||
|
'sources' : files('fuzz-manager-serialize.c'),
|
||||||
|
'link_with' : [
|
||||||
|
libcore,
|
||||||
|
libshared
|
||||||
|
],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
in_files = [['system.conf', pkgsysconfdir],
|
in_files = [['system.conf', pkgsysconfdir],
|
||||||
|
@ -211,21 +226,3 @@ core_test_template = test_template + {
|
||||||
'include_directories' : core_includes,
|
'include_directories' : core_includes,
|
||||||
'suite' : 'core',
|
'suite' : 'core',
|
||||||
}
|
}
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-unit-file.c'),
|
|
||||||
'link_with' : [
|
|
||||||
libcore,
|
|
||||||
libshared
|
|
||||||
],
|
|
||||||
'dependencies' : libmount,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-manager-serialize.c'),
|
|
||||||
'link_with' : [
|
|
||||||
libcore,
|
|
||||||
libshared
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -81,6 +81,14 @@ executables += [
|
||||||
'sources' : systemd_journal_gatewayd_sources,
|
'sources' : systemd_journal_gatewayd_sources,
|
||||||
'dependencies' : common_deps + [libmicrohttpd],
|
'dependencies' : common_deps + [libmicrohttpd],
|
||||||
},
|
},
|
||||||
|
fuzz_template + {
|
||||||
|
'sources' : files('fuzz-journal-remote.c'),
|
||||||
|
'link_with' : [
|
||||||
|
libshared,
|
||||||
|
libsystemd_journal_remote,
|
||||||
|
],
|
||||||
|
'include_directories' : journal_includes,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
in_files = [
|
in_files = [
|
||||||
|
@ -112,16 +120,3 @@ if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
|
||||||
chmod 755 $DESTDIR/var/log/journal/remote || :''')
|
chmod 755 $DESTDIR/var/log/journal/remote || :''')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-journal-remote.c'),
|
|
||||||
'link_with' : [
|
|
||||||
libshared,
|
|
||||||
libsystemd_journal_remote,
|
|
||||||
],
|
|
||||||
'includes' : journal_includes,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -48,6 +48,14 @@ journal_test_template = test_template + {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
journal_fuzz_template = fuzz_template + {
|
||||||
|
'link_with' : [
|
||||||
|
libjournal_core,
|
||||||
|
libshared,
|
||||||
|
],
|
||||||
|
'dependencies' : libselinux,
|
||||||
|
}
|
||||||
|
|
||||||
executables += [
|
executables += [
|
||||||
libexec_template + {
|
libexec_template + {
|
||||||
'name' : 'systemd-journald',
|
'name' : 'systemd-journald',
|
||||||
|
@ -124,6 +132,42 @@ executables += [
|
||||||
journal_test_template + {
|
journal_test_template + {
|
||||||
'sources' : files('test-journal.c'),
|
'sources' : files('test-journal.c'),
|
||||||
},
|
},
|
||||||
|
journal_fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fuzz-journald-audit.c',
|
||||||
|
'fuzz-journald.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
journal_fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fuzz-journald-kmsg.c',
|
||||||
|
'fuzz-journald.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
journal_fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fuzz-journald-native.c',
|
||||||
|
'fuzz-journald.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
journal_fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fuzz-journald-native-fd.c',
|
||||||
|
'fuzz-journald.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
journal_fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fuzz-journald-stream.c',
|
||||||
|
'fuzz-journald.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
journal_fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fuzz-journald-syslog.c',
|
||||||
|
'fuzz-journald.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
if install_sysconfdir_samples
|
if install_sysconfdir_samples
|
||||||
|
@ -150,55 +194,3 @@ if get_option('create-log-dirs')
|
||||||
'setfacl -nm g:wheel:rx,d:g:wheel:rx $DESTDIR/var/log/journal || :')
|
'setfacl -nm g:wheel:rx,d:g:wheel:rx $DESTDIR/var/log/journal || :')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
fuzzer_journald_base = {
|
|
||||||
'link_with' : [libjournal_core, libshared],
|
|
||||||
'dependencies' : [libselinux],
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fuzz-journald-audit.c',
|
|
||||||
'fuzz-journald.c',
|
|
||||||
),
|
|
||||||
'base' : fuzzer_journald_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fuzz-journald-kmsg.c',
|
|
||||||
'fuzz-journald.c',
|
|
||||||
),
|
|
||||||
'base' : fuzzer_journald_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fuzz-journald-native.c',
|
|
||||||
'fuzz-journald.c',
|
|
||||||
),
|
|
||||||
'base' : fuzzer_journald_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fuzz-journald-native-fd.c',
|
|
||||||
'fuzz-journald.c',
|
|
||||||
),
|
|
||||||
'base' : fuzzer_journald_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fuzz-journald-stream.c',
|
|
||||||
'fuzz-journald.c',
|
|
||||||
),
|
|
||||||
'base' : fuzzer_journald_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fuzz-journald-syslog.c',
|
|
||||||
'fuzz-journald.c',
|
|
||||||
),
|
|
||||||
'base' : fuzzer_journald_base,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -47,6 +47,13 @@ network_test_template = test_template + {
|
||||||
'suite' : 'network',
|
'suite' : 'network',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network_fuzz_template = fuzz_template + {
|
||||||
|
'link_with' : [
|
||||||
|
libshared,
|
||||||
|
libsystemd_network,
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
executables += [
|
executables += [
|
||||||
network_test_template + {
|
network_test_template + {
|
||||||
'sources' : files('test-acd.c'),
|
'sources' : files('test-acd.c'),
|
||||||
|
@ -83,35 +90,22 @@ executables += [
|
||||||
network_test_template + {
|
network_test_template + {
|
||||||
'sources' : files('test-sd-dhcp-lease.c'),
|
'sources' : files('test-sd-dhcp-lease.c'),
|
||||||
},
|
},
|
||||||
]
|
network_fuzz_template + {
|
||||||
|
|
||||||
fuzzer_network_base = {
|
|
||||||
'link_with' : [libshared, libsystemd_network],
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-dhcp-client.c'),
|
'sources' : files('fuzz-dhcp-client.c'),
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
},
|
||||||
{
|
network_fuzz_template + {
|
||||||
'sources' : files('fuzz-dhcp6-client.c'),
|
'sources' : files('fuzz-dhcp6-client.c'),
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
},
|
||||||
{
|
network_fuzz_template + {
|
||||||
'sources' : files('fuzz-dhcp-server.c'),
|
'sources' : files('fuzz-dhcp-server.c'),
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
},
|
||||||
{
|
network_fuzz_template + {
|
||||||
'sources' : files('fuzz-dhcp-server-relay.c'),
|
'sources' : files('fuzz-dhcp-server-relay.c'),
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
},
|
||||||
{
|
network_fuzz_template + {
|
||||||
'sources' : files('fuzz-lldp-rx.c'),
|
'sources' : files('fuzz-lldp-rx.c'),
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
},
|
||||||
{
|
network_fuzz_template + {
|
||||||
'sources' : files('fuzz-ndisc-rs.c'),
|
'sources' : files('fuzz-ndisc-rs.c'),
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -114,6 +114,9 @@ network_generator_sources = files(
|
||||||
'generator/network-generator.c',
|
'generator/network-generator.c',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
networkd_network_gperf_gperf = files('networkd-network-gperf.gperf')
|
||||||
|
networkd_netdev_gperf_gperf = files('netdev/netdev-gperf.gperf')
|
||||||
|
|
||||||
sources += custom_target(
|
sources += custom_target(
|
||||||
'networkd-gperf.c',
|
'networkd-gperf.c',
|
||||||
input : 'networkd-gperf.gperf',
|
input : 'networkd-gperf.gperf',
|
||||||
|
@ -122,13 +125,13 @@ sources += custom_target(
|
||||||
|
|
||||||
sources += custom_target(
|
sources += custom_target(
|
||||||
'networkd-network-gperf.c',
|
'networkd-network-gperf.c',
|
||||||
input : 'networkd-network-gperf.gperf',
|
input : networkd_network_gperf_gperf,
|
||||||
output : 'networkd-network-gperf.c',
|
output : 'networkd-network-gperf.c',
|
||||||
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
|
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
|
||||||
|
|
||||||
sources += custom_target(
|
sources += custom_target(
|
||||||
'netdev-gperf.c',
|
'netdev-gperf.c',
|
||||||
input : 'netdev/netdev-gperf.gperf',
|
input : networkd_netdev_gperf_gperf,
|
||||||
output : 'netdev-gperf.c',
|
output : 'netdev-gperf.c',
|
||||||
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
|
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
|
||||||
|
|
||||||
|
@ -158,6 +161,15 @@ network_test_template = test_template + {
|
||||||
'include_directories' : network_includes,
|
'include_directories' : network_includes,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network_fuzz_template = fuzz_template + {
|
||||||
|
'link_with' : [
|
||||||
|
libnetworkd_core,
|
||||||
|
libsystemd_network,
|
||||||
|
],
|
||||||
|
'dependencies' : threads,
|
||||||
|
'include_directories' : network_includes,
|
||||||
|
}
|
||||||
|
|
||||||
executables += [
|
executables += [
|
||||||
libexec_template + {
|
libexec_template + {
|
||||||
'name' : 'systemd-networkd',
|
'name' : 'systemd-networkd',
|
||||||
|
@ -221,6 +233,12 @@ executables += [
|
||||||
network_test_template + {
|
network_test_template + {
|
||||||
'sources' : files('test-networkd-util.c'),
|
'sources' : files('test-networkd-util.c'),
|
||||||
},
|
},
|
||||||
|
network_fuzz_template + {
|
||||||
|
'sources' : files('fuzz-netdev-parser.c'),
|
||||||
|
},
|
||||||
|
network_fuzz_template + {
|
||||||
|
'sources' : files('fuzz-network-parser.c'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
if conf.get('ENABLE_NETWORKD') == 1
|
if conf.get('ENABLE_NETWORKD') == 1
|
||||||
|
@ -244,20 +262,3 @@ if conf.get('ENABLE_NETWORKD') == 1
|
||||||
install_dir : pkgsysconfdir)
|
install_dir : pkgsysconfdir)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
fuzzer_network_base = {
|
|
||||||
'link_with' : [libnetworkd_core, libsystemd_network, networkd_link_with],
|
|
||||||
'dependencies' : threads,
|
|
||||||
'includes' : network_includes,
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-netdev-parser.c'),
|
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-network-parser.c'),
|
|
||||||
'base' : fuzzer_network_base,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ nspawn_common_template = {
|
||||||
'dependencies' : libseccomp,
|
'dependencies' : libseccomp,
|
||||||
}
|
}
|
||||||
nspawn_test_template = test_template + nspawn_common_template
|
nspawn_test_template = test_template + nspawn_common_template
|
||||||
|
nspawn_fuzz_template = fuzz_template + nspawn_common_template
|
||||||
|
|
||||||
executables += [
|
executables += [
|
||||||
executable_template + {
|
executable_template + {
|
||||||
|
@ -69,20 +70,10 @@ executables += [
|
||||||
'dependencies' : libacl,
|
'dependencies' : libacl,
|
||||||
'type' : 'manual',
|
'type' : 'manual',
|
||||||
},
|
},
|
||||||
]
|
nspawn_fuzz_template + {
|
||||||
|
|
||||||
fuzzer_nspawn_base = {
|
|
||||||
'link_with' : [libshared, libnspawn_core],
|
|
||||||
'dependencies' : libseccomp
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-nspawn-settings.c'),
|
'sources' : files('fuzz-nspawn-settings.c'),
|
||||||
'base' : fuzzer_nspawn_base,
|
|
||||||
},
|
},
|
||||||
{
|
nspawn_fuzz_template + {
|
||||||
'sources' : files('fuzz-nspawn-oci.c'),
|
'sources' : files('fuzz-nspawn-oci.c'),
|
||||||
'base' : fuzzer_nspawn_base,
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -134,6 +134,7 @@ resolve_common_template = {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
resolve_test_template = test_template + resolve_common_template
|
resolve_test_template = test_template + resolve_common_template
|
||||||
|
resolve_fuzz_template = fuzz_template + resolve_common_template
|
||||||
|
|
||||||
executables += [
|
executables += [
|
||||||
libexec_template + {
|
libexec_template + {
|
||||||
|
@ -195,6 +196,18 @@ executables += [
|
||||||
],
|
],
|
||||||
'include_directories' : resolve_includes,
|
'include_directories' : resolve_includes,
|
||||||
},
|
},
|
||||||
|
resolve_fuzz_template + {
|
||||||
|
'sources' : files('fuzz-dns-packet.c'),
|
||||||
|
},
|
||||||
|
resolve_fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fuzz-etc-hosts.c',
|
||||||
|
'resolved-etc-hosts.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
resolve_fuzz_template + {
|
||||||
|
'sources' : files('fuzz-resource-record.c'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
if conf.get('ENABLE_RESOLVE') == 1
|
if conf.get('ENABLE_RESOLVE') == 1
|
||||||
|
@ -223,28 +236,3 @@ custom_target(
|
||||||
command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
|
command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
|
||||||
install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples,
|
install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples,
|
||||||
install_dir : pkgsysconfdir)
|
install_dir : pkgsysconfdir)
|
||||||
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
fuzzer_resolve_base = {
|
|
||||||
'link_with' : [libsystemd_resolve_core, libshared],
|
|
||||||
'dependencies' : [lib_openssl_or_gcrypt, libm],
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-dns-packet.c'),
|
|
||||||
'base' : fuzzer_resolve_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fuzz-etc-hosts.c',
|
|
||||||
'resolved-etc-hosts.c',
|
|
||||||
),
|
|
||||||
'base' : fuzzer_resolve_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-resource-record.c'),
|
|
||||||
'base' : fuzzer_resolve_base,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -63,6 +63,14 @@ executables += [
|
||||||
threads,
|
threads,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
fuzz_template + {
|
||||||
|
'sources' : [
|
||||||
|
files('fuzz-systemctl-parse-argv.c'),
|
||||||
|
systemctl_sources,
|
||||||
|
],
|
||||||
|
'link_with' : systemctl_link_with,
|
||||||
|
'c_args' : ['-DFUZZ_SYSTEMCTL_PARSE_ARGV'],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
|
foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
|
||||||
|
@ -71,14 +79,3 @@ foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
|
||||||
bindir / 'systemctl',
|
bindir / 'systemctl',
|
||||||
sbindir / alias)
|
sbindir / alias)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : [
|
|
||||||
files('fuzz-systemctl-parse-argv.c'),
|
|
||||||
systemctl_sources,
|
|
||||||
],
|
|
||||||
'link_with' : systemctl_link_with,
|
|
||||||
'c_args' : '-DFUZZ_SYSTEMCTL_PARSE_ARGV',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -84,9 +84,11 @@ keyboard_keys_from_name_h = custom_target(
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
|
udev_link_gperf_gperf = files('net/link-config-gperf.gperf')
|
||||||
|
|
||||||
link_config_gperf_c = custom_target(
|
link_config_gperf_c = custom_target(
|
||||||
'link-config-gperf.c',
|
'link-config-gperf.c',
|
||||||
input : 'net/link-config-gperf.gperf',
|
input : udev_link_gperf_gperf,
|
||||||
output : 'link-config-gperf.c',
|
output : 'link-config-gperf.c',
|
||||||
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
|
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
|
||||||
|
|
||||||
|
@ -142,6 +144,7 @@ udev_common_template = {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
udev_test_template = test_template + udev_common_template
|
udev_test_template = test_template + udev_common_template
|
||||||
|
udev_fuzz_template = fuzz_template + udev_common_template
|
||||||
|
|
||||||
executables += [
|
executables += [
|
||||||
executable_template + {
|
executable_template + {
|
||||||
|
@ -226,6 +229,22 @@ executables += [
|
||||||
udev_test_template + {
|
udev_test_template + {
|
||||||
'sources' : files('test-udev-spawn.c'),
|
'sources' : files('test-udev-spawn.c'),
|
||||||
},
|
},
|
||||||
|
fuzz_template + {
|
||||||
|
'sources' : files(
|
||||||
|
'fido_id/fuzz-fido-id-desc.c',
|
||||||
|
'fido_id/fido_id_desc.c',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
udev_fuzz_template + {
|
||||||
|
'sources' : files('net/fuzz-link-parser.c'),
|
||||||
|
'include_directories' : udev_includes,
|
||||||
|
},
|
||||||
|
udev_fuzz_template + {
|
||||||
|
'sources' : files('fuzz-udev-rule-parse-value.c'),
|
||||||
|
},
|
||||||
|
udev_fuzz_template + {
|
||||||
|
'sources' : files('fuzz-udev-rules.c'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
meson.add_install_script(meson_make_symlink,
|
meson.add_install_script(meson_make_symlink,
|
||||||
|
@ -252,30 +271,3 @@ if install_sysconfdir
|
||||||
meson.add_install_script('sh', '-c',
|
meson.add_install_script('sh', '-c',
|
||||||
mkdir_p.format(sysconfdir / 'udev/rules.d'))
|
mkdir_p.format(sysconfdir / 'udev/rules.d'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
fuzzer_udev_base = {
|
|
||||||
'link_with' : [libudevd_core, libshared],
|
|
||||||
'dependencies' : [threads, libacl],
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files('net/fuzz-link-parser.c'),
|
|
||||||
'includes' : udev_includes,
|
|
||||||
'base' : fuzzer_udev_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-udev-rule-parse-value.c'),
|
|
||||||
'base' : fuzzer_udev_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files('fuzz-udev-rules.c'),
|
|
||||||
'base' : fuzzer_udev_base,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'sources' : files(
|
|
||||||
'fido_id/fuzz-fido-id-desc.c',
|
|
||||||
'fido_id/fido_id_desc.c',
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -23,10 +23,7 @@ executables += [
|
||||||
'xdg-autostart-service.c',
|
'xdg-autostart-service.c',
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
]
|
fuzz_template + {
|
||||||
|
|
||||||
fuzzers += [
|
|
||||||
{
|
|
||||||
'sources' : files(
|
'sources' : files(
|
||||||
'fuzz-xdg-desktop.c',
|
'fuzz-xdg-desktop.c',
|
||||||
'xdg-autostart-service.c',
|
'xdg-autostart-service.c',
|
||||||
|
|
|
@ -1,32 +1,38 @@
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
generate_directives_py = find_program('generate-directives.py')
|
generate_directives_py = find_program('generate-directives.py')
|
||||||
fuzz_generated_in_dir = meson.current_build_dir()
|
|
||||||
|
|
||||||
fuzz_generated_directives = []
|
fuzz_regression_tests = {}
|
||||||
|
|
||||||
directives = [['fuzz-network-parser_directives', 'src/network/networkd-network-gperf.gperf'],
|
directives = [['fuzz-network-parser', 'directives.network', networkd_network_gperf_gperf],
|
||||||
['fuzz-netdev-parser_directives.netdev', 'src/network/netdev/netdev-gperf.gperf'],
|
['fuzz-netdev-parser', 'directives.netdev', networkd_netdev_gperf_gperf],
|
||||||
['fuzz-link-parser_directives.link', 'src/udev/net/link-config-gperf.gperf'],
|
['fuzz-link-parser', 'directives.link', udev_link_gperf_gperf],
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach tuple : directives
|
foreach tuple : directives
|
||||||
fuzz_generated_directives += custom_target(
|
directive = custom_target(
|
||||||
tuple[0],
|
tuple[1],
|
||||||
output: tuple[0],
|
output: tuple[1],
|
||||||
command: [generate_directives_py, files(project_source_root / tuple[1])],
|
command: [generate_directives_py, tuple[2]],
|
||||||
capture: true)
|
capture: true)
|
||||||
|
|
||||||
|
dict = { 'directives' : [directive] }
|
||||||
|
fuzz_regression_tests += { tuple[0] : dict }
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
unit_directives = []
|
||||||
foreach section : ['Automount', 'Mount', 'Path', 'Scope', 'Service', 'Slice', 'Socket', 'Swap', 'Timer']
|
foreach section : ['Automount', 'Mount', 'Path', 'Scope', 'Service', 'Slice', 'Socket', 'Swap', 'Timer']
|
||||||
unit_type = section.to_lower()
|
unit_type = section.to_lower()
|
||||||
sec_rx = section == 'Service' ? '(Service|Unit|Install)' : section
|
sec_rx = section == 'Service' ? '(Service|Unit|Install)' : section
|
||||||
fuzz_generated_directives += custom_target(
|
name = 'directives.@0@'.format(unit_type)
|
||||||
'fuzz-unit-file_directives.@0@'.format(unit_type),
|
unit_directives += custom_target(
|
||||||
output: 'fuzz-unit-file_directives.@0@'.format(unit_type),
|
name,
|
||||||
|
output: name,
|
||||||
command: [generate_directives_py, load_fragment_gperf_gperf, sec_rx, unit_type],
|
command: [generate_directives_py, load_fragment_gperf_gperf, sec_rx, unit_type],
|
||||||
capture: true)
|
capture: true)
|
||||||
endforeach
|
endforeach
|
||||||
|
dict = { 'directives' : unit_directives }
|
||||||
|
fuzz_regression_tests += { 'fuzz-unit-file' : dict }
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
|
@ -58,21 +64,6 @@ else
|
||||||
out = run_command(sh, '-c', 'cd "@0@"; echo @1@/*/*'.format(project_source_root, fuzz_testsdir), check: true)
|
out = run_command(sh, '-c', 'cd "@0@"; echo @1@/*/*'.format(project_source_root, fuzz_testsdir), check: true)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Fuzz inputs that we generate (see above fuzz_generated_directives)
|
|
||||||
fuzz_regression_tests = {
|
|
||||||
'fuzz-link-parser': [['', 'directives.link']],
|
|
||||||
'fuzz-netdev-parser': [['', 'directives.netdev']],
|
|
||||||
'fuzz-network-parser': [['', 'directives']],
|
|
||||||
'fuzz-unit-file': [['', 'directives.automount'],
|
|
||||||
['', 'directives.mount'],
|
|
||||||
['', 'directives.path'],
|
|
||||||
['', 'directives.scope'],
|
|
||||||
['', 'directives.service'],
|
|
||||||
['', 'directives.slice'],
|
|
||||||
['', 'directives.socket'],
|
|
||||||
['', 'directives.swap'],
|
|
||||||
['', 'directives.timer']]}
|
|
||||||
|
|
||||||
# Add crafted fuzz inputs we have in the repo
|
# Add crafted fuzz inputs we have in the repo
|
||||||
foreach p : out.stdout().split()
|
foreach p : out.stdout().split()
|
||||||
# Remove the last entry which is ''.
|
# Remove the last entry which is ''.
|
||||||
|
@ -84,11 +75,8 @@ foreach p : out.stdout().split()
|
||||||
endif
|
endif
|
||||||
fuzzer = fs.name(fs.parent(p))
|
fuzzer = fs.name(fs.parent(p))
|
||||||
fuzz_in = fs.name(p)
|
fuzz_in = fs.name(p)
|
||||||
if fuzzer not in fuzz_regression_tests
|
|
||||||
fuzz_regression_tests += {fuzzer: []}
|
dict = fuzz_regression_tests.get(fuzzer, {})
|
||||||
endif
|
dict += { 'files' : dict.get('files', []) + files(fuzzer / fuzz_in) }
|
||||||
# Meson parser provision for: fuzz_regression_tests[fuzzer] += [fuzz_in]
|
fuzz_regression_tests += { fuzzer : dict }
|
||||||
l = fuzz_regression_tests[fuzzer]
|
|
||||||
l += [[fuzz_testsdir, fuzz_in]]
|
|
||||||
fuzz_regression_tests += {fuzzer: l}
|
|
||||||
endforeach
|
endforeach
|
||||||
|
|
|
@ -309,7 +309,3 @@ if want_tests != 'false' and conf.get('ENABLE_KERNEL_INSTALL') == 1
|
||||||
args : args,
|
args : args,
|
||||||
depends : deps)
|
depends : deps)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
subdir('fuzz')
|
|
||||||
|
|
Loading…
Reference in a new issue