From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH 3/3] xt_owner match
Date: Mon, 19 Nov 2007 16:43:33 +0100 [thread overview]
Message-ID: <4741AF25.5080604@trash.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0711161400360.3340@fbirervta.pbzchgretzou.qr>
Jan Engelhardt wrote:
> As with xt_tos and xt_TOS, the old header files are kept for the time,
> and we define a revision 0 which is compatible with ipt_tos/ipt_TOS -
> same for xt_owner.
>
> --- net-2.6.25.orig/include/linux/netfilter_ipv4/Kbuild
> +++ net-2.6.25/include/linux/netfilter_ipv4/Kbuild
> @@ -29,7 +29,6 @@ header-y += ipt_limit.h
> header-y += ipt_mac.h
> header-y += ipt_mark.h
> header-y += ipt_multiport.h
> -header-y += ipt_owner.h
> header-y += ipt_physdev.h
> header-y += ipt_pkttype.h
> header-y += ipt_policy.h
> Index: net-2.6.25/include/linux/netfilter_ipv6/Kbuild
> ===================================================================
> --- net-2.6.25.orig/include/linux/netfilter_ipv6/Kbuild
> +++ net-2.6.25/include/linux/netfilter_ipv6/Kbuild
> @@ -13,7 +13,6 @@ header-y += ip6t_mac.h
> header-y += ip6t_mark.h
> header-y += ip6t_multiport.h
> header-y += ip6t_opts.h
> -header-y += ip6t_owner.h
> header-y += ip6t_physdev.h
> header-y += ip6t_policy.h
> header-y += ip6t_rt.h
Please keep both.
> +config NETFILTER_XT_MATCH_OWNER
> + tristate '"owner" match support'
> + depends on NETFILTER_XTABLES
> + ---help---
> + Socket owner matching allows you to match locally-generated packets
> + based on who created the socket: the user, group, process or session.
Only user and group are supported.
> +#include <linux/module.h>
> +#include <linux/skbuff.h>
> +#include <linux/file.h>
> +#include <net/sock.h>
> +#include <linux/netfilter/x_tables.h>
> +#include <linux/netfilter/xt_owner.h>
> +#include <linux/netfilter_ipv4/ipt_owner.h>
> +#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)
> +{
> + const struct ipt_owner_info *info = matchinfo;
> + const struct file *filp;
> +
> + if (skb->sk == NULL || skb->sk->sk_socket == NULL)
> + return false;
> +
> + filp = skb->sk->sk_socket->file;
> + if (filp == NULL)
> + return false;
What would be nice is to allow matching whether a socket exists,
without UID/GID. I had a patch for this for a long time, but
lost it somewhere.
> +
> + if (info->match & IPT_OWNER_UID)
> + if ((filp->f_uid != info->uid) ^
> + !!(info->invert & IPT_OWNER_UID))
> + return false;
> +
> + if (info->match & IPT_OWNER_GID)
> + if ((filp->f_gid != info->gid) ^
> + !!(info->invert & IPT_OWNER_GID))
> + return false;
> +
> + return true;
> +}
> +
> +static struct xt_match owner_mt_reg[] __read_mostly = {
> + {
> + .name = "owner",
> + .revision = 0,
> + .family = AF_INET,
> + .match = owner_mt_v0,
> + .matchsize = sizeof(struct ipt_owner_info),
> + .checkentry = owner_mt_check_v0,
> + .hooks = (1 << NF_IP_LOCAL_OUT) |
> + (1 << NF_IP_POST_ROUTING),
This needs to use NF_INET_...
Please resend all your patches when you want me to apply them.
Thanks.
next prev parent reply other threads:[~2007-11-19 15:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-16 13:00 [PATCH 1/3] xt_tos match Jan Engelhardt
2007-11-16 13:00 ` [PATCH 2/3] xt_TOS target Jan Engelhardt
2007-11-19 10:40 ` Patrick McHardy
2007-11-19 11:46 ` Jan Engelhardt
2007-11-16 13:01 ` [PATCH 3/3] xt_owner match Jan Engelhardt
2007-11-19 15:43 ` Patrick McHardy [this message]
2007-11-19 16:56 ` Jan Engelhardt
2007-11-19 17:08 ` Jan Engelhardt
2007-11-19 17:12 ` Jan Engelhardt
2007-11-19 17:18 ` Patrick McHardy
2007-11-19 17:10 ` Patrick McHardy
2007-11-19 10:37 ` [PATCH 1/3] xt_tos match Patrick McHardy
2007-11-19 11:39 ` Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4741AF25.5080604@trash.net \
--to=kaber@trash.net \
--cc=jengelh@computergmbh.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).