-
Notifications
You must be signed in to change notification settings - Fork 0
[KFTF]: introduce domain constraints #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: kftf_step1
Are you sure you want to change the base?
Conversation
these via sysfs, and how they can be parsed from the vmlinux binary as well.
constraints to avoid weird errors occurring during parsing.
f988367 to
581f240
Compare
| static int write_input_cb_common(struct file *filp, const char __user *buf, | ||
| size_t len, loff_t *off, void *arg, | ||
| size_t arg_size) | ||
| // XXX: why can't we use without the attribute unused anymore?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe because this function is inlined at every callsite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah could be!
| * | ||
| * Note: if this struct is not a multiple of 64 bytes, everything breaks and | ||
| * we get corrupted data and occasional kernel panics. To avoid this happening, | ||
| * we enforce 64 Byte alignment and statically assert that this struct has size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid we'll have bigger structs in the future (e.g. to list a set of possible values).
Why does everything break?
Maybe we can put the struct length at its beginning?
| "struct kftf_constraint should have size 64"); | ||
|
|
||
| /** | ||
| * __KFTF_DEFINE_CONSTRAINT - defines a fuzz test constraint linked to a given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you normally don't write doc comments for internal macros/functions.
strings) and a field being the length of another.
There was not any mechanism in place in the KFuzzTest for distinguishing between value pointers and array pointers in fuzz test inputs. This information is difficult to parse without additional semantic information on the context. We introduce a new KFTF_ANNOTATE_ARRAY macro that annotates a field in a KFuzzTest input struct as an array, removing this ambiguity.
4a7f93e to
8e1f787
Compare
Description (WIP)
We want to be able to express domain constraint programmatically via macro as we do for exposing kernel fuzz tests with the framework.
This PR, for now, introduces several new macros that define constraint structures with static types. These should be readable in the
.kftf.constraintssection of the VM Linux binary (see PR ethangraham2001/syzkaller#2 on the syzkaller fork). The idea is to also expose these via the debugfs in one or more entries that can be parsed by fuzzing engines.This PR also introduces a few macros for defining annotations - annotations allow us to annotate fields with more information in a way that isn't reflected in a type. For example, a
const char *field may be an array of bytes, or may be a logical string that is null-terminated. We thus allow theFUZZ_TESTauthor to annotate fields in the input structures. We currently supportAny validation of such annotations is left up to the fuzzing engine. For example a length field should be a numerical type, and a string should have base type
(const) char *.