rm(1) bug, possibly serious

Torfinn Ingolfsen torfinn.ingolfsen at broadpark.no
Tue Sep 25 09:36:37 PDT 2007


On Tue, 25 Sep 2007 17:12:50 +0200 (CEST)
Oliver Fromme <olli at lurza.secnetix.de> wrote:

> $ cd /tmp
> $ mkdir -p foo/var
> $ cd foo/bar
> $ rm -rf ../
> rm: ../: Invalid argument
> $ rm -rf ../
> $ 
> 
> Note that the command "rm -rf ../" was entered twice.
> The first time I got an error message (and exit code 1),
> the second time it apparently succeeded.  The very same
> command.

What happens if you issue a 'pwd' command after each 'rm -rf ../'?
We want to see the output.

IMHO, the only way the second rm command *should* succeed, is if it
invalidates the current working directory, thus releasing the last lock
on the directory.

Quick testing here:
tingo at kg-work$ mkdir -p foo/bar
tingo at kg-work$ cd foo/bar
tingo at kg-work$ ll
total 4
drwxr-xr-x  2 tingo  wheel  - 512 Sep 25 17:31 ./
drwxr-xr-x  3 tingo  wheel  - 512 Sep 25 17:31 ../
tingo at kg-work$ pwd
/tmp/foo/bar
tingo at kg-work$ rm -rf ../
rm: ../: Invalid argument
tingo at kg-work$ pwd
/tmp/foo/bar
tingo at kg-work$ rm -rf ../
tingo at kg-work$ pwd
/tmp/foo/bar
tingo at kg-work$ ls -al
total 0
tingo at kg-work$ ll
total 0
tingo at kg-work$ pwd
/tmp/foo/bar
tingo at kg-work$ ls -al ..
ls: ..: No such file or directory
tingo at kg-work$ ls -al /tmp/foo/bar
ls: /tmp/foo/bar: No such file or directory
tingo at kg-work$ ls -al /tmp/foo
total 8
drwxr-xr-x   2 tingo  wheel   512 Sep 25 17:32 .
drwxrwxrwt  35 root   wheel  5632 Sep 25 17:31 ..


Ok, I think it is a bug.
-- 
Regards,
Torfinn Ingolfsen



More information about the freebsd-stable mailing list