Bug 620300 - (CVE-2010-2798) CVE-2010-2798 kernel: gfs2: rename causes kernel panic
CVE-2010-2798 kernel: gfs2: rename causes kernel panic
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
high Severity high
: ---
: ---
Assigned To: Red Hat Product Security
reported=20100802,public=20100608,sou...
: Security
Depends On: 602025 614642 614913 614914 614916
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-01 23:03 EDT by Eugene Teo (Security Response)
Modified: 2015-07-31 08:10 EDT (History)
12 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-03-28 04:55:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Eugene Teo (Security Response) 2010-08-01 23:03:06 EDT
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-01 23:15:07 EDT
Statement:

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-01 23:23:49 EDT
Introduced in upstream commit 71b86f56 (v2.6.19-rc1), and fixed in commit 728a756b.

http://git.kernel.org/linus/71b86f562b5eb6f94ea00bba060caa64d0137969
http://git.kernel.org/linus/728a756b8fcd22d80e2dbba8117a8a3aafd3f203
Comment 4 Eugene Teo (Security Response) 2010-08-20 02:15:56 EDT
Acknowledgements:

Red Hat would like to thank Grant Diffey of CenITex for reporting this issue.
Comment 5 errata-xmlrpc 2010-08-30 09:11:17 EDT
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 13:20:27 EDT
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 10:53:34 EDT
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

Note You need to log in before you can comment on or make changes to this bug.