Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4559421imu; Tue, 29 Jan 2019 03:48:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN5DzxDmtBH8rIq5/7G7ut7vgQjHufMMVsJRAsHcWr7GO6p7+iDrV1i0HTXQMc6TMCw7QLoI X-Received: by 2002:a17:902:6113:: with SMTP id t19mr24914217plj.248.1548762480494; Tue, 29 Jan 2019 03:48:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548762480; cv=none; d=google.com; s=arc-20160816; b=kha1gjxNrWK44BaXS6bEY1Pe9SJFepH5efBN2g3uF4WqZC5a0Ql+WSb2UHAppqmekn 4FakV33FDmE0mTcMLMT8+USTlFfUCxoEi/4Sgux0O+6Jw8JQWShGijhXF3L6hMWgYrqZ Q8+QA9nwkoGjRZHszCaHHd5lNoorrFDOKoiMkX/ciGHXGtt6g8JWUq/DhGmlFD2iUu3l LLrzyDuD/IHYIznxThAMOVkSHm+QX3H2PWwd2YOwqgchMZF6b4ha9a2kDusS742A1FNc QzQ1vcW1zI8uv8FLQouvVenkDRFTNTJFOyRVoldC47OMIoClD8/HKba480OvKeZKpY6X gB9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+7zpiQmCUiUJK5jWteTX9Uhi4kxaaXXWgEnGOJTWntI=; b=xGdEBtpTzI1v1dWHejQ/crYxtyZFfnS8Y77u5R4PicKrpSo/vkvR651UsHiNahq98T 6cKOzkcJ65HX6T5uEDusnOOzz7NmfsGt9Axs1jKPgIt4bxPN5edwX3J4KJt7HtXCqRUl qDQfXQ101QjJUo5glN53rgb9WNO+khW6A6u7V9ThujD2sc5PrHytcavTzrGrpQi56bw1 RlET73QkkmfRjw131WvwsENIKEhGZC3l4aggKkBsYt5Ty7EPkmn0Qdfry0KLcO//bdj6 wa/aVuktvmfCEVa9TKfIyuRWi5DIGJ7SQUm3LWB2KGXepsoq7+Qkdlvs7pt71tTJKSa4 wltg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oH7+6pEU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m32si4697637pld.86.2019.01.29.03.47.45; Tue, 29 Jan 2019 03:48:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=oH7+6pEU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731071AbfA2Lqx (ORCPT + 99 others); Tue, 29 Jan 2019 06:46:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:37502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729724AbfA2Lqv (ORCPT ); Tue, 29 Jan 2019 06:46:51 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2801721874; Tue, 29 Jan 2019 11:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762410; bh=waHCZt964ElGKcR5whMcvxMfWXmFTIPHjGLK0WnXm2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oH7+6pEULaqpVgYT4vvWHw5RfIksq2baPVI/oK0CBAKXT8JFkN2ZFo3p065bm8ISe nVaWLhZyD45h4Quyx+4VY7xaKyDPgqcEtcRQ//hDtD9p70f+5H9IUB8gjCne/sTTLl X+NVVhuQUbU/2nyGt10++NcyQK39pM48WixpTJcg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Milan Broz , Mike Snitzer Subject: [PATCH 4.19 065/103] dm crypt: fix parsing of extended IV arguments Date: Tue, 29 Jan 2019 12:35:42 +0100 Message-Id: <20190129113204.552478151@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113159.567154026@linuxfoundation.org> References: <20190129113159.567154026@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Milan Broz commit 1856b9f7bcc8e9bdcccc360aabb56fbd4dd6c565 upstream. The dm-crypt cipher specification in a mapping table is defined as: cipher[:keycount]-chainmode-ivmode[:ivopts] or (new crypt API format): capi:cipher_api_spec-ivmode[:ivopts] For ESSIV, the parameter includes hash specification, for example: aes-cbc-essiv:sha256 The implementation expected that additional IV option to never include another dash '-' character. But, with SHA3, there are names like sha3-256; so the mapping table parser fails: dmsetup create test --table "0 8 crypt aes-cbc-essiv:sha3-256 9c1185a5c5e9fc54612808977ee8f5b9e 0 /dev/sdb 0" or (new crypt API format) dmsetup create test --table "0 8 crypt capi:cbc(aes)-essiv:sha3-256 9c1185a5c5e9fc54612808977ee8f5b9e 0 /dev/sdb 0" device-mapper: crypt: Ignoring unexpected additional cipher options device-mapper: table: 253:0: crypt: Error creating IV device-mapper: ioctl: error adding target to table Fix the dm-crypt constructor to ignore additional dash in IV options and also remove a bogus warning (that is ignored anyway). Cc: stable@vger.kernel.org # 4.12+ Signed-off-by: Milan Broz Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-crypt.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -2405,9 +2405,21 @@ static int crypt_ctr_cipher_new(struct d * capi:cipher_api_spec-iv:ivopts */ tmp = &cipher_in[strlen("capi:")]; - cipher_api = strsep(&tmp, "-"); - *ivmode = strsep(&tmp, ":"); - *ivopts = tmp; + + /* Separate IV options if present, it can contain another '-' in hash name */ + *ivopts = strrchr(tmp, ':'); + if (*ivopts) { + **ivopts = '\0'; + (*ivopts)++; + } + /* Parse IV mode */ + *ivmode = strrchr(tmp, '-'); + if (*ivmode) { + **ivmode = '\0'; + (*ivmode)++; + } + /* The rest is crypto API spec */ + cipher_api = tmp; if (*ivmode && !strcmp(*ivmode, "lmk")) cc->tfms_count = 64; @@ -2477,11 +2489,8 @@ static int crypt_ctr_cipher_old(struct d goto bad_mem; chainmode = strsep(&tmp, "-"); - *ivopts = strsep(&tmp, "-"); - *ivmode = strsep(&*ivopts, ":"); - - if (tmp) - DMWARN("Ignoring unexpected additional cipher options"); + *ivmode = strsep(&tmp, ":"); + *ivopts = tmp; /* * For compatibility with the original dm-crypt mapping format, if