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/validation.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'prog/validation.go') diff --git a/prog/validation.go b/prog/validation.go index 564c0b060..28c619802 100644 --- a/prog/validation.go +++ b/prog/validation.go @@ -106,9 +106,13 @@ func (c *Call) validate(ctx *validCtx) error { switch typ1.Kind { case sys.BufferString: if typ1.Length != 0 && len(arg.Data) != int(typ1.Length) { - return fmt.Errorf("syscall %v: string arg '%v' has size %v, which should be %v", c.Meta.Name, len(arg.Data), typ1.Length) + return fmt.Errorf("syscall %v: string arg '%v' has size %v, which should be %v", c.Meta.Name, typ.Name(), len(arg.Data), typ1.Length) } } + case *sys.CsumType: + if arg.Val != 0 { + return fmt.Errorf("syscall %v: csum arg '%v' has nonzero value %v", c.Meta.Name, typ.Name(), arg.Val) + } } switch arg.Kind { case ArgConst: -- cgit mrf-deployment