Red Hat Bugzilla – Bug 235401
rm can segfault when racing another rm to delete a directory
Last modified: 2007-11-30 17:12:01 EST
Description of problem:
When deleting a deep directory tree from two different instances of "rm -rf"
simultaneously, one of the instances may segfault.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Create a deep directory tree (I used 10 levels deep)
2. From two different command lines, rm -rf the parent directory of the tree
3. Repeat (it requires tricky timing so may not always happen)
One of the 'rm's will segfault.
Neither of the 'rm's would segfault.
The problem seems to be in remove.c:remove_cwd_entries(), where opendir is
called on ".". If this fails for reason of ENOENT, the function calls readdir
on the NULL dirp.
Created attachment 151772 [details]
Patch to fix rm segfault
Thanks for the patch.
Fixed in update: coreutils-5.97-12.5.fc6