pending-4.4: 610-netfilter_match_bypass_default_check: fix 32bit compat layer
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 16 Oct 2017 09:29:55 +0000 (11:29 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Tue, 24 Oct 2017 20:15:47 +0000 (22:15 +0200)
Patch 610-netfilter_match_bypass_default_check added an extra flag IPT_F_NO_DEF_MATCH
which is copied to user space in function copy_entries_to_user. The 32bit compat
layer function was missing the same logic to copy the flag IPT_F_NO_DEF_MATCH to
user space for a 64bit kernel and 32 bit user space.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Signed-off-by: Thierry Dutre <thierry.dutre@dtsystems.be>
target/linux/generic/pending-4.4/610-netfilter_match_bypass_default_checks.patch

index ea9558fccfb44dacdf9accb38a9c962c81e06c3c..8b96639c7fb8d117d91a1ebfb81e395442dd5b56 100644 (file)
  
        counters = alloc_counters(table);
        if (IS_ERR(counters))
-@@ -974,6 +1003,14 @@ copy_entries_to_user(unsigned int total_
-                       ret = -EFAULT;
+@@ -975,6 +1004,14 @@ copy_entries_to_user(unsigned int total_
                        goto free_counters;
                }
-+
 +              flags = e->ip.flags & IPT_F_MASK;
 +              if (copy_to_user(userptr + off
 +                               + offsetof(struct ipt_entry, ip.flags),
 +                      ret = -EFAULT;
 +                      goto free_counters;
 +              }
++
                for (i = sizeof(struct ipt_entry);
                     i < e->target_offset;
+                    i += m->u.match_size) {
+@@ -1380,12 +1417,15 @@ compat_copy_entry_to_user(struct ipt_ent
+       compat_uint_t origsize;
+       const struct xt_entry_match *ematch;
+       int ret = 0;
++      u8 flags = e->ip.flags & IPT_F_MASK;
+       origsize = *size;
+       ce = (struct compat_ipt_entry __user *)*dstptr;
+       if (copy_to_user(ce, e, sizeof(struct ipt_entry)) != 0 ||
+           copy_to_user(&ce->counters, &counters[i],
+-          sizeof(counters[i])) != 0)
++          sizeof(counters[i])) != 0 ||
++          copy_to_user(&ce->ip.flags, &flags,
++          sizeof(flags)) != 0)
+               return -EFAULT;
+       *dstptr += sizeof(struct compat_ipt_entry);