Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 228706 - [RHEL4] [patch] cid-11 Avoid static buffer overruns in debugfs
Summary: [RHEL4] [patch] cid-11 Avoid static buffer overruns in debugfs
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: e2fsprogs
Version: 4.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Eric Sandeen
QA Contact: Jay Turner
URL:
Whiteboard:
Depends On:
Blocks: 239341
TreeView+ depends on / blocked
 
Reported: 2007-02-14 16:18 UTC by Bryn M. Reeves
Modified: 2018-10-19 22:59 UTC (History)
2 users (show)

Fixed In Version: RHBA-2007-0758
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-11-15 16:01:32 UTC


Attachments (Terms of Use)
Patch correcting array usage in ls_dir_proc (deleted)
2007-02-14 16:18 UTC, Bryn M. Reeves
no flags Details | Diff


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2007:0758 normal SHIPPED_LIVE e2fsprogs bug fix update 2007-11-14 17:06:52 UTC

Description Bryn M. Reeves 2007-02-14 16:18:01 UTC
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:

        char                    name[EXT2_NAME_LEN];
        ...
        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):
e2fsprogs-1.35-12.4.EL4

How reproducible:
100%

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';"

Actual results:
The byte after the end of name[] is overwritten.

Expected results:
The assignment stays within the array bounds.

Comment 1 Bryn M. Reeves 2007-02-14 16:18:01 UTC
Created attachment 148062 [details]
Patch correcting array usage in ls_dir_proc

Comment 5 RHEL Product and Program Management 2007-05-09 07:43:26 UTC
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
release.

Comment 6 Eric Sandeen 2007-05-29 20:10:34 UTC
upstream commits for cid-11, cid-12, cid-13 at
http://thunk.org/hg/e2fsprogs/?rev/4c321a4ecbd6

Comment 7 Benjamin Kahn 2007-06-08 14:37:16 UTC
Applying a DEV_ACK for Eric Sandeen <sandeen@redhat.com>.  This bug
    was found by coverity and has a patch available.

Comment 10 Eric Sandeen 2007-07-02 20:43:17 UTC
In cvs as of e2fsprogs-1.35-12.7.el4

Comment 14 errata-xmlrpc 2007-11-15 16:01:32 UTC
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.

http://rhn.redhat.com/errata/RHBA-2007-0758.html



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