From owner-freebsd-ipfw Tue Aug 20 11:37:49 2002 Delivered-To: freebsd-ipfw@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 92B3737B400 for ; Tue, 20 Aug 2002 11:37:45 -0700 (PDT) Received: from mailhost.iprg.nokia.com (mailhost.iprg.nokia.com [205.226.5.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id A1AB843E6E for ; Tue, 20 Aug 2002 11:37:44 -0700 (PDT) (envelope-from jre@iprg.nokia.com) Received: from darkstar.iprg.nokia.com (darkstar.iprg.nokia.com [205.226.5.69]) by mailhost.iprg.nokia.com (8.9.3/8.9.3-GLGS) with ESMTP id LAA08919; Tue, 20 Aug 2002 11:37:42 -0700 (PDT) Received: (from root@localhost) by darkstar.iprg.nokia.com (8.11.0/8.11.0-DARKSTAR) id g7KIbfH02108; Tue, 20 Aug 2002 11:37:41 -0700 X-mProtect: <200208201837> Nokia Silicon Valley Messaging Protection Received: from UNKNOWN (205.226.1.150, claiming to be "iprg.nokia.com") by darkstar.iprg.nokia.com smtpdc1iL8E; Tue, 20 Aug 2002 11:37:39 PDT Message-ID: <3D628C73.D5C85248@iprg.nokia.com> Date: Tue, 20 Aug 2002 11:37:39 -0700 From: Joe Eykholt Organization: Nokia IPRG X-Mailer: Mozilla 4.7 [en] (X11; I; FreeBSD 3.4-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Luigi Rizzo Cc: ipfw@FreeBSD.ORG Subject: Re: ambiguity of filter expressions (tcpdump and ipfw2) References: <20020820054206.A45915@iguana.icir.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-ipfw@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG How about giving a syntax error if TCP or UDP (or some other (future) protocol where a port number IS applicable) isn't specified? That'd remove the ambiguity and alert any existing users to any problem in their rules. I'm not on the ipfw alias, and you don't need to reply to this suggestion. Joe Luigi Rizzo wrote: > > [Bcc to -net, but please keep the discussion on -ipfw] > > Hi, > we have the following issue (both in tcpdump and ipfw2): > > when you specify a match pattern that is not applicable to the > packet being processed (e.g. "src-port 80" on an ICMP packet), > the match will simply fail and the packet will not be selected. > > However, when you put in a "not" operator (as in "not src-port 80") > there are really two ways to implement the operation: > > 1. the basic match fails, so its negation will succeed. > This is the way tcpdump operates (try a "tcpdump not port 80" > and see how it matches all sort of non-tcp traffic), and also > ipfw2 does the same thing for consistency with tcpdump > (that is the official excuse -- in reality, i did not think of > the issue in the first place, maybe the same happened to > the tcpdump/libpcap authors). > > 2. The match operator is "not applicable" so both the > direct form and the negation will fail. > > Now, using the first approach in a firewall might be somewhat dangerous, > in the sense that, yes, the rule does exactly what you write, but > that might not be what you really want. E.g. consider > > ipfw add allow not src-port 80 > > which could be meant to pass all tcp traffic not coming from a web > server -- however, this rule would also leak all non-tcp and non-udp > packets. The correct way to express the rule is of course to > to include a "proto tcp" match pattern, but sometimes this can escape. > The second approach would prevent such mistakes, though it might > be non-obvious to people used to tcpdump syntax (although, i suspect > "not" operators are not widely used there either). > > So, what do we do ? Implementing the second behavior requires rather > trivial changes in the kernel, and no changes in the kernel-user > interface or in the userland programs. ipfw2 syntax is not yet > widely used so changing between one mode and the other would not > give too much trouble to people. It might even be possible to provide > a sysctl variable to choose between the two behaviours, though i'd > rather not do that because it has a little bit of impact on run-time > performance, and also because having yet another tunable increases > confusion. > > I'd be inclined to leave things as they are, surely remark the issue > in the manpage, and maybe make ipfw2 print out a "Warning" message > about the use of a potentially unsafe match pattern, same as the > compiler does when you use a "gets". > > Opinions anyone ? > > cheers > luigi > ----------------------------------+----------------------------------------- > Luigi RIZZO, luigi@iet.unipi.it . ICSI (on leave from Univ. di Pisa) > http://www.iet.unipi.it/~luigi/ . 1947 Center St, Berkeley CA 94704 > Phone: (510) 666 2927 > ----------------------------------+----------------------------------------- > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-net" in the body of the message -- Joe Eykholt jre@iprg.nokia.com Nokia Internet Communications 313 Fairchild Drive, Mountain View, CA 94043 http://www.nokia.com/securitysolutions/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ipfw" in the body of the message