Red Hat Bugzilla – Bug 228706
[RHEL4] [patch] cid-11 Avoid static buffer overruns in debugfs
Last modified: 2015-01-07 19:15:37 EST
Description of problem:
list_dir_proc uses a buffer allocated on the stack for the file name. This is
sized as EXT2_NAME_LEN and the length of the string is checked:
thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
(dirent->name_len & 0xFF) : EXT2_NAME_LEN;
Finally, we copy the string and set the name[thislen] to '\0'.
In the case that thislen == EXT2_NAME_LEN, the '\0' char is stored outside the
bounds of the name array.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
This isn't easy to reproduce as the stack layout (on i386 anyway) means that an
overflow of 1 byte does not overwrite any other datastructures.
1. Create a filename with length equal to EXT2_NAME_LEN
2. Open the filesystem with debugfs running under gdb
3. Set a breakpoint on list_dir_proc
3. List directory contents
4. Continue until the long filename appears in *dirent
5. Store a known character in the byte following the end of name
6. Step through the routine until after the "name[thislen] = '\0';"
The byte after the end of name is overwritten.
The assignment stays within the array bounds.
Created attachment 148062 [details]
Patch correcting array usage in ls_dir_proc
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release. Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products. This request is not yet committed for inclusion in an Update
upstream commits for cid-11, cid-12, cid-13 at
Applying a DEV_ACK for Eric Sandeen <firstname.lastname@example.org>. This bug
was found by coverity and has a patch available.
In cvs as of e2fsprogs-1.35-12.7.el4
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.