tests: Add the image fuzzer with qcow2 support
v2 cover tests: Add the image fuzzer with qcow2 support
This patch series introduces the image fuzzer, a tool for stability and reliability testing.
Its approach is to run large amount of tests in background. During every test a program (e.g. qemu-img) is called to read or modify an invalid test image. A test image has valid inner structure defined by its format specification with some fields having random invalid values.
Patch 1 contains documentation for the image fuzzer, patch 2 is the test runner and remaining ones relate to the image generator for qcow2 format.
This patch series was created for the 'block-next' branch.
v1 -> v2:
* refactored qcow2/layout module
* added support of external fuzzer configurations
* fixed wrong string truncation in qcow2/fuzz module
* fixed documentation typos and ambiguities (based on Eric Blake comments)
* updated documentation with the fuzzer configuration
* add LICENSE file (based on Eric Blake comments)
Maria Kustova (6):
docs: Specification for the image fuzzer
runner: Tool for fuzz tests execution
fuzz: Fuzzing functions for qcow2 images
layout: Generator of fuzzed qcow2 images
package: Public API for image-fuzzer/runner/runner.py
image-fuzzer: GPLv2 license file
tests/image-fuzzer/LICENSE | 339 +++++++++++++++++++++++++++++++ tests/image-fuzzer/docs/fuzzer.conf | 37 ++++ tests/image-fuzzer/docs/image-fuzzer.txt | 216 ++++++++++++++++++++ tests/image-fuzzer/qcow2/__init__.py | 1 + tests/image-fuzzer/qcow2/fuzz.py | 328 ++++++++++++++++++++++++++++++ tests/image-fuzzer/qcow2/layout.py | 319 +++++++++++++++++++++++++++++ tests/image-fuzzer/runner/runner.py | 290 ++++++++++++++++++++++++++ 7 files changed, 1530 insertions(+) create mode 100644 tests/image-fuzzer/LICENSE create mode 100644 tests/image-fuzzer/docs/fuzzer.conf create mode 100644 tests/image-fuzzer/docs/image-fuzzer.txt create mode 100644 tests/image-fuzzer/qcow2/__init__.py create mode 100644 tests/image-fuzzer/qcow2/fuzz.py create mode 100644 tests/image-fuzzer/qcow2/layout.py create mode 100755 tests/image-fuzzer/runner/runner.py
Signature · 1 line
1.9.3
PATCH v2 1/6 docs: Specification for the image fuzzer
'Overall fuzzer requirements' chapter contains the current product vision and features done and to be done. This chapter is still in progress.
v1 -> v2:
* added description for fuzzer configuration files
* added the example fuzzer.conf file
* various fixes based on the Eric's review
--- tests/image-fuzzer/docs/fuzzer.conf | 37 ++++++ tests/image-fuzzer/docs/image-fuzzer.txt | 216 +++++++++++++++++++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 tests/image-fuzzer/docs/fuzzer.conf create mode 100644 tests/image-fuzzer/docs/image-fuzzer.txt
tests/image-fuzzer/docs/fuzzer.conf new file +37 -0
@@ -0,0 +1,37 @@ +# Python version < 2.7 doesn't support empty options +# Option values will not be interpreted +[header] +magic=True +version=True +backing_file_offset=True +backing_file_size=True +cluster_bits=True +size=True +crypt_method=True +l1_size=True +l1_table_offset=True +refcount_table_offset=True +refcount_table_clusters=True +nb_snapshots=True +snapshots_offset=True +incompatible_features=True +compatible_features=True +autoclear_features=True +refcount_order=True +header_length=True + +[backing_file_format_ext] +ext_magic=True +ext_length=True +bf_data=True + +[feature_name_table_ext] +ext_magic=True +ext_length=True +feat_type=True +feat_bit_number=True +feat_name=True + +[end_ext] +ext_magic=True +ext_length=True
tests/image-fuzzer/docs/image-fuzzer.txt new file +216 -0
216 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH v2 2/6 runner: Tool for fuzz tests execution
In reply to Maria KustovaThe purpose of the test runner is to prepare test environment (e.g. create a work directory, a test image, etc), execute the program under test with parameters, indicate a test failure if the program was killed during test execution and collect core dumps, logs and other test artifacts.
The test runner doesn't depend on image format or a program will be tested, so it can be used with any external image generator and program under test.
v1 -> v2:
Added parameter for a fuzzer configuration file
--- tests/image-fuzzer/runner/runner.py | 290 ++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100755 tests/image-fuzzer/runner/runner.py
tests/image-fuzzer/runner/runner.py new file +290 -0
@@ -0,0 +1,290 @@ +#!/usr/bin/env python + +# Tool for running fuzz tests +# +# Copyright (C) 2014 Maria Kustova <[email protected]> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import sys, os, signal +from time import time +import subprocess +import random +from itertools import count +from shutil import rmtree +import getopt +import ConfigParser +import resource +resource.setrlimit(resource.RLIMIT_CORE, (-1, -1)) + + +def multilog(msg, *output): + """ Write an object to all of specified file descriptors + """ + + for fd in output: + fd.write(msg) + fd.flush() + + +def str_signal(sig): + """ Convert a numeric value of a system signal to the string one + defined by the current operational system + """ + + for k, v in signal.__dict__.items(): + if v == sig: + return k + + +class TestException(Exception): + """Exception for errors risen by TestEnv objects""" + pass + + +class TestEnv(object): + """ Trivial test object + + The class sets up test environment, generates a test image and executes + application under tests with specified arguments and a test image provided. + All logs are collected. + Summary log will contain short descriptions and statuses of tests in + a run. + Test log will include application (e.g. 'qemu-img') logs besides info sent + to the summary log. + """ + + def __init__(self, test_id, seed, work_dir, run_log, exec_bin=None, + cleanup=True, log_all=False, fuzz_config=None): + """Set test environment in a specified work directory. + + Path to qemu_img will be retrieved from 'QEMU_IMG' environment + variable, if a test binary is not specified. + """ + + if seed is not None: + self.seed = seed + else: + self.seed = hash(time()) + + self.init_path = os.getcwd() + self.work_dir = work_dir + self.current_dir = os.path.join(work_dir, 'test-' + test_id) + if exec_bin is not None: + self.exec_bin = exec_bin.strip().split(' ') + else: + self.exec_bin = \ + os.environ.get('QEMU_IMG', 'qemu-img').strip().split(' ') + + try: + os.makedirs(self.current_dir) + except OSError: + e = sys.exc_info()[1] + print >>sys.stderr, \ + "Error: The working directory '%s' cannot be used. Reason: %s"\ + % (self.work_dir, e[1]) + raise TestException + self.log = open(os.path.join(self.current_dir, "test.log"), "w") + self.parent_log = open(run_log, "a") + self.result = False + self.cleanup = cleanup + self.log_all = log_all + self.fuzz_config = fuzz_config + + def _test_app(self, q_args): + """ Start application under test with specified arguments and return + an exit code or a kill signal depending on result of an execution. + """ + devnull = open('/dev/null', 'r+') + return subprocess.call(self.exec_bin + q_args, + stdin=devnull, stdout=self.log, stderr=self.log) + + def execute(self, q_args): + """ Execute a test. + + The method creates a test image, runs the test app and analyzes + its exit status. If the application was killed by a signal, + the test is marked as failed. + """ + os.chdir(self.current_dir) + # Seed initialization should be as close to an image generation call + # as posssible to avoid a corruption of the random sequence + random.seed(self.seed) + image_generator.create_image('test_image', self.fuzz_config) + test_summary = "Seed: %s\nCommand: %s\nTest directory: %s\n" \ + % (self.seed, " ".join(q_args), self.current_dir) + try: + retcode = self._test_app(q_args) + except OSError: + e = sys.exc_info()[1] + multilog(test_summary + "Error: Start of '%s' failed. " \ + "Reason: %s\n\n" % (os.path.basename(self.exec_bin[0]), + e[1]), + sys.stderr, self.log, self.parent_log) + raise TestException + + if retcode < 0: + multilog(test_summary + "FAIL: Test terminated by signal %s\n\n" + % str_signal(-retcode), sys.stderr, self.log, + self.parent_log) + elif self.log_all: + multilog(test_summary + "PASS: Application exited with the code" + + " '%d'\n\n" % retcode, sys.stdout, self.log, + self.parent_log) + self.result = True + else: + self.result = True + + def finish(self): + """ Restore environment after a test execution. Remove folders of + passed tests + """ + self.log.close() + self.parent_log.close() + os.chdir(self.init_path) + if self.result and self.cleanup: + rmtree(self.current_dir) + +if __name__ == '__main__': + + def usage(): + print """ + Usage: runner.py [OPTION...] TEST_DIR IMG_GENERATOR + + Set up test environment in TEST_DIR and run a test in it. A module for + test image generation should be specified via IMG_GENERATOR. Use + TEST_IMG alias to mark the position in the command where a test image + name should be placed. + Example: + python runner.py -b ./qemu-img -c 'info TEST_IMG' /tmp/test ../qcow2 + + Optional arguments: + -h, --help display this help and exit + -b, --binary=PATH path to the application under test, + by default "qemu-img" in PATH or + QEMU_IMG environment variables + -c, --command=STRING execute the tested application + with arguments specified, + by default STRING="check" + -s, --seed=STRING seed for a test image generation, + by default will be generated randomly + --config=FILE take fuzzer a configuration from FILE + -k, --keep_passed don't remove folders of passed tests + -v, --verbose log information about passed tests + """ + + def run_test(test_id, seed, work_dir, run_log, test_bin, cleanup, log_all, + command, fuzz_config): + """Setup environment for one test and execute this test""" + try: + test = TestEnv(test_id, seed, work_dir, run_log, test_bin, cleanup, + log_all, fuzz_config) + except TestException: + sys.exit(1) + + # Python 2.4 doesn't support 'finally' and 'except' in the same 'try' + # block + try: + try: + test.execute(command) + # Silent exit on user break + except TestException: + sys.exit(1) + finally: + test.finish() + + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], 'c:hb:s:kv', + ['command=', 'help', 'binary=', 'seed=', + 'config=', 'keep_passed', 'verbose']) + except getopt.error: + e = sys.exc_info()[1] + print "Error: %s\n\nTry 'runner.py --help' for more information" % e + sys.exit(1) + + command = ['check'] + cleanup = True + log_all = False + test_bin = None + seed = None + config_file = None + for opt, arg in opts: + if opt in ('-h', '--help'): + usage() + sys.exit() + elif opt in ('-c', '--command'): + command = arg.split(" ") + elif opt in ('-k', '--keep_passed'): + cleanup = False + elif opt in ('-v', '--verbose'): + log_all = True + elif opt in ('-b', '--binary'): + test_bin = os.path.realpath(arg) + elif opt in ('-s', '--seed'): + seed = arg + elif opt == '--config': + config_file = arg + + if not len(args) == 2: + print "Missed parameter\nTry 'runner.py --help' " \ + "for more information" + sys.exit(1) + + work_dir = os.path.realpath(args[0]) + # run_log is created in 'main', because multiple tests are expected to + # log in it + run_log = os.path.join(work_dir, 'run.log') + + # Add the path to the image generator module to sys.path + sys.path.append(os.path.dirname(os.path.realpath(args[1]))) + # Remove a script extension from image generator module if any + generator_name = os.path.splitext(os.path.basename(args[1]))[0] + try: + image_generator = __import__(generator_name) + except ImportError: + e = sys.exc_info()[1] + print "Error: The image generator '%s' cannot be imported.\n" \ + "Reason: %s" % (generator_name, e) + sys.exit(1) + + # Replace test image alias with its real name + for idx, item in enumerate(command): + if item == 'TEST_IMG': + command[idx] = 'test_image' + # Read fuzzer configuration + if config_file is None: + fuzz_config = None + else: + fuzz_config = [] + config = ConfigParser.RawConfigParser() + config.read(config_file) + for s in config.sections(): + opt_list = config.options(s) + if len(opt_list) == 0: + fuzz_config.append([s]) + else: + for o in opt_list: + fuzz_config.append([s, o]) + # If a seed is specified, only one test will be executed. + # Otherwise runner will terminate after a keyboard interruption + for test_id in count(1): + try: + run_test(str(test_id), seed, work_dir, run_log, test_bin, cleanup, + log_all, command, fuzz_config) + except (KeyboardInterrupt, SystemExit): + sys.exit(1) + + if seed is not None: + break
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH V2 2/6] runner: Tool for fuzz tests execution
Quoted 2 lines · Maria Kustova
v1 -> v2:
Added parameter for a fuzzer configuration file
In the future revisions, please put such revision change notes below a '---' line, like:
<commit log>
Signed-off-by: Your Name <[email protected]>
---
v1 -> v2: changeThis way, it doesn't get into git log when maintainers apply your patch email with "git am".
The reason is that revision notes only matter when reviewing patches, but has no value once applied to master.
Thanks,
Fam
PATCH v2 3/6 fuzz: Fuzzing functions for qcow2 images
In reply to Maria KustovaFuzz submodule of qcow2 image generator contains fuzzing functions for image fields.
Each fuzzing function contains list of constraints and call of a helper function that randomly selects a fuzzed value satisfied to one of constraints. For now constraints are only known as invalid or potentially dangerous values. But after investigation of code coverage by fuzz tests they will be expanded by heuristic values based on inner checks and flows of a program under test.
Now fuzzing of header and header extensions is supported.
v1 -> v2:
Fixed incorrect string truncation in 'truncate_string()'
--- tests/image-fuzzer/qcow2/fuzz.py | 328 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 tests/image-fuzzer/qcow2/fuzz.py
tests/image-fuzzer/qcow2/fuzz.py new file +328 -0
@@ -0,0 +1,328 @@ +# Fuzzing functions for qcow2 fields +# +# Copyright (C) 2014 Maria Kustova <[email protected]> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import random + + +UINT32 = 0xffffffff +UINT64 = 0xffffffffffffffff +# Most significant bit orders +UINT32_M = 31 +UINT64_M = 63 +# Fuzz vectors +UINT32_V = [0, 0x100, 0x1000, 0x10000, 0x100000, UINT32/4, UINT32/2 - 1, + UINT32/2, UINT32/2 + 1, UINT32 - 1, UINT32] +UINT64_V = UINT32_V + [0x1000000, 0x10000000, 0x100000000, UINT64/4, + UINT64/2 - 1, UINT64/2, UINT64/2 + 1, UINT64 - 1, + UINT64] +STRING_V = ['%s%p%x%d', '.1024d', '%.2049d', '%p%p%p%p', '%x%x%x%x', + '%d%d%d%d', '%s%s%s%s', '%99999999999s', '%08x', '%%20d', '%%20n', + '%%20x', '%%20s', '%s%s%s%s%s%s%s%s%s%s', '%p%p%p%p%p%p%p%p%p%p', + '%#0123456x%08x%x%s%p%d%n%o%u%c%h%l%q%j%z%Z%t%i%e%g%f%a%C%S%08x%%', + '%s x 129', '%x x 257'] + + +def random_from_intervals(intervals): + """Select a random integer number from the list of specified intervals + + Each interval is a tuple of lower and upper limits of the interval. The + limits are included. Intervals in a list should not overlap. + """ + total = reduce(lambda x, y: x + y[1] - y[0] + 1, intervals, 0) + r = random.randint(0, total-1) + intervals[0][0] + temp = zip(intervals, intervals[1:]) + for x in temp: + r = r + (r > x[0][1])*(x[1][0] - x[0][1] - 1) + return r + + +def random_bits(bit_ranges): + """Generate random binary mask with ones in the specified bit ranges + + Each bit_ranges is a list of tuples of lower and upper limits of bit + positions will be fuzzed. The limits are included. Random amount of bits + in range limits will be set to ones. The mask is returned in decimal + integer format. + """ + bit_numbers = [] + # Select random amount of random positions in bit_ranges + for rng in bit_ranges: + bit_numbers += random.sample(range(rng[0], rng[1] + 1), + random.randint(0, rng[1] - rng[0] + 1)) + val = 0 + # Set bits on selected possitions to ones + for bit in bit_numbers: + val |= 1 << bit + return val + + +def truncate_string(strings, length): + """Return strings truncated to the specified length""" + if type(strings) == list: + return [s[:length] for s in strings] + else: + return strings[:length] + + +def int_validator(current, intervals): + """Return a random value from intervals not equal to the current. + + This function is useful for selection from valid values except current one. + """ + val = random_from_intervals(intervals) + if val == current: + return int_validator(current, intervals) + else: + return val + + +def bit_validator(current, bit_ranges): + """Return a random bit mask not equal to the current. + + This function is useful for selection from valid values except current one. + """ + + val = random_bits(bit_ranges) + if val == current: + return bit_validator(current, bit_ranges) + else: + return val + + +def string_validator(current, strings): + """Return a random string value from the list not equal to the current. + + This function is useful for selection from valid values except current one. + """ + val = random.choice(strings) + if val == current: + return string_validator(current, strings) + else: + return val + + +def selector(current, constraints, fmt=None): + """Select one value from all defined by constraints + + Each constraint produces one random value satisfying to it. The function + randomly selects one value satisfying at least one constraint (depending on + constraints overlaps). + """ + validate = { + 'bitmask': bit_validator, + 'string': string_validator + }.get(fmt, int_validator) + + def iter_validate(c): + """Apply validate() only to constraints represented as lists + + This auxiliary function replaces short circuit conditions not supported + in Python 2.4 + """ + if type(c) == list: + return validate(current, c) + else: + return c + fuzz_values = [iter_validate(c) for c in constraints] + # Remove current for cases it's implicitly specified in constraints + # Duplicate validator functionality to prevent decreasing of probability + # to get one of allowable values + # TODO: remove validators after implementation of intelligent selection + # of fields will be fuzzed + try: + fuzz_values.remove(current) + except ValueError: + pass + return random.choice(fuzz_values) + + +def magic(current): + """Fuzz magic header field + + The function just returns the current magic value and provides uniformity + of calls for all fuzzing functions + """ + return current + + +def version(current): + """Fuzz version header field""" + constraints = UINT32_V + [ + [(2, 3)], # correct values + [(0, 1), (4, UINT32)] + ] + return selector(current, constraints) + + +def backing_file_offset(current): + """Fuzz backing file offset header field""" + constraints = UINT64_V + return selector(current, constraints) + + +def backing_file_size(current): + """Fuzz backing file size header field""" + constraints = UINT32_V + return selector(current, constraints) + + +def cluster_bits(current): + """Fuzz cluster bits header field""" + constraints = UINT32_V + [ + [(9, 20)], # correct values + [(0, 9), (20, UINT32)] + ] + return selector(current, constraints) + + +def size(current): + """Fuzz image size header field""" + constraints = UINT64_V + return selector(current, constraints) + + +def crypt_method(current): + """Fuzz crypt method header field""" + constraints = UINT32_V + [ + 1, + [(2, UINT32)] + ] + return selector(current, constraints) + + +def l1_size(current): + """Fuzz L1 table size header field""" + constraints = UINT32_V + return selector(current, constraints) + + +def l1_table_offset(current): + """Fuzz L1 table offset header field""" + constraints = UINT64_V + return selector(current, constraints) + + +def refcount_table_offset(current): + """Fuzz refcount table offset header field""" + constraints = UINT64_V + return selector(current, constraints) + + +def refcount_table_clusters(current): + """Fuzz refcount table clusters header field""" + constraints = UINT32_V + return selector(current, constraints) + + +def nb_snapshots(current): + """Fuzz number of snapshots header field""" + constraints = UINT32_V + return selector(current, constraints) + + +def snapshots_offset(current): + """Fuzz snapshots offset header field""" + constraints = UINT64_V + return selector(current, constraints) + + +def incompatible_features(current): + """Fuzz incompatible features header field""" + constraints = [ + [(0, 1)], # allowable values + [(0, UINT64_M)] + ] + return selector(current, constraints, 'bitmask') + + +def compatible_features(current): + """Fuzz compatible features header field""" + constraints = [ + [(0, UINT64_M)] + ] + return selector(current, constraints, 'bitmask') + + +def autoclear_features(current): + """Fuzz autoclear features header field""" + constraints = [ + [(0, UINT64_M)] + ] + return selector(current, constraints, 'bitmask') + + +def refcount_order(current): + """Fuzz number of refcount order header field""" + constraints = UINT32_V + return selector(current, constraints) + + +def header_length(current): + """Fuzz number of refcount order header field""" + constraints = UINT32_V + [ + 72, + 104, + [(0, UINT32)] + ] + return selector(current, constraints) + + +def ext_magic(current): + """Fuzz magic field of a header extension""" + constraints = UINT32_V + return selector(current, constraints) + + +def ext_length(current): + """Fuzz length field of a header extension""" + constraints = UINT32_V + return selector(current, constraints) + + +def bf_data(current): + """Fuzz backing file format in the corresponding header extension""" + constraints = [ + truncate_string(STRING_V, len(current)), + truncate_string(STRING_V, (len(current) + 7) & ~7) # Fuzz padding + ] + return selector(current, constraints, 'string') + + +def feat_type(current): + """Fuzz feature type field of a feature name table header extension""" + constraints = [ + [(0, 255)] + ] + return selector(current, constraints) + + +def feat_bit_number(current): + """Fuzz bit number field of a feature name table header extension""" + constraints = [ + [(0, 255)] + ] + return selector(current, constraints) + + +def feat_name(current): + """Fuzz feature name field of a feature name table header extension""" + constraints = [ + truncate_string(STRING_V, len(current)), + truncate_string(STRING_V, 48) # Fuzz padding (field length = 48) + ] + return selector(current, constraints, 'string')
Signature · 1 line
1.9.3
PATCH v2 4/6 layout: Generator of fuzzed qcow2 images
In reply to Maria KustovaLayout submodule of qcow2 package creates a random valid image, randomly selects some amount of its fields, fuzzes them and write the fuzzed image to the file.
Now only header and header extensions are generated, a remaining file is filled by zeroes.
v1 -> v2:
* Added support of fuzzer configurations.
* Created general Image class:
** fixed mixed defs/classes module style
** internalized all functions related to image generation ** simplified internal image representation
--- tests/image-fuzzer/qcow2/layout.py | 319 +++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 tests/image-fuzzer/qcow2/layout.py
tests/image-fuzzer/qcow2/layout.py new file +319 -0
@@ -0,0 +1,319 @@ +# Generator of fuzzed qcow2 images +# +# Copyright (C) 2014 Maria Kustova <[email protected]> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import random +import struct +import qcow2.fuzz + +MAX_IMAGE_SIZE = 10*2**20 +# Standard sizes +UINT32_S = 4 +UINT64_S = 8 + +# Percentage of fields will be fuzzed +BIAS = random.uniform(0.2, 0.5) + + +class Field(object): + """Atomic image element (field) + + The class represents an image field as quadruple of a data format + of value necessary for its packing to binary form, an offset from + the beginning of the image, a value and a name. + + The field can be iterated as a list [format, offset, value] + """ + __slots__ = ('fmt', 'offset', 'value', 'name') + + def __init__(self, fmt, offset, val, name): + self.fmt = fmt + self.offset = offset + self.value = val + self.name = name + + def __iter__(self): + return (x for x in [self.fmt, self.offset, self.value]) + + def __repr__(self): + return "Field(fmt='%s', offset=%d, value=%s, name=%s)" % \ + (self.fmt, self.offset, str(self.value), self.name) + + +class FieldsList(object): + """List of fields + + The class allows access to a field in the list by its name and joins + several list in one via in-place addition + """ + def __init__(self, meta_data=None): + if meta_data is None: + self.data = [] + else: + self.data = [Field(f[0], f[1], f[2], f[3]) + for f in meta_data] + + def __getitem__(self, name): + return [x for x in self.data if x.name == name] + + def __iter__(self): + return (x for x in self.data) + + def __iadd__(self, other): + self.data += other.data + return self + + def __len__(self): + return len(self.data) + + +class Image(object): + """ Qcow2 image object + + This class allows to create valid qcow2 images with random structure, + fuzz them via external qcow2.fuzz module and write to files. + """ + @staticmethod + def _size_params(): + """Generate a random file size aligned to a random correct cluster size + """ + cluster_bits = random.randrange(9, 21) + cluster_size = 1 << cluster_bits + # Minimal image size is equal to 5 clusters as for qcow2 empty image + # created by qemu-img + file_size = random.randrange(5*cluster_size, MAX_IMAGE_SIZE + 1, + cluster_size) + return [cluster_bits, file_size] + + @staticmethod + def _header(cluster_bits, img_size): + """Generate a random valid header""" + meta_header = [ + ['>4s', 0, "QFI\xfb", 'magic'], + ['>I', 4, random.randint(2, 3), 'version'], + ['>Q', 8, 0, 'backing_file_offset'], + ['>I', 16, 0, 'backing_file_size'], + ['>I', 20, cluster_bits, 'cluster_bits'], + ['>Q', 24, img_size, 'size'], + ['>I', 32, 0, 'crypt_method'], + ['>I', 36, 0, 'l1_size'], + ['>Q', 40, 0, 'l1_table_offset'], + ['>Q', 48, 0, 'refcount_table_offset'], + ['>I', 56, 0, 'refcount_table_clusters'], + ['>I', 60, 0, 'nb_snapshots'], + ['>Q', 64, 0, 'snapshots_offset'], + ['>Q', 72, 0, 'incompatible_features'], + ['>Q', 80, 0, 'compatible_features'], + ['>Q', 88, 0, 'autoclear_features'], + # From the e-mail thread for [PATCH] docs: Define refcount_bits + # value: Only refcount_order = 4 is supported by QEMU at the moment + ['>I', 96, 4, 'refcount_order'], + ['>I', 100, 0, 'header_length'] + ] + v_header = FieldsList(meta_header) + + if v_header['version'][0].value == 2: + v_header['header_length'][0].value = 72 + else: + v_header['incompatible_features'][0].value = random.getrandbits(2) + v_header['compatible_features'][0].value = random.getrandbits(1) + v_header['header_length'][0].value = 104 + + return v_header + + @staticmethod + def _backing_file_format_ext(header): + """Generate a random header extension for name of backing file + format + + If the header doesn't contain information about the backing file, + this extension is left empty + """ + offset = struct.calcsize(header['header_length'][0].fmt) + \ + header['header_length'][0].offset + + if not header['backing_file_offset'][0].value == 0: + # Till real backup image is not supported, a random valid fmt + # is set + ext_data = random.choice(['raw', 'qcow', 'qcow2', 'qed', + 'cow', 'vdi', 'vmdk', 'vpc', + 'vhdx', 'bochs', 'cloop', + 'dmg', 'parallels']) + ext_data_len = len(ext_data) + ext_data_padded = '>' + str(ext_data_len) + 's' + \ + str(7 - (ext_data_len - 1) % 8) + 'x' + ext = FieldsList([ + ['>I', offset, 0xE2792ACA, 'ext_magic'], + ['>I', offset + UINT32_S, ext_data_len, 'ext_length'], + [ext_data_padded, offset + UINT32_S*2, ext_data, + 'bf_data'] + ]) + offset = ext['bf_data'][0].offset + \ + struct.calcsize(ext['bf_data'][0].fmt) + else: + ext = FieldsList() + return (ext, offset) + + @staticmethod + def _feature_name_table_ext(header, offset): + """Generate a random header extension for names of features used in + the image + + If all features bit masks in the header are set to zeroes, + this extension is left empty + """ + feature_tables = [] + # Current offset + magic and length fields of the feature table + # extension + inner_offset = offset + 2*UINT32_S + + # Each tuple includes bit value in the corresponding header field, + # feature type, number of the bit in the header field and feature name + feature_list = [ + (header['incompatible_features'][0].value & 1, 0, + 1, 'dirty bit'), + (header['incompatible_features'][0].value & 2, 0, + 2, 'corrupt bit'), + (header['compatible_features'][0].value & 1, 1, + 1, 'lazy refcounts bit') + ] + for item in feature_list: + if not item[0] == 0: + name_len = len(item[3]) + name_padded_fmt = '>' + str(name_len) + 's' + \ + str(46 - name_len) + 'x' + feature_tables += [['B', inner_offset, item[1], 'feat_type'], + ['B', inner_offset + 1, + item[2], 'feat_bit_number'], + [name_padded_fmt, inner_offset + 2, + item[3], 'feat_name'] + ] + inner_offset = inner_offset + 2 + \ + struct.calcsize(name_padded_fmt) + + if not len(feature_tables) == 0: + # No padding for the extension is necessary, because + # the extension length = 8 + 48*N is multiple of 8 + ext = FieldsList([ + ['>I', offset, 0x6803f857, 'ext_magic'], + ['>I', offset + UINT32_S, len(feature_tables)*48,'ext_length'] + ] + feature_tables) + offset = inner_offset + else: + ext = FieldsList() + + return (ext, offset) + + @staticmethod + def _end_ext(offset): + """Generate a mandatory header extension marking end of header + extensions + """ + ext = FieldsList([ + ['>I', offset, 0, 'ext_magic'], + ['>I', offset + UINT32_S, 0, 'ext_length'] + ]) + return (ext, offset) + + def __init__(self): + """Create a random valid qcow2 image with the correct inner structure + and allowable values + """ + # Image size is necessary for writing, but the field with it can be + # fuzzed so it's saved separately. + cluster_bits, self.image_size = self._size_params() + self.header = self._header(cluster_bits, self.image_size) + self.backing_file_format_ext, \ + offset = self._backing_file_format_ext(self.header) + self.feature_name_table_ext, \ + offset = self._feature_name_table_ext(self.header, offset) + self.end_ext, offset = self._end_ext(offset) + # Container for entire image + self.data = FieldsList() + + def __iter__(self): + return (x for x in [self.header, self.backing_file_format_ext, + self.feature_name_table_ext, self.end_ext]) + + def _join(self): + """Join all image structure elements as header, tables, etc in one + list of fields + """ + if len(self.data) == 0: + for v in self: + self.data += v + + def fuzz(self, fields_to_fuzz=None): + """Fuzz an image by corrupting values of a random subset of its fields + + Without parameters the method fuzzes an entire image. + If 'fields_to_fuzz' is specified then only fields in this list will be + fuzzed. 'fields_to_fuzz' can contain both individual fields and more + general image elements as header or tables. + In the first case the single field will be fuzzed always. + In the second a random subset of fields will be selected and fuzzed. + """ + def coin(): + """Return boolean value proportional to a portion of fields to be + fuzzed + """ + return random.random() < BIAS + + if fields_to_fuzz is None: + self._join() + for field in self.data: + if coin(): + field.value = getattr(qcow2.fuzz, field.name)(field.value) + else: + for item in fields_to_fuzz: + if len(item) == 1: + for field in self.__dict__[item[0]]: + if coin(): + field.value = getattr(qcow2.fuzz, + field.name)(field.value) + else: + for field in self.__dict__[item[0]][item[1]]: + try: + field.value = getattr(qcow2.fuzz, field.name)( + field.value) + except AttributeError: + # Some fields can be skipped depending on + # references, e.g. FNT header extension is not + # generated for a feature mask header field + # equal to zero + pass + + def write(self, filename): + """Writes an entire image to the file""" + image_file = open(filename, 'w') + # Create an empty image + # (sparse if FS supports it or preallocated otherwise) + image_file.seek(self.image_size - 1) + image_file.write("\0") + self._join() + for field in self.data: + image_file.seek(field.offset) + image_file.write(struct.pack(field.fmt, field.value)) + + image_file.close() + + +def create_image(test_img_path, fields_to_fuzz=None): + """Create a fuzzed image and write it to the specified file""" + image = Image() + image.fuzz(fields_to_fuzz) + image.write(test_img_path)
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH V2 4/6] layout: Generator of fuzzed qcow2 images
Quoted 138 lines · Maria Kustova
Layout submodule of qcow2 package creates a random valid image, randomly selects some amount of its fields, fuzzes them and write the fuzzed image to the file.
Now only header and header extensions are generated, a remaining file is filled by zeroes.v1 -> v2:
* Added support of fuzzer configurations.
* Created general Image class:
** fixed mixed defs/classes module style
** internalized all functions related to image generation ** simplified internal image representationSigned-off-by Maria Kustova <[email protected]>--- tests/image-fuzzer/qcow2/layout.py | 319 +++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 tests/image-fuzzer/qcow2/layout.pytests/image-fuzzer/qcow2/layout.py new file +113
-0@@ -0,0 +1,319 @@ +# Generator of fuzzed qcow2 images +# +# Copyright (C) 2014 Maria Kustova <[email protected]> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import random +import struct +import qcow2.fuzz + +MAX_IMAGE_SIZE = 10*2**20 +# Standard sizes +UINT32_S = 4 +UINT64_S = 8 + +# Percentage of fields will be fuzzed +BIAS = random.uniform(0.2, 0.5) + + +class Field(object): + """Atomic image element (field) + + The class represents an image field as quadruple of a data format + of value necessary for its packing to binary form, an offset from + the beginning of the image, a value and a name. + + The field can be iterated as a list [format, offset, value] + """ + __slots__ = ('fmt', 'offset', 'value', 'name') + + def __init__(self, fmt, offset, val, name): + self.fmt = fmt + self.offset = offset + self.value = val + self.name = name + + def __iter__(self): + return (x for x in [self.fmt, self.offset, self.value]) + + def __repr__(self): + return "Field(fmt='%s', offset=%d, value=%s, name=%s)" % \ + (self.fmt, self.offset, str(self.value), self.name) + + +class FieldsList(object): + """List of fields + + The class allows access to a field in the list by its name and joins + several list in one via in-place addition + """ + def __init__(self, meta_data=None): + if meta_data is None: + self.data = [] + else: + self.data = [Field(f[0], f[1], f[2], f[3]) + for f in meta_data] + + def __getitem__(self, name): + return [x for x in self.data if x.name == name] + + def __iter__(self): + return (x for x in self.data) + + def __iadd__(self, other): + self.data += other.data + return self + + def __len__(self): + return len(self.data) + + +class Image(object): + """ Qcow2 image object + + This class allows to create valid qcow2 images with random structure, + fuzz them via external qcow2.fuzz module and write to files. + """ + @staticmethod + def _size_params(): + """Generate a random file size aligned to a random correct cluster size + """ + cluster_bits = random.randrange(9, 21) + cluster_size = 1 << cluster_bits + # Minimal image size is equal to 5 clusters as for qcow2 empty image + # created by qemu-img + file_size = random.randrange(5*cluster_size, MAX_IMAGE_SIZE + 1, + cluster_size) + return [cluster_bits, file_size] + + @staticmethod + def _header(cluster_bits, img_size): + """Generate a random valid header""" + meta_header = [ + ['>4s', 0, "QFI\xfb", 'magic'], + ['>I', 4, random.randint(2, 3), 'version'], + ['>Q', 8, 0, 'backing_file_offset'], + ['>I', 16, 0, 'backing_file_size'], + ['>I', 20, cluster_bits, 'cluster_bits'], + ['>Q', 24, img_size, 'size'], + ['>I', 32, 0, 'crypt_method'], + ['>I', 36, 0, 'l1_size'],
tests/image-fuzzer/qcow2/layout.py line 123
Quoted 10 lines
tests/image-fuzzer/qcow2/layout.py new file +10
-0+ ['>Q', 40, 0, 'l1_table_offset'], + ['>Q', 48, 0, 'refcount_table_offset'], + ['>I', 56, 0, 'refcount_table_clusters'], + ['>I', 60, 0, 'nb_snapshots'], + ['>Q', 64, 0, 'snapshots_offset'], + ['>Q', 72, 0, 'incompatible_features'], + ['>Q', 80, 0, 'compatible_features'], + ['>Q', 88, 0, 'autoclear_features'], + # From the e-mail thread for [PATCH] docs: Define refcount_bits + # value: Only refcount_order = 4 is supported by QEMU at the moment
Better to refer docs/specs/qcow2.txt instead of an email thread, since it's already merged.
Fam
Quoted 3 lines
tests/image-fuzzer/qcow2/layout.py new file +3
-0+ ['>I', 96, 4, 'refcount_order'], + ['>I', 100, 0, 'header_length'] + ]
PATCH v2 5/6 package: Public API for image-fuzzer/runner/runner.py
In reply to Maria Kustova__init__.py provides the public API required by the test runner
--- tests/image-fuzzer/qcow2/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/image-fuzzer/qcow2/__init__.py
tests/image-fuzzer/qcow2/__init__.py new file +1 -0
@@ -0,0 +1 @@ +from layout import create_image
Signature · 1 line
1.9.3
PATCH v2 6/6 image-fuzzer: GPLv2 license file
In reply to Maria Kustova--- tests/image-fuzzer/LICENSE | 339 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 tests/image-fuzzer/LICENSE
tests/image-fuzzer/LICENSE new file +339 -0
@@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License.
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH V2 6/6] image-fuzzer: GPLv2 license file
Quoted 1 line · Maria Kustova
Signed-off-by Maria Kustova <[email protected]>
You have the copyright headers in each file, so it's not really necessary to put the license here.
No need to respin for this, if it's unwanted in the end, maintainer could probably skip when merging the series.
Fam