Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile
[cascardo/linux.git] / net / netfilter / xt_owner.c
index 9059c16..22b2a5e 100644 (file)
 #include <linux/netfilter_ipv6/ip6t_owner.h>
 
 static bool
-owner_mt_v0(const struct sk_buff *skb, const struct net_device *in,
-            const struct net_device *out, const struct xt_match *match,
-            const void *matchinfo, int offset, unsigned int protoff,
-            bool *hotdrop)
+owner_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
 {
-       const struct ipt_owner_info *info = matchinfo;
+       const struct ipt_owner_info *info = par->matchinfo;
        const struct file *filp;
 
        if (skb->sk == NULL || skb->sk->sk_socket == NULL)
@@ -37,12 +34,12 @@ owner_mt_v0(const struct sk_buff *skb, const struct net_device *in,
                return false;
 
        if (info->match & IPT_OWNER_UID)
-               if ((filp->f_uid != info->uid) ^
+               if ((filp->f_cred->fsuid != info->uid) ^
                    !!(info->invert & IPT_OWNER_UID))
                        return false;
 
        if (info->match & IPT_OWNER_GID)
-               if ((filp->f_gid != info->gid) ^
+               if ((filp->f_cred->fsgid != info->gid) ^
                    !!(info->invert & IPT_OWNER_GID))
                        return false;
 
@@ -50,12 +47,9 @@ owner_mt_v0(const struct sk_buff *skb, const struct net_device *in,
 }
 
 static bool
-owner_mt6_v0(const struct sk_buff *skb, const struct net_device *in,
-             const struct net_device *out, const struct xt_match *match,
-             const void *matchinfo, int offset, unsigned int protoff,
-             bool *hotdrop)
+owner_mt6_v0(const struct sk_buff *skb, const struct xt_match_param *par)
 {
-       const struct ip6t_owner_info *info = matchinfo;
+       const struct ip6t_owner_info *info = par->matchinfo;
        const struct file *filp;
 
        if (skb->sk == NULL || skb->sk->sk_socket == NULL)
@@ -66,12 +60,12 @@ owner_mt6_v0(const struct sk_buff *skb, const struct net_device *in,
                return false;
 
        if (info->match & IP6T_OWNER_UID)
-               if ((filp->f_uid != info->uid) ^
+               if ((filp->f_cred->fsuid != info->uid) ^
                    !!(info->invert & IP6T_OWNER_UID))
                        return false;
 
        if (info->match & IP6T_OWNER_GID)
-               if ((filp->f_gid != info->gid) ^
+               if ((filp->f_cred->fsgid != info->gid) ^
                    !!(info->invert & IP6T_OWNER_GID))
                        return false;
 
@@ -79,12 +73,9 @@ owner_mt6_v0(const struct sk_buff *skb, const struct net_device *in,
 }
 
 static bool
-owner_mt(const struct sk_buff *skb, const struct net_device *in,
-         const struct net_device *out, const struct xt_match *match,
-         const void *matchinfo, int offset, unsigned int protoff,
-         bool *hotdrop)
+owner_mt(const struct sk_buff *skb, const struct xt_match_param *par)
 {
-       const struct xt_owner_match_info *info = matchinfo;
+       const struct xt_owner_match_info *info = par->matchinfo;
        const struct file *filp;
 
        if (skb->sk == NULL || skb->sk->sk_socket == NULL)
@@ -102,26 +93,23 @@ owner_mt(const struct sk_buff *skb, const struct net_device *in,
                       (XT_OWNER_UID | XT_OWNER_GID)) == 0;
 
        if (info->match & XT_OWNER_UID)
-               if ((filp->f_uid >= info->uid_min &&
-                   filp->f_uid <= info->uid_max) ^
+               if ((filp->f_cred->fsuid >= info->uid_min &&
+                   filp->f_cred->fsuid <= info->uid_max) ^
                    !(info->invert & XT_OWNER_UID))
                        return false;
 
        if (info->match & XT_OWNER_GID)
-               if ((filp->f_gid >= info->gid_min &&
-                   filp->f_gid <= info->gid_max) ^
+               if ((filp->f_cred->fsgid >= info->gid_min &&
+                   filp->f_cred->fsgid <= info->gid_max) ^
                    !(info->invert & XT_OWNER_GID))
                        return false;
 
        return true;
 }
 
-static bool
-owner_mt_check_v0(const char *tablename, const void *ip,
-                  const struct xt_match *match, void *matchinfo,
-                  unsigned int hook_mask)
+static bool owner_mt_check_v0(const struct xt_mtchk_param *par)
 {
-       const struct ipt_owner_info *info = matchinfo;
+       const struct ipt_owner_info *info = par->matchinfo;
 
        if (info->match & (IPT_OWNER_PID | IPT_OWNER_SID | IPT_OWNER_COMM)) {
                printk(KERN_WARNING KBUILD_MODNAME
@@ -133,12 +121,9 @@ owner_mt_check_v0(const char *tablename, const void *ip,
        return true;
 }
 
-static bool
-owner_mt6_check_v0(const char *tablename, const void *ip,
-                   const struct xt_match *match, void *matchinfo,
-                   unsigned int hook_mask)
+static bool owner_mt6_check_v0(const struct xt_mtchk_param *par)
 {
-       const struct ip6t_owner_info *info = matchinfo;
+       const struct ip6t_owner_info *info = par->matchinfo;
 
        if (info->match & (IP6T_OWNER_PID | IP6T_OWNER_SID)) {
                printk(KERN_WARNING KBUILD_MODNAME
@@ -153,7 +138,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = {
        {
                .name       = "owner",
                .revision   = 0,
-               .family     = AF_INET,
+               .family     = NFPROTO_IPV4,
                .match      = owner_mt_v0,
                .matchsize  = sizeof(struct ipt_owner_info),
                .checkentry = owner_mt_check_v0,
@@ -164,7 +149,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = {
        {
                .name       = "owner",
                .revision   = 0,
-               .family     = AF_INET6,
+               .family     = NFPROTO_IPV6,
                .match      = owner_mt6_v0,
                .matchsize  = sizeof(struct ip6t_owner_info),
                .checkentry = owner_mt6_check_v0,
@@ -175,17 +160,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = {
        {
                .name       = "owner",
                .revision   = 1,
-               .family     = AF_INET,
-               .match      = owner_mt,
-               .matchsize  = sizeof(struct xt_owner_match_info),
-               .hooks      = (1 << NF_INET_LOCAL_OUT) |
-                             (1 << NF_INET_POST_ROUTING),
-               .me         = THIS_MODULE,
-       },
-       {
-               .name       = "owner",
-               .revision   = 1,
-               .family     = AF_INET6,
+               .family     = NFPROTO_UNSPEC,
                .match      = owner_mt,
                .matchsize  = sizeof(struct xt_owner_match_info),
                .hooks      = (1 << NF_INET_LOCAL_OUT) |