Bug 620300 (CVE-2010-2798)

Summary: CVE-2010-2798 kernel: gfs2: rename causes kernel panic
Product: [Other] Security Response Reporter: Eugene Teo (Security Response) <eteo>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: arozansk, chen1537, davej, dhoward, jpirko, kmcmartin, lwang, plyons, pmatouse, rcvalle, tao, tcallawa
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-28 08:55:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 602025, 614642, 614913, 614914, 614916    
Bug Blocks:    

Description Eugene Teo (Security Response) 2010-08-02 03:03:06 UTC
Description of problem:
The problem was in the way the gfs2 directory code was trying to re-use sentinel directory entries.

In the failing case, gfs2's rename function was renaming a file to another name that had the same non-trivial length. The file being renamed happened to be the first directory entry on the leaf block.

First, the rename code (gfs2_rename in ops_inode.c) found the original directory entry and decided it could do its job by simply replacing the directory entry with another.  Therefore it determined correctly that no block allocations were needed.

Next, the rename code deleted the old directory entry prior to replacing it with the new name.  Therefore, the soon-to-be replaced directory entry was temporarily made into a directory entry "sentinel" or a place holder at the start of a leaf block.

Lastly, it went to re-add the replacement directory entry in that leaf block.  However, when gfs2_dirent_find_space was looking for space in the leaf block, it used the wrong value for the sentinel.  That threw off its calculations so later it decides it can't really re-use the sentinel and therefore must allocate a new leaf block.  But because it previously decided to re-use the directory entry, it didn't waste the time to grab a new block allocation for the inode.  Therefore, the inode's i_alloc pointer was still NULL and it crashes trying to reference it.

In the case of sentinel directory entries, the entire dirent is reused, not just the "free space" portion of it, and therefore the function gfs2_dirent_find_space should use the value 0 rather than GFS2_DIRENT_SIZE(0) for the actual dirent size.

Fixing this calculation enables the reproducer programs to work properly.

Comment 2 Eugene Teo (Security Response) 2010-08-02 03:15:07 UTC

This issue did not affect the version of Linux kernel as shipped with Red Hat
Enterprise Linux 3, 4 and Red Hat Enterprise MRG as they did not include
support for the GFS2 file system.

A future kernel update in Red Hat Enterprise Linux 5 will address this issue.

Comment 3 Eugene Teo (Security Response) 2010-08-02 03:23:49 UTC
Introduced in upstream commit 71b86f56 (v2.6.19-rc1), and fixed in commit 728a756b.


Comment 4 Eugene Teo (Security Response) 2010-08-20 06:15:56 UTC

Red Hat would like to thank Grant Diffey of CenITex for reporting this issue.

Comment 5 errata-xmlrpc 2010-08-30 13:11:17 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5.3.Z - Server Only

Via RHSA-2010:0660 https://rhn.redhat.com/errata/RHSA-2010-0660.html

Comment 6 errata-xmlrpc 2010-09-02 17:20:27 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5.4.Z - Server Only

Via RHSA-2010:0670 https://rhn.redhat.com/errata/RHSA-2010-0670.html

Comment 8 errata-xmlrpc 2010-09-29 14:53:34 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2010:0723 https://rhn.redhat.com/errata/RHSA-2010-0723.html