Message ID | 20180103214859.3842-1-gmazyland@gmail.com (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Mike Snitzer |
Headers | show
Return-Path: <dm-devel-bounces@redhat.com> 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 DFFAB6034B for <patchwork-dm-devel@patchwork.kernel.org>; Wed, 3 Jan 2018 21:51:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFBE329373 for <patchwork-dm-devel@patchwork.kernel.org>; Wed, 3 Jan 2018 21:51:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4B3529376; Wed, 3 Jan 2018 21:51:21 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 98AAA29373 for <patchwork-dm-devel@patchwork.kernel.org>; Wed, 3 Jan 2018 21:51:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F8DC81240; Wed, 3 Jan 2018 21:51:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D87F660D5F; Wed, 3 Jan 2018 21:51:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 101C74BB79; Wed, 3 Jan 2018 21:51:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w03LnwBg008041 for <dm-devel@listman.util.phx.redhat.com>; Wed, 3 Jan 2018 16:49:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id BFBD060A98; Wed, 3 Jan 2018 21:49:58 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA2DD70527 for <dm-devel@redhat.com>; Wed, 3 Jan 2018 21:49:56 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AEF281226 for <dm-devel@redhat.com>; Wed, 3 Jan 2018 21:49:55 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id i6so686288wrf.3 for <dm-devel@redhat.com>; Wed, 03 Jan 2018 13:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=p0YvCPBIjv//Gn+bWDr4IwYcKyaE7Qzrl/vDiDsUfZE=; b=Z6NvcUTP8o+r30/d4fbF0CB9XEgqkbrHZWUJvZ48YuayFPY6ZVgdMPAHk1r/zbXisv 8nOsE+H771FbYqvc5eSTpnflCwsFtVDR8OUis0XrYSs0VnVNSa5TZi4a2wy4Qwt2Vx0M sm/RNzzdCc+Cfj0eqlp1va4R+jm71Y32Og4Xnk7dejge0hrpAVhTmUPZnBzlVmo3OZhB ZFF0LmZSuOkkz+1vED5vBGnfra7wTU4ZHYmlPW7YZYA4Vt3pftLWz7m8nwJr57ovA4zH r14cGGKzDpynSm4btIk8uMbyaLlf9IzTa9xqpKtpIy721dafkYjbaAYOUP6gTNzh/D6Q vLFw== 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=p0YvCPBIjv//Gn+bWDr4IwYcKyaE7Qzrl/vDiDsUfZE=; b=rioHd7i/aBTTUVbVsuwgV7+Zak6jJqayZ/hFXcJXiR1NSqEbvUkKIq4SMdLzkMlssQ 0km8d050wqzWb6BaVqn16mVWTaTGD7oBWMGApnk3l3BWPak/BaW4ibZTmDwid45ZgK5d MYteM1pi/Jiy3nTlbpqj5JELQ9WZXgL4qh63vNsS66YZLtYs+lKgNp7MD7RzSKNKNd6q a428RSF8w82HNx6m4stFBmjZhV94I9N4psiIrp0sdUK6FnN9TMmtlJXR1WMsJEqBuAYy YUs6xwcJlF+erfDn7vYS1DSDOboZTnUjzsJ5bx/OwBKLMpjgZTGXKVCc+u9Rw9xTGLWU 4QQw== X-Gm-Message-State: AKGB3mKRr1Ql0eWjgRcrEXTLkKMevZ9Jt+W64Bjnm5djCIN3UXzRZTRs h/b16p9WgItuLJuLgjuadQ9zxw== X-Google-Smtp-Source: ACJfBovTOKmhioyg3gIrS0WxNp65oHC0qHkx0Ic4DRwqB483PXYAX0sx+w11Pw8HpQoRbtu3l/aXZg== X-Received: by 10.223.198.137 with SMTP id j9mr2801819wrg.57.1515016193852; Wed, 03 Jan 2018 13:49:53 -0800 (PST) Received: from merlot.mazyland.net (dynamic-2a00-1028-96c1-4f6a-740e-137c-bba9-27a9.ipv6.broadband.iol.cz. [2a00:1028:96c1:4f6a:740e:137c:bba9:27a9]) by smtp.googlemail.com with ESMTPSA id f42sm1870499wrf.46.2018.01.03.13.49.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 13:49:53 -0800 (PST) From: Milan Broz <gmazyland@gmail.com> To: dm-devel@redhat.com Date: Wed, 3 Jan 2018 22:48:59 +0100 Message-Id: <20180103214859.3842-1-gmazyland@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 03 Jan 2018 21:49:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 03 Jan 2018 21:49:55 +0000 (UTC) for IP:'209.85.128.196' DOMAIN:'mail-wr0-f196.google.com' HELO:'mail-wr0-f196.google.com' FROM:'gmazyland@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.196 mail-wr0-f196.google.com 209.85.128.196 mail-wr0-f196.google.com <gmazyland@gmail.com> X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: Milan Broz <gmazyland@gmail.com> Subject: [dm-devel] [PATCH] dm-crypt: Add missing check for auth key size X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development <dm-devel.redhat.com> List-Unsubscribe: <https://www.redhat.com/mailman/options/dm-devel>, <mailto:dm-devel-request@redhat.com?subject=unsubscribe> List-Archive: <https://www.redhat.com/archives/dm-devel> List-Post: <mailto:dm-devel@redhat.com> List-Help: <mailto:dm-devel-request@redhat.com?subject=help> List-Subscribe: <https://www.redhat.com/mailman/listinfo/dm-devel>, <mailto:dm-devel-request@redhat.com?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 03 Jan 2018 21:51:19 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 9fc12f556534..4cc3809b2a3a 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1954,10 +1954,15 @@ static int crypt_setkey(struct crypt_config *cc) /* Ignore extra keys (which are used for IV etc) */ subkey_size = crypt_subkey_size(cc); - if (crypt_integrity_hmac(cc)) + if (crypt_integrity_hmac(cc)) { + if (subkey_size < cc->key_mac_size) + return -EINVAL; + crypt_copy_authenckey(cc->authenc_key, cc->key, subkey_size - cc->key_mac_size, cc->key_mac_size); + } + for (i = 0; i < cc->tfms_count; i++) { if (crypt_integrity_hmac(cc)) r = crypto_aead_setkey(cc->cipher_tfm.tfms_aead[i],
If dm-crypt uses authenticated mode with separate MAC, there are two concatenated part of the key structure - key(s) for encryption and authentication key. This patch adds a missing check for authenticated key length. If this key length is smaller than actually provided key, dm-crypt now properly fails instead of crashing. Reported-by: Salah Coronya <salahx@yahoo.com> Signed-off-by: Milan Broz <gmazyland@gmail.com> --- drivers/md/dm-crypt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)