Bug 235401

Summary: rm can segfault when racing another rm to delete a directory
Product: [Fedora] Fedora Reporter: David Shaw <dshaw>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6CC: meyering
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 5.97-12.5.fc6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-04-19 04:25:06 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 207681    
Attachments:
Description Flags
Patch to fix rm segfault none

Description David Shaw 2007-04-05 11:54:17 EDT
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):

coreutils-5.97-12.3.fc6

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)
  
Actual results:

One of the 'rm's will segfault.

Expected results:

Neither of the 'rm's would segfault.

Additional info:

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.

Patch attached.
Comment 1 David Shaw 2007-04-05 11:54:17 EDT
Created attachment 151772 [details]
Patch to fix rm segfault
Comment 2 Tim Waugh 2007-04-11 07:33:16 EDT
Thanks for the patch.
Comment 3 Fedora Update System 2007-04-18 18:37:45 EDT
Fixed in update: coreutils-5.97-12.5.fc6