From patchwork Mon Aug 19 14:17:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171636 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3046867ily; Mon, 19 Aug 2019 07:18:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhtNGBFYXJS542+DHRqMMHBzd0co4ZAlE3JPlbRBH76SIhRG+Z4SekAopyDpjUP+lej3Mz X-Received: by 2002:a63:d34c:: with SMTP id u12mr20427787pgi.114.1566224299559; Mon, 19 Aug 2019 07:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566224299; cv=none; d=google.com; s=arc-20160816; b=HN0K+CogwaNsmzG+enYPX59sJkDpfosKcjRcWeSQqwvlZgt+oUai9BQXddWiXDBQLh b46Undc3kUmrQQLgHvZ7447XUyTso4YAlhr4BGLiqEk3hyAzfyZaPI7JhSjHDsZWu9xY 2MBrZO6Kq+oT/qI/6XrqjX0GtglTnsGZUD506Yr2HkYlFLXwLUkkCwUaiTPSyjQDXt/3 AwVYvGkPtOW8KF/be6EX7m3UWWy9xou0+q0NhlcMoqlLDs+FssSqCX+JjhLYJlOuZASo 9BoMua1z6tFLuRRkdd54V9QjT1+evrurYUsmfDiDhLMlcGY8+SgRMtCB/sjGxTsm7UKa unGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=TmnznT0hptKHz4ZiqoCAURLmBmT8IKpbKUZOSS9EXts=; b=HSHmEz0TBA5hfaQZOcFwQWOduJLRNe2BHh8v1/vZF7UsyZ0KotxMDFEINgEzchxFjY sWq7L0X/CTXJOC0kCpPVZPmeUXby2oNiG/bh+F3B10cZrHfj2at3+7cvJLWX9VWuwy92 JfCSvUH8NIZTucQ+sFVaXMv6+6ySEQhj1881DzKeAOTuZmWTEwEUq02fhCPXA83DWeAX bvf3VSuTwdI8RTM+GL434tgMTy8+JctivQPeOWMYnqKUSI18tBqw0OL/JT/5Ep+R/Apa S52vwztJuWFDTl7qKIRSEFINiNpCI9NGfo2jXKDWWsWdyNijDs5+e+6Ru3ncOJvyz4k2 cxMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k+j7hV4F; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13si9983973pgp.133.2019.08.19.07.18.19; Mon, 19 Aug 2019 07:18:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k+j7hV4F; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726893AbfHSOSS (ORCPT + 3 others); Mon, 19 Aug 2019 10:18:18 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:50587 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726879AbfHSOSS (ORCPT ); Mon, 19 Aug 2019 10:18:18 -0400 Received: by mail-wm1-f68.google.com with SMTP id v15so1792316wml.0 for ; Mon, 19 Aug 2019 07:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TmnznT0hptKHz4ZiqoCAURLmBmT8IKpbKUZOSS9EXts=; b=k+j7hV4F10gOP4bMJkudPvXJal9wc7ostfNWhX69nckFbpPExiJV7p4QjTKfjoFZQq pInlW7RUfZyQMvHKjQBFuxcEWIOBMoZjrddkAw5Z49QLLWyIyv4g9jWwqj+GsH8pVfDb zJK8mvK7ncMm/PNWGQmVvM4Py1h/LjalRpAsU3UZVXU2SqAACHlHumAFDpBMbrd7/K0K iXV99u5zT9fRxJuEl45V7tEB68zI+Ayb6xzlT/CXN6BxQvactcGb3N0AVQse7Lg0DWvG wn5U0pfe7/gud+eK//rnDgb/9kg1H9TMCNrVDArXHAOXbGj20DOsFpZ+3ZcpCIYf0UD5 EN6g== 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:in-reply-to :references; bh=TmnznT0hptKHz4ZiqoCAURLmBmT8IKpbKUZOSS9EXts=; b=SpyMSlcZdF6cHOaLaonJrOoTlMLssbJ6vP7oBexHoNmxAf3iU0ocHuoksPcCywmVFi MCD/tJW7YRS6WH648UvezxNexmomc/DZKizu7DgRKSrhaWP0JxdK28Ze5jUjLBgWPIf2 +ajZSwCsz0GspDIdI0w2kEDN+JV9KjeRtadfDG+XDkgxyH2ljOnWiF7WPy+ouBJ6qCG+ FFyO/JMfD87VdLcaEiPgNx9YgDGhoii3wr3SS1q3XzOPRmTqDyvH3kDAgSO8Dm57PWgs zeBi+m3khOueRtcnEAaTz/goSSsjazWB8uRTTcf6hqZIk3leOs8cvflteN/KtMd38oav uYvA== X-Gm-Message-State: APjAAAU3IbSb/Up+goJGgCNDZtWs3Hsz/PZeSN99OTX0vhEs84ueShdO eAmYQqUXA1cQAWWGk7Dr2qNPhkjQHe9RIQ== X-Received: by 2002:a1c:f604:: with SMTP id w4mr4087230wmc.169.1566224296584; Mon, 19 Aug 2019 07:18:16 -0700 (PDT) Received: from localhost.localdomain (11.172.185.81.rev.sfr.net. [81.185.172.11]) by smtp.gmail.com with ESMTPSA id b26sm12693352wmj.14.2019.08.19.07.18.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Aug 2019 07:18:15 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , Herbert Xu , Eric Biggers , dm-devel@redhat.com, linux-fscrypt@vger.kernel.org, Gilad Ben-Yossef , Milan Broz Subject: [PATCH v13 6/6] md: dm-crypt: omit parsing of the encapsulated cipher Date: Mon, 19 Aug 2019 17:17:38 +0300 Message-Id: <20190819141738.1231-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819141738.1231-1-ard.biesheuvel@linaro.org> References: <20190819141738.1231-1-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Only the ESSIV IV generation mode used to use cc->cipher so it could instantiate the bare cipher used to encrypt the IV. However, this is now taken care of by the ESSIV template, and so no users of cc->cipher remain. So remove it altogether. Signed-off-by: Ard Biesheuvel --- drivers/md/dm-crypt.c | 58 -------------------- 1 file changed, 58 deletions(-) -- 2.17.1 Acked-by: Mike Snitzer diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index e3e6e111edfc..0dd1fb027ac0 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -147,7 +147,6 @@ struct crypt_config { struct task_struct *write_thread; struct rb_root write_tree; - char *cipher; char *cipher_string; char *cipher_auth; char *key_string; @@ -2166,7 +2165,6 @@ static void crypt_dtr(struct dm_target *ti) if (cc->dev) dm_put_device(ti, cc->dev); - kzfree(cc->cipher); kzfree(cc->cipher_string); kzfree(cc->key_string); kzfree(cc->cipher_auth); @@ -2247,52 +2245,6 @@ static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode) return 0; } -/* - * Workaround to parse cipher algorithm from crypto API spec. - * The cc->cipher is currently used only in ESSIV. - * This should be probably done by crypto-api calls (once available...) - */ -static int crypt_ctr_blkdev_cipher(struct crypt_config *cc) -{ - const char *alg_name = NULL; - char *start, *end; - - if (crypt_integrity_aead(cc)) { - alg_name = crypto_tfm_alg_name(crypto_aead_tfm(any_tfm_aead(cc))); - if (!alg_name) - return -EINVAL; - if (crypt_integrity_hmac(cc)) { - alg_name = strchr(alg_name, ','); - if (!alg_name) - return -EINVAL; - } - alg_name++; - } else { - alg_name = crypto_tfm_alg_name(crypto_skcipher_tfm(any_tfm(cc))); - if (!alg_name) - return -EINVAL; - } - - start = strchr(alg_name, '('); - end = strchr(alg_name, ')'); - - if (!start && !end) { - cc->cipher = kstrdup(alg_name, GFP_KERNEL); - return cc->cipher ? 0 : -ENOMEM; - } - - if (!start || !end || ++start >= end) - return -EINVAL; - - cc->cipher = kzalloc(end - start + 1, GFP_KERNEL); - if (!cc->cipher) - return -ENOMEM; - - strncpy(cc->cipher, start, end - start); - - return 0; -} - /* * Workaround to parse HMAC algorithm from AEAD crypto API spec. * The HMAC is needed to calculate tag size (HMAC digest size). @@ -2402,12 +2354,6 @@ static int crypt_ctr_cipher_new(struct dm_target *ti, char *cipher_in, char *key else cc->iv_size = crypto_skcipher_ivsize(any_tfm(cc)); - ret = crypt_ctr_blkdev_cipher(cc); - if (ret < 0) { - ti->error = "Cannot allocate cipher string"; - return -ENOMEM; - } - return 0; } @@ -2442,10 +2388,6 @@ static int crypt_ctr_cipher_old(struct dm_target *ti, char *cipher_in, char *key } cc->key_parts = cc->tfms_count; - cc->cipher = kstrdup(cipher, GFP_KERNEL); - if (!cc->cipher) - goto bad_mem; - chainmode = strsep(&tmp, "-"); *ivmode = strsep(&tmp, ":"); *ivopts = tmp;