From 63b16a5d5cfd3b41f596daccd56d32b2548ec119 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Wed, 25 Jan 2017 16:18:05 +0100 Subject: prog, sys: add csum type, embed checksums for ipv4 packets This change adds a `csum[kind, type]` type. The only available kind right now is `ipv4`. Using `csum[ipv4, int16be]` in `ipv4_header` makes syzkaller calculate and embed correct checksums into ipv4 packets. --- prog/mutation.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'prog/mutation.go') diff --git a/prog/mutation.go b/prog/mutation.go index 04465a424..358a2b104 100644 --- a/prog/mutation.go +++ b/prog/mutation.go @@ -197,6 +197,8 @@ func (p *Prog) Mutate(rs rand.Source, ncalls int, ct *ChoiceTable, corpus []*Pro p.replaceArg(c, arg, arg1, calls) case *sys.LenType: panic("bad arg returned by mutationArgs: LenType") + case *sys.CsumType: + panic("bad arg returned by mutationArgs: CsumType") case *sys.ConstType: panic("bad arg returned by mutationArgs: ConstType") default: @@ -397,7 +399,7 @@ func Minimize(p0 *Prog, callIndex0 int, pred func(*Prog, int) bool, crash bool) } } p0 = p - case *sys.VmaType, *sys.LenType, *sys.ConstType: + case *sys.VmaType, *sys.LenType, *sys.CsumType, *sys.ConstType: // TODO: try to remove offset from vma return false default: @@ -460,6 +462,9 @@ func mutationArgs(c *Call) (args, bases []*Arg) { case *sys.LenType: // Size is updated when the size-of arg change. return + case *sys.CsumType: + // Checksum is updated when the checksummed data changes. + return case *sys.ConstType: // Well, this is const. return -- cgit mrf-deployment