Skip to contentSkip to conversation

: complain when broken ipt_owner options are used on SMP

PATCH In review Harald Welte 1 participant 1 message Jun 21, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/10 : complain when broken ipt_owner options are used on SMP

This patch for 2.4 makes ipt_owner and ip6t_owner complain when options that are broken on SMP are used. When the pid, sid or command is matched the owner match takes files->file_lock in a BH, which deadlocks on SMP.

Author: Patrick McHardy <[email protected]>

--
- Harald Welte <[email protected]> http://www.netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/06/20 22:28:50+02:00 [email protected]
# [NETFILTER]: complain about brokeness on SMP for pid, sid and command matching in ipt_owner
#

# net/ipv6/netfilter/ip6t_owner.c
#   2004/06/20 22:28:48+02:00 [email protected] +8 -1
#   [NETFILTER]: complain about brokeness on SMP for pid, sid and command matching in ipt_owner
# 
# net/ipv4/netfilter/ipt_owner.c
#   2004/06/20 22:28:48+02:00 [email protected] +9 -1
#   [NETFILTER]: complain about brokeness on SMP for pid, sid and command matching in ipt_owner
# 
diff -Nru a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c
--- a/net/ipv4/netfilter/ipt_owner.c	2004-06-20 23:02:36 +02:00
+++ b/net/ipv4/netfilter/ipt_owner.c	2004-06-20 23:02:36 +02:00
@@ -171,7 +171,15 @@

if (matchsize != IPT_ALIGN(sizeof(struct ipt_owner_info)))
return 0;
-
+#ifdef CONFIG_SMP
+ /* files->file_lock can not be used in a BH */
+ if (((struct ipt_owner_info *)matchinfo)->match
+ & (IPT_OWNER_PID|IPT_OWNER_SID|IPT_OWNER_COMM)) {
+ printk("ipt_owner: pid, sid and command matching is broken "
+ "on SMP.\n");
+ return 0;
+ }
+#endif
return 1;
}

net/ipv6/netfilter/ip6t_owner.c +8 -1
diff -Nru a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c
@@ -137,7 +137,14 @@
 
 	if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_owner_info)))
 		return 0;
-
+#ifdef CONFIG_SMP
+	/* files->file_lock can not be used in a BH */
+	if (((struct ip6t_owner_info *)matchinfo)->match
+	    & (IP6T_OWNER_PID|IP6T_OWNER_SID)) {
+		printk("ip6t_owner: pid and sid matching is broken on SMP.\n");
+		return 0;
+	}
+#endif
 	return 1;
 }