From owner-freebsd-hackers@FreeBSD.ORG Fri May 29 16:58:09 2009 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E77E106566B for ; Fri, 29 May 2009 16:58:09 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 1E46F8FC15 for ; Fri, 29 May 2009 16:58:08 +0000 (UTC) (envelope-from des@des.no) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 488EA6D421; Fri, 29 May 2009 18:58:08 +0200 (CEST) Received: by ds4.des.no (Postfix, from userid 1001) id 26FF4844EE; Fri, 29 May 2009 18:58:08 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Bruce Evans References: <23727599.post@talk.nabble.com> <86prdvipwe.fsf@ds4.des.no> <20090527233110.E4243@delplex.bde.org> <86r5yaijef.fsf@ds4.des.no> <20090529210855.V1643@besplex.bde.org> <86vdnju9z1.fsf@ds4.des.no> Date: Fri, 29 May 2009 18:58:08 +0200 In-Reply-To: <86vdnju9z1.fsf@ds4.des.no> ("Dag-Erling =?utf-8?Q?Sm=C3=B8rg?= =?utf-8?Q?rav=22's?= message of "Fri, 29 May 2009 18:53:22 +0200") Message-ID: <86r5y7u9r3.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@FreeBSD.org, Jakub Lach Subject: Re: FYI Lighttpd 1.4.23 /kernel (trailing '/' on regular file symlink) vulnerability X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2009 16:58:09 -0000 How's this? Index: sys/kern/vfs_lookup.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/kern/vfs_lookup.c (revision 193028) +++ sys/kern/vfs_lookup.c (working copy) @@ -454,7 +454,6 @@ int docache; /* =3D=3D 0 do not cache last component */ int wantparent; /* 1 =3D> wantparent or lockparent flag */ int rdonly; /* lookup read-only flag bit */ - int trailing_slash; int error =3D 0; int dpunlocked =3D 0; /* dp has already been unlocked */ struct componentname *cnp =3D &ndp->ni_cnd; @@ -529,12 +528,10 @@ * trailing slashes to handle symlinks, existing non-directories * and non-existing files that won't be directories specially later. */ - trailing_slash =3D 0; while (*cp =3D=3D '/' && (cp[1] =3D=3D '/' || cp[1] =3D=3D '\0')) { cp++; ndp->ni_pathlen--; if (*cp =3D=3D '\0') { - trailing_slash =3D 1; *ndp->ni_next =3D '\0'; /* XXX for direnter() ... */ cnp->cn_flags |=3D TRAILINGSLASH; } @@ -711,7 +708,7 @@ error =3D EROFS; goto bad; } - if (*cp =3D=3D '\0' && trailing_slash && + if (*cp =3D=3D '\0' && (cnp->cn_flags & TRAILINGSLASH) && !(cnp->cn_flags & WILLBEDIR)) { error =3D ENOENT; goto bad; @@ -788,7 +785,7 @@ * Check for symbolic link */ if ((dp->v_type =3D=3D VLNK) && - ((cnp->cn_flags & FOLLOW) || trailing_slash || + ((cnp->cn_flags & FOLLOW) || (cnp->cn_flags & TRAILINGSLASH) || *ndp->ni_next =3D=3D '/')) { cnp->cn_flags |=3D ISSYMLINK; if (dp->v_iflag & VI_DOOMED) { BTW, what does the "XXX for direnter()" comment mean? DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no