From owner-freebsd-bugs@FreeBSD.ORG Sat May 15 17:20:21 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BDD7816A4CE for ; Sat, 15 May 2004 17:20:21 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E28243D54 for ; Sat, 15 May 2004 17:20:20 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i4G0KJBn021676 for ; Sat, 15 May 2004 17:20:20 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i4G0KHhu021670; Sat, 15 May 2004 17:20:17 -0700 (PDT) (envelope-from gnats) Resent-Date: Sat, 15 May 2004 17:20:17 -0700 (PDT) Resent-Message-Id: <200405160020.i4G0KHhu021670@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dmitry Kazarov Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4336916A4CE for ; Sat, 15 May 2004 17:11:54 -0700 (PDT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id BDDF843D1F for ; Sat, 15 May 2004 17:11:53 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i4G0Br3S050521 for ; Sat, 15 May 2004 17:11:53 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.11/8.12.11/Submit) id i4G0Brlk050520; Sat, 15 May 2004 17:11:53 -0700 (PDT) (envelope-from nobody) Message-Id: <200405160011.i4G0Brlk050520@www.freebsd.org> Date: Sat, 15 May 2004 17:11:53 -0700 (PDT) From: Dmitry Kazarov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: bin/66677: mv incorrectly copies somedir/.. to ./.. when it crossing devices. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2004 00:20:22 -0000 >Number: 66677 >Category: bin >Synopsis: mv incorrectly copies somedir/.. to ./.. when it crossing devices. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat May 15 17:20:14 PDT 2004 >Closed-Date: >Last-Modified: >Originator: Dmitry Kazarov >Release: FreeBSD 4.9 STABLE >Organization: MIDIKON >Environment: FreeBSD serv.willcom.ru 4.10-PRERELEASE FreeBSD 4.10-PRERELEASE #0: Thu May 6 12:04:39 MSD 2004 root@serv.willcom.ru:/var/obj/usr/src/sys/SERV i386 >Description: When moving dirs across devices it does not check for moving some/dir/.. over ./.. dir (or more generally it allows moving a dir over contents of existing dir). rename(2) disallows moving some/dir/.. over ./.. (but it works withing a filesystem). >How-To-Repeat: [697]$ cd [698]$ df . /var/tmp Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/vinum/home 3949805 2850542 783279 78% /home /dev/vinum/var 9290542 3212148 5335152 38% /var [699]$ mkdir -p /var/tmp/1/1 [700]$ touch /var/tmp/1/11 /var/tmp/1/12; [701]$ mkdir -p 2/2; cd 2/2 [702]$ ls [703]$ ls .. 2 [704]$ mv /var/tmp/1/1/.. . mv: "." and ".." may not be removed mv: /bin/rm: terminated with 1 (non-zero) status: Cross-device link [705]$ ls .. 1 11 12 2 BUT [710]$ cd [711]$ mkdir -p 1/1; touch 1/11 1/12 [712]$ mkdir -p 2/2 [713]$ cd 2/2 [714]$ mv ../../1/1/.. . mv: rename ../../1/1/.. to ./..: Invalid argument >Fix: --- mv.c.orig Sun May 16 04:04:29 2004 +++ mv.c Sun May 16 04:11:04 2004 @@ -145,6 +145,9 @@ if ((baselen + (len = strlen(p))) >= PATH_MAX) { warnx("%s: destination pathname too long", *argv); rval = 1; + } else if( strcmp("..",p) == 0 ) { + warnx("moving '..' is not allowed"); + rval = 1; } else { memmove(endp, p, (size_t)len + 1); if (do_move(*argv, path)) >Release-Note: >Audit-Trail: >Unformatted: