Skip to content
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

Merged
merged 2 commits into from
Jan 25, 2017
Merged

Embed ipv4 checksums #117

merged 2 commits into from
Jan 25, 2017

Conversation

xairy
Copy link
Collaborator

@xairy xairy commented Jan 25, 2017

No description provided.

@@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/LenType/CsumType/

@xairy
Copy link
Collaborator Author

xairy commented Jan 25, 2017

All done, PTAL

bfLen := uint64(arg.Type.BitfieldLength())
switch arg.Size() {
case 1:
storeByBitmask8((*uint8)(addr), uint8(arg.Value(pid)), bfOff, bfLen)
Copy link
Collaborator

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 {
Copy link
Collaborator

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)
Copy link
Collaborator

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.

@dvyukov
Copy link
Collaborator

dvyukov commented Jan 25, 2017

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.
@xairy xairy merged commit 72353dc into google:master Jan 25, 2017
@xairy xairy deleted the checksums branch January 25, 2017 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants