From patchwork Wed Jun 13 14:44:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ondrej Mosnacek X-Patchwork-Id: 10462363 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4CC7260348 for ; Wed, 13 Jun 2018 14:44:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F18C1FFDB for ; Wed, 13 Jun 2018 14:44:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33C6127CF9; Wed, 13 Jun 2018 14:44:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 275AF1FFDB for ; Wed, 13 Jun 2018 14:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935719AbeFMOoe (ORCPT ); Wed, 13 Jun 2018 10:44:34 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40197 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935659AbeFMOod (ORCPT ); Wed, 13 Jun 2018 10:44:33 -0400 Received: by mail-wm0-f66.google.com with SMTP id n5-v6so5902631wmc.5 for ; Wed, 13 Jun 2018 07:44:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xHG1cx1vUx0JXaqx3+K0iynmkMXVQrbVNZMGH+HJjc8=; b=f7DGiY+dkeodRuBW0WaXfV84lHHZjgKGqsNVKXpLM/d5EB1mTbXPgvvleOGaCkhMt0 l/WpOAuxJo/xSXWu+cgp86ouxhCl4o/PPpGK8J7dE9NzOCUpbL03d3kmP2Rm5qOscSAg FkSNOHKraCSeqsLXRMSeKgiv9+E4+B7IF8hBp53KbsTtAAHjqk//wnIjzfCYk0Ha4lZi GTKnk425ulIlY47Cjtfxkl2o8kX0t6Z516w9NbomNCdgMK7VKry+jxrIgzgz6xhuyNgp f7xbQqV4QvNGXkbAzmCywNYBxzNPGRj2FxCLfH4Gol1bYromY5pw+ssVK+99fpeTZ70E 2zbw== X-Gm-Message-State: APt69E3EtiGeDgzkyjh0J3fCitYw1ZyO3UEh8fBp8xBo1c3VQKKfAY9U bg/5ImcJZl4vaDBwgPLnClujY2dMBIc= X-Google-Smtp-Source: ADUXVKJakgmVx2hxthDl3G/jXxP722csjBoNqTubVK6b4EnY9Px+IBKNryCuPF1vCFkI27ckherFOw== X-Received: by 2002:a1c:5582:: with SMTP id j124-v6mr3863450wmb.153.1528901072176; Wed, 13 Jun 2018 07:44:32 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id t9-v6sm1894565wmh.41.2018.06.13.07.44.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 07:44:31 -0700 (PDT) From: Ondrej Mosnacek To: linux-crypto@vger.kernel.org Cc: Herbert Xu , Dmitry Vyukov , Milan Broz , Ondrej Mosnacek Subject: [PATCH] crypto: morus640 - Fix out-of-bounds access Date: Wed, 13 Jun 2018 16:44:17 +0200 Message-Id: <20180613144417.30225-1-omosnace@redhat.com> X-Mailer: git-send-email 2.17.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We must load the block from the temporary variable here, not directly from the input. Also add forgotten zeroing-out of the uninitialized part of the temporary block (as is done correctly in morus1280.c). Fixes: 396be41f16fd ("crypto: morus - Add generic MORUS AEAD implementations") Reported-by: syzbot+1fafa9c4cf42df33f716@syzkaller.appspotmail.com Reported-by: syzbot+d82643ba80bf6937cd44@syzkaller.appspotmail.com Signed-off-by: Ondrej Mosnacek --- crypto/morus640.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/morus640.c b/crypto/morus640.c index 9fbcde307daf..5eede3749e64 100644 --- a/crypto/morus640.c +++ b/crypto/morus640.c @@ -274,8 +274,9 @@ static void crypto_morus640_decrypt_chunk(struct morus640_state *state, u8 *dst, union morus640_block_in tail; memcpy(tail.bytes, src, size); + memset(tail.bytes + size, 0, MORUS640_BLOCK_SIZE - size); - crypto_morus640_load_a(&m, src); + crypto_morus640_load_a(&m, tail.bytes); crypto_morus640_core(state, &m); crypto_morus640_store_a(tail.bytes, &m); memset(tail.bytes + size, 0, MORUS640_BLOCK_SIZE - size);