From owner-svn-src-head@FreeBSD.ORG Tue Nov 10 11:50:37 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF6B3106566C; Tue, 10 Nov 2009 11:50:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BEDB18FC1D; Tue, 10 Nov 2009 11:50:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAABobe7058141; Tue, 10 Nov 2009 11:50:37 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAABobP6058139; Tue, 10 Nov 2009 11:50:37 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200911101150.nAABobP6058139@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 10 Nov 2009 11:50:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199137 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2009 11:50:37 -0000 Author: kib Date: Tue Nov 10 11:50:37 2009 New Revision: 199137 URL: http://svn.freebsd.org/changeset/base/199137 Log: When rename("a", "b/.") is performed, target namei() call returns dvp == vp. Rename syscall does not check for the case, and at least ufs_rename() cannot deal with it. POSIX explicitely requires that both rename(2) and rmdir(2) return EINVAL when any of the pathes end in "/.". Detect the slashdot lookup for RENAME or REMOVE in lookup(), and return EINVAL. Reported by: Jim Meyering Tested by: simon, pho MFC after: 1 week Modified: head/sys/kern/vfs_lookup.c Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Tue Nov 10 11:46:53 2009 (r199136) +++ head/sys/kern/vfs_lookup.c Tue Nov 10 11:50:37 2009 (r199137) @@ -552,6 +552,12 @@ dirloop: else cnp->cn_flags &= ~ISLASTCN; + if ((cnp->cn_flags & ISLASTCN) != 0 && + cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.' && + (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) { + error = EINVAL; + goto bad; + } /* * Check for degenerate name (e.g. / or "")