From d0405298b24db0e2a6b2abfdc8c7e5ebbe49d1a0 Mon Sep 17 00:00:00 2001 From: Hrutvik Kanabar Date: Tue, 25 Oct 2022 10:13:51 +0000 Subject: prog, pkg/compiler: add `BufferCompressed` buffer type & `compressed_image` builtin Create the `BufferCompressed` kind of `BufferType`, which will be used to represent compressed data. Create the corresponding `compressed_image` syzlang builtin, which is backed by `BufferCompressed`. For now, no syscalls use this feature - this will be introduced in future commits. We have to be careful to decompress the data before mutating, and re-compress before storing. We make sure that any deserialised `BufferCompressed` data is valid too. `BufferCompressed` arguments are mutated using a generic heatmap. In future, we could add variants of `BufferCompressed` or populate the `BufferType` sub-kind, using it to choose different kinds of heatmap for different uncompressed data formats. Various operations on compressed data must be forbidden, so we check for `BufferCompressed` in key places. We also have to ensure `compressed_image` can only be used in syscalls that are marked `no_{generate,minimize}`. Therefore, we add a generic compiler check which allows type descriptions to require attributes on the syscalls which use them. --- pkg/compiler/testdata/all.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pkg/compiler/testdata/all.txt') diff --git a/pkg/compiler/testdata/all.txt b/pkg/compiler/testdata/all.txt index d03e35def..6fd9f7cc6 100644 --- a/pkg/compiler/testdata/all.txt +++ b/pkg/compiler/testdata/all.txt @@ -322,3 +322,19 @@ struct$fmt0 { } flags_with_one_value = 0 + +# Compressed images. + +struct_compressed { + f0 compressed_image +} + +union_compressed [ + f0 compressed_image + f1 int32 +] [varlen] + +compressed$1(a compressed_image) (no_generate, no_minimize) +compressed$2(a ptr[in, compressed_image]) (no_generate, no_minimize) +compressed$3(a ptr[in, struct_compressed]) (no_generate, no_minimize) +compressed$4(a ptr[in, union_compressed]) (no_generate, no_minimize) \ No newline at end of file -- cgit mrf-deployment