lkml.org 
[lkml]   [2015]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.2 072/152] udf: Check component length before reading it
    3.2.67-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Jan Kara <jack@suse.cz>

    commit e237ec37ec154564f8690c5bd1795339955eeef9 upstream.

    Check that length specified in a component of a symlink fits in the
    input buffer we are reading. Also properly ignore component length for
    component types that do not use it. Otherwise we read memory after end
    of buffer for corrupted udf image.

    Reported-by: Carl Henrik Lunde <chlunde@ping.uio.no>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    fs/udf/symlink.c | 9 +++++++--
    1 file changed, 7 insertions(+), 2 deletions(-)

    --- a/fs/udf/symlink.c
    +++ b/fs/udf/symlink.c
    @@ -42,14 +42,17 @@ static int udf_pc_to_char(struct super_b
    tolen--;
    while (elen < fromlen) {
    pc = (struct pathComponent *)(from + elen);
    + elen += sizeof(struct pathComponent);
    switch (pc->componentType) {
    case 1:
    /*
    * Symlink points to some place which should be agreed
    * upon between originator and receiver of the media. Ignore.
    */
    - if (pc->lengthComponentIdent > 0)
    + if (pc->lengthComponentIdent > 0) {
    + elen += pc->lengthComponentIdent;
    break;
    + }
    /* Fall through */
    case 2:
    if (tolen == 0)
    @@ -74,6 +77,9 @@ static int udf_pc_to_char(struct super_b
    /* that would be . - just ignore */
    break;
    case 5:
    + elen += pc->lengthComponentIdent;
    + if (elen > fromlen)
    + return -EIO;
    comp_len = udf_get_filename(sb, pc->componentIdent,
    pc->lengthComponentIdent,
    p, tolen);
    @@ -85,7 +91,6 @@ static int udf_pc_to_char(struct super_b
    tolen--;
    break;
    }
    - elen += sizeof(struct pathComponent) + pc->lengthComponentIdent;
    }
    if (p > to + 1)
    p[-1] = '\0';


    \
     
     \ /
      Last update: 2015-02-17 03:21    [W:4.742 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site