-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Embed ipv4 checksums #117
Embed ipv4 checksums #117
Conversation
@@ -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: LenType") |
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.
s/LenType/CsumType/
All done, PTAL |
bfLen := uint64(arg.Type.BitfieldLength()) | ||
switch arg.Size() { | ||
case 1: | ||
storeByBitmask8((*uint8)(addr), uint8(arg.Value(pid)), bfOff, bfLen) |
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.
Please also declare val := arg.Value(pid)
outside of the switch.
return csumField, &newCsumField | ||
} | ||
|
||
func calcChecksumsArray(args []*Arg, pid int) map[*Arg]*Arg { |
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.
Please inline this into calcChecksumsCall as that's the only caller.
} | ||
|
||
func calcChecksumsArray(args []*Arg, pid int) map[*Arg]*Arg { | ||
m := make(map[*Arg]*Arg) |
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.
Declare it as var m map[*Arg]*Arg
and then in the loop:
if m == nil {
m = make(map[*Arg]*Arg)
}
This will remove memory allocation from hot path in expected case when there are no checksums.
Otherwise LGTM |
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.
No description provided.