Bug#150467: user-defined chains vs. iptables module names
The problem deals with user-defined chain names clashing with iptables module names. Basically, it's entirely possible to create a user-defined chain with the same name (case sensitive) as a target module, but the new chain cannot be used as a jump target.
It is a packaging problem of sorts because an upgrade with new modules can suddenly conflict with existing user-defined chains.
As always, don't shoot the messenger.
Any proposal on what do do about it?
The problems I see when making iptables rulesets are
* There is no distinction between terminal actions, jumps and
modifiers/nonterminal actions, all three look the same but are conceptually quite different. Most of you have seen this problem with the LOG target, but there is several other examples.
* Only one modifier or target can be applied per rule. I.e. it is impossible
to LOG, MARK and ACCEPT in the same rule, to do all three three rules is currently needed.
As a workaround to the problem of not having a distinction beteen "modifiers" and targets it has been proposed to recode the LOG target as a match, but this does not feel right to me, and there is several other "non-terminal targets" sharing the same problem. Having modifiers implemented as matches gives a ugly dependency on ordering within the rule.
My proposal on how to deal with this is for the future is to
1. Introduce the concept of a modifier. A modifier is something that
modifies some aspect of the packet or netfilter but does not in itself make any verdict on the packet. Examples of suitable modifiers are MARK, CONNMARK, ECN, LOG etc.. This would make a rule consist of 1. IP match data. 2. list of matches. 3. list of modifiers. 4. action.
2. Introduce a virtual JUMP action or flag for jumping to a custom chain
only. This can be done today to workaround the problem of custom chains colliding with modules by only extending the userspace syntax with a way to explicitly indicate a jump to a custom chain as this is only a limitation of the userspace component.
Regard
Henrik
Quoted 11 lines · Laurence J. Lane
The problem deals with user-defined chain names clashing with iptables module names. Basically, it's entirely possible to create a user-defined chain with the same name (case sensitive) as a target module, but the new chain cannot be used as a jump target.
It is a packaging problem of sorts because an upgrade with new modules can suddenly conflict with existing user-defined chains.
As always, don't shoot the messenger.
2002-06-20 17:36:11+0200, Henrik Nordstrom <[email protected]> ->
Quoted 29 lines
Any proposal on what do do about it?
The problems I see when making iptables rulesets are
* There is no distinction between terminal actions, jumps and
modifiers/nonterminal actions, all three look the same but are conceptually quite different. Most of you have seen this problem with the LOG target, but there is several other examples.* Only one modifier or target can be applied per rule. I.e. it is impossible
to LOG, MARK and ACCEPT in the same rule, to do all three three rules is currently needed.As a workaround to the problem of not having a distinction beteen "modifiers" and targets it has been proposed to recode the LOG target as a match, but this does not feel right to me, and there is several other "non-terminal targets" sharing the same problem. Having modifiers implemented as matches gives a ugly dependency on ordering within the rule.
My proposal on how to deal with this is for the future is to
1. Introduce the concept of a modifier. A modifier is something that
modifies some aspect of the packet or netfilter but does not in itself make any verdict on the packet. Examples of suitable modifiers are MARK, CONNMARK, ECN, LOG etc.. This would make a rule consist of 1. IP match data. 2. list of matches. 3. list of modifiers. 4. action.
Quoted 6 lines
2. Introduce a virtual JUMP action or flag for jumping to a custom chain
only. This can be done today to workaround the problem of custom chains colliding with modules by only extending the userspace syntax with a way to explicitly indicate a jump to a custom chain as this is only a limitation of the userspace component.
A very good idea with the "modifiers". However i do not feel that LOG is a modifer. Its neither a match. More like an action, action as what action mean as a word. You want to use action as the same thing as -j is today (correct?). The name modifier will collide with match as they both begins with m (the -m option).
May instead propose to take the name "action". And keep the -j TARGET name. Meaning:
1. IP match data
2. A list of matches
3. (If 1 and 2 all matches) A list of actions. (LOG, MARK, CONNMARK).
4. An optional target. Can be this virtual JUMP.
Example:
iptables -A INPUT -s 10.11.12.13 \
-m limit --limit 5/s -m unclean --unlean-option \
-a Log --log-prefix -a Mark --mark-option \
-j JUMP --jump-chain my_own_chain
'-a' is unused today as well. Note that i did start all Actions with a capital and the rest lowercase.
I guess however this is all due to iptables (pkttables?) for kernel 2.5.
Signature · 1 line
/Joakim Axelsson A.K.A Gozem@EFnet & OPN
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160
Replying to Joakim Axelsson:
Quoted 8 lines
May instead propose to take the name "action". And keep the -j TARGET name. Meaning:
1. IP match data
2. A list of matches
3. (If 1 and 2 all matches) A list of actions. (LOG, MARK, CONNMARK).
4. An optional target. Can be this virtual JUMP.
Quoted 6 lines
Example:
iptables -A INPUT -s 10.11.12.13 \
-m limit --limit 5/s -m unclean --unlean-option \
-a Log --log-prefix -a Mark --mark-option \
-j JUMP --jump-chainmy_own_chain
too complex, but in-line with current design
so what do you think about compile&exec idea existed for a long time in form of bpf/lpf and re-implemented for firewall packet filtering by ipfw creator for freebsd-CURRENT ?
for one who don't read it. the basic, the IDEA is to take a complex match and compile it into set of smaller matches taken in some order, with jump-like instructions, linking our "matchset" by jumps forward and backward to (finally) "exit"
replace matches with "transformations" or "plugin function calls", respectively
(yes, it way too much from current design, heh, that's why I'm asking "what do you think")
- --
Paul P 'Stingray' Komkoff 'Greatest' Jr /// (icq)23200764 /// (http)stingr.net
When you're invisible, the only one really watching you is you (my keychain)
-----BEGIN PGP SIGNATURE-----
iEYEAREDAAYFAj0SG7cACgkQyMW8naS07KSQBACfdZDE0A/qfq3zbTY0uDRP/aoY iIkAn0cRlNbHjSy0JQjIYD9PqGq87PYC
=Yx9b
-----END PGP SIGNATURE-----
Quoted 2 lines
replace matches with "transformations" or "plugin function calls", respectively
Hey, let's put Parrot in the kernel and use that.
:)
Patrick
Quoted 4 lines · Laurence J. Lane
The problem deals with user-defined chain names clashing with iptables module names. Basically, it's entirely possible to create a user-defined chain with the same name (case sensitive) as a target module, but the new chain cannot be used as a jump target.
We've already seen proposals to solve the problem, but please, we must maintain as much backward compatibility as possible. Every syntactical (and semantical) change results only confusion.
The built-in chain and target names are all fully capitalized. What about the simple restriction that user-defined chain name cannot be a string consisting of capitalized letters only.
Regards,
Jozsef
-
E-mail : [email protected], [email protected]
WWW-Home: http://www.kfki.hu/~kadlec
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Quoted 3 lines
The built-in chain and target names are all fully capitalized. What about the simple restriction that user-defined chain name cannot be a string consisting of capitalized letters only.
This is again breaking backwards compatibility. For example, most of my rulesets contain two chains, named "RD" and "LRD". The first does the "REJECT with limit, then DROP" stance, and the second puts a "LOG with limit" in front of that. As both chains are "designed" to be used with the same ease as REJECT or DROP, the "ALL CAPS" naming makes eminent sense to me.
Let me make a different proposal, providing backward compatibility while giving active control over the ambiguity:
- permit the definition of user defined chains having the same name as a possible target. This is now the case by chance, depending on whether an extension module is loaded, or not. My proposal is to permit it in all cases.
- when a user defined chain with the same name as a builtin target gets created, make all references to that target now refer to the new user-defined chain. This is the radical step, I think. If I define a chain named "LOG", all my logging targets would now refer to it.
- provide special syntax to call builtin targets, only. This may be a new command line option, or it may be as simple as putting "+" in front of the target name.
Here's an example of what I mean:
iptables -A INPUT bla bla bla -j LOG
...
iptables -N LOG
iptables -A LOG -m limit --limit 1/s -j +LOG --log-prefix "FILTER: "
After that sequence, the INPUT chain LOG would jump to the new LOG chain, and the "+LOG" there would call the real builtin target.
The only drawback I can see now, is that builtin targets take arguments, while user defined chains don't. Anyway, what do you all think of the above general proposal?
best regards
Patrick
Quoted 10 lines · Patrick Schaaf
Quoted 3 lines
The built-in chain and target names are all fully capitalized. What about the simple restriction that user-defined chain name cannot be a string consisting of capitalized letters only.
This is again breaking backwards compatibility. For example, most of my rulesets contain two chains, named "RD" and "LRD". The first does the "REJECT with limit, then DROP" stance, and the second puts a "LOG with limit" in front of that. As both chains are "designed" to be used with the same ease as REJECT or DROP, the "ALL CAPS" naming makes eminent sense to me.
Yes, it'd break backward compatibility as well. I see the reasoning for all capitals in user defined chains as well.
What about simply returning by an error code if there is an attempt to create a chain wich clashes with a target name?
Regards,
Jozsef
-
E-mail : [email protected], [email protected]
WWW-Home: http://www.kfki.hu/~kadlec
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Quoted 2 lines
What about simply returning by an error code if there is an attempt to create a chain wich clashes with a target name?
Wasn't there recent discussion about "how do I find all available target names"? But I agree in principle, that would be the least intrusive shorttime "rationalization" of the now-very-order-dependant behaviour.
I could still shoot myself in the foot by installing a new target into a running system (easily done with patch-o-matic and kernel modules). My already-user-defined-chains will continue to work as before - until the next fresh run of my iptables init scripts / iptables-restore.
With my proposal, that shooting would not happen - it's just that the newly installed module won't be accessible without using the special "+TARGET" syntax I invented.
regards
Patrick
Quoted 7 lines · Patrick Schaaf
Quoted 2 lines
What about simply returning by an error code if there is an attempt to create a chain wich clashes with a target name?
Wasn't there recent discussion about "how do I find all available target names"? But I agree in principle, that would be the least intrusive shorttime "rationalization" of the now-very-order-dependant behaviour.
Here is the patch according to my proposal:
iptables.c renamed from iptables.c.orig +4 -3
@@ -1159,9 +1159,6 @@u_int8_t flags;char buf[BUFSIZ ]; -/* User creates a chain called "REJECT": this overrides the -`REJECT' target module. Keep feeding them rope until the -revolution... Bwahahahahah */ if (!iptc_is_chain (targname, handle)) target =find_target (targname,TRY_LOAD );else
@@ -1760,6 +1757,10 @@exit_error (PARAMETER_PROBLEM ,"chain name not allowed to start " "with `-'\n" ); +if (find_target (optarg,TRY_LOAD )) +exit_error (PARAMETER_PROBLEM , +"chain name may not clash " +"with target name\n" );add_command (&command,CMD_NEW_CHAIN ,CMD_NONE , invert); chain = optarg;
ip6tables.c renamed from ip6tables.c.orig +8 -3
@@ -1161,9 +1161,6 @@u_int8_t flags;char buf[BUFSIZ ]; -/* User creates a chain called "REJECT": this overrides the -`REJECT' target module. Keep feeding them rope until the -revolution... Bwahahahahah */ if (!ip6tc_is_chain (targname, handle)) target =find_target (targname,TRY_LOAD );else
@@ -1797,6 +1794,14 @@break ;case 'N' : +if (optarg && *optarg =='-' ) +exit_error (PARAMETER_PROBLEM , +"chain name not allowed to start " +"with `-'\n" ); +if (find_target (optarg,TRY_LOAD )) +exit_error (PARAMETER_PROBLEM , +"chain name may not clash " +"with target name\n" );add_command (&command,CMD_NEW_CHAIN ,CMD_NONE , invert); chain = optarg;
I believe this is the simplest approach - all other solutions require changes both in the user interface and the kernel structures.
Regards,
Jozsef
-
E-mail : [email protected], [email protected]
WWW-Home: http://www.kfki.hu/~kadlec
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
Quoted 2 lines · Patrick Schaaf
Wasn't there recent discussion about "how do I find all available target names"?
yes. Unfortunately nobody implemented what the discussion was about.
Quoted 2 lines
regards
Patrick
Signature · 5 lines
Live long and prosper - Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M+ V-- PS++ PE-- Y++ PGP++ t+ 5-- !X !R tv-- b+++ !DI !D G+ e* h--- r++ y+(*)
Quoted 6 lines · Jozsef Kadlecsik
Quoted 2 lines · Patrick Schaaf
Quoted 2 lines
What about simply returning by an error code if there is an attempt to create a chain wich clashes with a target name?
Here is the patch according to my proposal:
I have committed the patch in cvs.
Regards,
Jozsef
-
E-mail : [email protected], [email protected]
WWW-Home: http://www.kfki.hu/~kadlec
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary