[lkml]   [2009]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[patch 08/41] Fix memory corruption in console selection
    2.6.27-stable review patch.  If anyone has any objections, please let us know.


    From: Mikulas Patocka <>

    commit 878b8619f711280fd05845e21956434b5e588cc4 upstream.

    Fix an off-by-two memory error in console selection.

    The loop below goes from sel_start to sel_end (inclusive), so it writes
    one more character. This one more character was added to the allocated
    size (+1), but it was not multiplied by an UTF-8 multiplier.

    This patch fixes a memory corruption when UTF-8 console is used and the
    user selects a few characters, all of them 3-byte in UTF-8 (for example
    a frame line).

    When memory redzones are enabled, a redzone corruption is reported.
    When they are not enabled, trashing of random memory occurs.

    Signed-off-by: Mikulas Patocka <>
    Signed-off-by: Linus Torvalds <>
    Signed-off-by: Greg Kroah-Hartman <>

    drivers/char/selection.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/drivers/char/selection.c
    +++ b/drivers/char/selection.c
    @@ -268,7 +268,7 @@ int set_selection(const struct tiocl_sel

    /* Allocate a new buffer before freeing the old one ... */
    multiplier = use_unicode ? 3 : 1; /* chars can take up to 3 bytes */
    - bp = kmalloc((sel_end-sel_start)/2*multiplier+1, GFP_KERNEL);
    + bp = kmalloc(((sel_end-sel_start)/2+1)*multiplier, GFP_KERNEL);
    if (!bp) {
    printk(KERN_WARNING "selection: kmalloc() failed\n");

     \ /
      Last update: 2009-02-04 19:57    [W:0.021 / U:3.056 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site