From: Patrick McHardy <kaber@trash.net>
To: John Lange <john.lange@open-it.ca>
Cc: netfilter-develop <netfilter-devel@lists.netfilter.org>
Subject: Re: iptables --log-uid patch for 2.6
Date: Wed, 08 Dec 2004 05:33:16 +0100 [thread overview]
Message-ID: <41B6840C.1030706@trash.net> (raw)
In-Reply-To: <1101668109.2922.1618.camel@ws102.darkcore.net>
[-- Attachment #1: Type: text/plain, Size: 747 bytes --]
John Lange wrote:
>I sent this to the list yesterday but I don't think it made it through.
>Apologies if it is a duplicate.
>
>Here are patches against the userspace and the kernel which allows the
>logging of the uid that generated the (outgoing) packet.
>
>This patch was originally the work of Martin Josefsson for the 2.4
>kernel but was never incorporated into the main code base. My work here
>simply ports it to the 2.6 kernel and the current version of netfilter
>(iptables).
>
Thanks, I've fixed locking (packets with skb->sk set may reach ipt_LOG
without the socket lock held through tunnel devices, so we need extra
locking) and added this patch to my tree. I'm going to add the userspace
patch when SVN is up again.
Regards
Patrick
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1918 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/12/08 04:53:15+01:00 kaber@coreworks.de
# [NETFILTER]: Add --log-uid option to ipt_LOG
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# net/ipv4/netfilter/ipt_LOG.c
# 2004/12/08 04:53:08+01:00 kaber@coreworks.de +8 -0
# [NETFILTER]: Add --log-uid option to ipt_LOG
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# include/linux/netfilter_ipv4/ipt_LOG.h
# 2004/12/08 04:53:08+01:00 kaber@coreworks.de +2 -1
# [NETFILTER]: Add --log-uid option to ipt_LOG
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
diff -Nru a/include/linux/netfilter_ipv4/ipt_LOG.h b/include/linux/netfilter_ipv4/ipt_LOG.h
--- a/include/linux/netfilter_ipv4/ipt_LOG.h 2004-12-08 05:26:20 +01:00
+++ b/include/linux/netfilter_ipv4/ipt_LOG.h 2004-12-08 05:26:20 +01:00
@@ -4,7 +4,8 @@
#define IPT_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
#define IPT_LOG_TCPOPT 0x02 /* Log TCP options */
#define IPT_LOG_IPOPT 0x04 /* Log IP options */
-#define IPT_LOG_MASK 0x07
+#define IPT_LOG_UID 0x08 /* Log UID owning local socket */
+#define IPT_LOG_MASK 0x0f
struct ipt_log_info {
unsigned char level;
diff -Nru a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
--- a/net/ipv4/netfilter/ipt_LOG.c 2004-12-08 05:26:20 +01:00
+++ b/net/ipv4/netfilter/ipt_LOG.c 2004-12-08 05:26:20 +01:00
@@ -327,6 +327,14 @@
printk("PROTO=%u ", ih->protocol);
}
+ /* Max length: 15 "UID=4294967295 " */
+ if ((info->logflags & IPT_LOG_UID) && !iphoff && skb->sk) {
+ read_lock_bh(&skb->sk->sk_callback_lock);
+ if (skb->sk->sk_socket && skb->sk->sk_socket->file)
+ printk("UID=%u ", skb->sk->sk_socket->file->f_uid);
+ read_unlock_bh(&skb->sk->sk_callback_lock);
+ }
+
/* Proto Max log string length */
/* IP: 40+46+6+11+127 = 230 */
/* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */
next prev parent reply other threads:[~2004-12-08 4:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-28 18:55 iptables --log-uid patch for 2.6 John Lange
2004-12-08 4:33 ` Patrick McHardy [this message]
2004-12-08 6:10 ` John Lange
2004-12-08 17:07 ` Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2004-11-27 22:30 John Lange
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=41B6840C.1030706@trash.net \
--to=kaber@trash.net \
--cc=john.lange@open-it.ca \
--cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.