aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux/init_iptables.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-30 14:17:47 -0700
committerDmitry Vyukov <dvyukov@google.com>2018-08-30 21:45:03 -0700
commite8dd2c6713522707b3b89884eb95601cdf9bc9be (patch)
tree9df12a938af90c06794ec9f60920d59330766ed1 /sys/linux/init_iptables.go
parent6ba5fe3e62880ddf8aeec68ab44eabaa8bc148b8 (diff)
prog: add concept of "special pointers"
Currently we only generate either valid user-space pointers or NULL. Extend NULL to a set of special pointers that we will use in programs. All targets now contain 3 special values: - NULL - 0xfffffffffffffff (invalid kernel pointer) - 0x999999999999999 (non-canonical address) Each target can add additional special pointers on top of this. Also generate NULL/special pointers for non-opt ptr's. This restriction was always too restrictive. We may want to generate them with very low probability, but we do want to generate them. Also change pointers to NULL/special during mutation (but still not in the opposite direction).
Diffstat (limited to 'sys/linux/init_iptables.go')
-rw-r--r--sys/linux/init_iptables.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/linux/init_iptables.go b/sys/linux/init_iptables.go
index 231bcfb77..2a49bffe4 100644
--- a/sys/linux/init_iptables.go
+++ b/sys/linux/init_iptables.go
@@ -126,6 +126,9 @@ func (arch *arch) generateEbtables(g *prog.Gen, typ prog.Type, old prog.Arg) (
}
tableArg := arg.(*prog.UnionArg).Option.(*prog.GroupArg)
entriesPtr := tableArg.Inner[entriesField].(*prog.PointerArg)
+ if entriesPtr.Res == nil {
+ return
+ }
entriesArray := entriesPtr.Res.(*prog.GroupArg)
offsets := make([]uint64, len(entriesArray.Inner))
var pos, totalEntries uint64
@@ -165,8 +168,15 @@ func (arch *arch) sanitizeEbtables(c *prog.Call) {
// This is very hacky... just as netfilter interfaces.
// setsockopt's len argument must be equal to size of ebt_replace + entries size.
lenArg := c.Args[4].(*prog.ConstArg)
- tableArg := c.Args[3].(*prog.PointerArg).Res.(*prog.UnionArg).Option.(*prog.GroupArg)
+ tablePtr := c.Args[3].(*prog.PointerArg).Res
+ if tablePtr == nil {
+ return
+ }
+ tableArg := tablePtr.(*prog.UnionArg).Option.(*prog.GroupArg)
entriesField := len(tableArg.Inner) - 1
entriesArg := tableArg.Inner[entriesField].(*prog.PointerArg).Res
+ if entriesArg == nil {
+ return
+ }
lenArg.Val = tableArg.Size() + entriesArg.Size()
}