From patchwork Thu Sep 3 11:32:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 7116321 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1A7D0BEEC1 for ; Thu, 3 Sep 2015 11:32:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5015D207AF for ; Thu, 3 Sep 2015 11:32:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7156A20762 for ; Thu, 3 Sep 2015 11:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752287AbbICLcd (ORCPT ); Thu, 3 Sep 2015 07:32:33 -0400 Received: from mx2.parallels.com ([199.115.105.18]:55785 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751914AbbICLcc (ORCPT ); Thu, 3 Sep 2015 07:32:32 -0400 Received: from [199.115.105.250] (helo=mail.odin.com) by mx2.parallels.com with esmtps (TLSv1.2:AES256-SHA:256) (Exim 4.85) (envelope-from ) id 1ZXUbB-0005k5-Ql; Thu, 03 Sep 2015 06:30:41 -0700 Received: from localhost.sw.ru (10.30.25.228) by US-EXCH2.sw.swsoft.com (10.255.249.46) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Thu, 3 Sep 2015 04:32:24 -0700 From: Andrey Ryabinin To: Herbert Xu , "David S. Miller" , CC: Andrey Ryabinin , Subject: [PATCH] crypto/testmgr: don't copy from source IV too much Date: Thu, 3 Sep 2015 14:32:00 +0300 Message-ID: <1441279921-26838-1-git-send-email-aryabinin@odin.com> X-Mailer: git-send-email 2.4.6 MIME-Version: 1.0 X-ClientProxiedBy: US-EXCH2.sw.swsoft.com (10.255.249.46) To US-EXCH2.sw.swsoft.com (10.255.249.46) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While the destination buffer 'iv' is MAX_IVLEN size, the source 'template[i].iv' could be smaller. Thus copying it via memcpy() leads to invalid memory access. Use strlcpy() instead. Signed-off-by: Andrey Ryabinin --- crypto/testmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index d0a42bd..d85221c 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -974,7 +974,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, continue; if (template[i].iv) - memcpy(iv, template[i].iv, MAX_IVLEN); + strlcpy(iv, template[i].iv, MAX_IVLEN); else memset(iv, 0, MAX_IVLEN); @@ -1049,7 +1049,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, continue; if (template[i].iv) - memcpy(iv, template[i].iv, MAX_IVLEN); + strlcpy(iv, template[i].iv, MAX_IVLEN); else memset(iv, 0, MAX_IVLEN);