lkml.org 
[lkml]   [2016]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 234/346] dm crypt: fix free of bad values after tfm allocation failure
    3.16.39-rc1 review patch.  If anyone has any objections, please let me know.

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

    From: Eric Biggers <ebiggers@google.com>

    commit 5d0be84ec0cacfc7a6d6ea548afdd07d481324cd upstream.

    If crypt_alloc_tfms() had to allocate multiple tfms and it failed before
    the last allocation, then it would call crypt_free_tfms() and could free
    pointers from uninitialized memory -- due to the crypt_free_tfms() check
    for non-zero cc->tfms[i]. Fix by allocating zeroed memory.

    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    drivers/md/dm-crypt.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/drivers/md/dm-crypt.c
    +++ b/drivers/md/dm-crypt.c
    @@ -1400,7 +1400,7 @@ static int crypt_alloc_tfms(struct crypt
    unsigned i;
    int err;

    - cc->tfms = kmalloc(cc->tfms_count * sizeof(struct crypto_ablkcipher *),
    + cc->tfms = kzalloc(cc->tfms_count * sizeof(struct crypto_ablkcipher *),
    GFP_KERNEL);
    if (!cc->tfms)
    return -ENOMEM;
    \
     
     \ /
      Last update: 2016-11-14 04:36    [W:4.045 / U:0.048 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site