From patchwork Wed Sep 13 13:45:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 9951487 X-Patchwork-Delegate: snitzer@redhat.com 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 9798B6038F for ; Wed, 13 Sep 2017 14:16:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 890AA28E8C for ; Wed, 13 Sep 2017 14:16:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DBED28E9D; Wed, 13 Sep 2017 14:16:24 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 1383828E8C for ; Wed, 13 Sep 2017 14:16:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FB957E436; Wed, 13 Sep 2017 14:16:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3FB957E436 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3FB957E436 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="THhmsp+A" Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5146318AC4; Wed, 13 Sep 2017 14:16:21 +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 6E3211806107; Wed, 13 Sep 2017 14:16:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8DDkQqe001865 for ; Wed, 13 Sep 2017 09:46:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id F14DC18AC4; Wed, 13 Sep 2017 13:46:26 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB08D69FB6; Wed, 13 Sep 2017 13:46:24 +0000 (UTC) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) (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 6E3EB4A6F5; Wed, 13 Sep 2017 13:46:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E3EB4A6F5 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=gmazyland@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6E3EB4A6F5 Received: by mail-wr0-f193.google.com with SMTP id n64so148094wrb.2; Wed, 13 Sep 2017 06:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Gi0ajMExq+aelrqal+NZbB8FiXvdVTFKmhwogswqvdc=; b=THhmsp+AC6WeiTllTpvDta0i98+25cDI9+FksqlzXwpj7VjRZ5ttLhs8sA/IJf+2JQ l4KaHjpR91AeGT5AAFzp8be9DAZJT6PbJv6kXQedZkOR9bWGFWyBVm6TzT1g73/WgZbi WOLeuXkfjY4eu2yulAdLH1jmrAY2Fc4v9JzISeBEUI1UUhGAXnkWAIUKx6Yr73GIADB6 kE/a/l6XfK9GdiY27RS0jBu/j6e8zrSpibMEVr4ltqEbe9HYggUd0GtKvtRKSI9tshmM VkVgmBf2FdCy8fMwgrDGUbvhJGi22/qE15NXFIKH+a/Nf97/uzP46Efu3VNMJEg95lvV yVRA== 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=Gi0ajMExq+aelrqal+NZbB8FiXvdVTFKmhwogswqvdc=; b=GTpGOKsbJQ0gjR/PplYeO9NueChqwrhIz1Pdgq11UlFY3/75IuMW+MgwbFdyunwbIs 56yy7AswIqsem7Zna1mSh8DzYZvnVIhVSsCuXV0mGtSMa7yWWbPt3MqKYnoiUap1a4T4 cmM0smYuxusO6FpgRMwCRL5onqh+8WpbJ0M7ztgr843832TVGPuLVfeuzviDUTIFoLhN cFuURT748DZU08erNwg1Ib7IqkwzaL0QTWfBD0BG2lToJzeUhVUr4zOtpjC5UQMHh9zA JLkDuISZaMQJ6WlS0zeYzhIz9WuXo9Gc8HBtGS7dPvYJvEPl2ZDSomDaCF6A8IE7qBzJ NhlQ== X-Gm-Message-State: AHPjjUgsCQQBUKlfrYI9Dcg/g7CwaYm8QnZ1AbfKMEpnE6ZDygoHRSYs lFgRNFL8r7IXRzHz X-Google-Smtp-Source: ADKCNb4VpbzqvrIPxapPQd3odV7F0+AfSFVMufUFHtw5Y+dKUQI6XJyvtu26TQkAWmIDc2ZlbmpvXg== X-Received: by 10.223.136.168 with SMTP id f37mr14951490wrf.191.1505310381794; Wed, 13 Sep 2017 06:46:21 -0700 (PDT) Received: from merlot.mazyland.net (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.googlemail.com with ESMTPSA id z108sm13840454wrc.49.2017.09.13.06.46.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 06:46:20 -0700 (PDT) From: Milan Broz To: dm-devel@redhat.com Date: Wed, 13 Sep 2017 15:45:56 +0200 Message-Id: <20170913134556.23145-1-gmazyland@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 13 Sep 2017 13:46:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 13 Sep 2017 13:46:23 +0000 (UTC) for IP:'209.85.128.193' DOMAIN:'mail-wr0-f193.google.com' HELO:'mail-wr0-f193.google.com' FROM:'gmazyland@gmail.com' RCPT:'' X-RedHat-Spam-Score: -2.41 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.128.193 mail-wr0-f193.google.com 209.85.128.193 mail-wr0-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: mpatocka@redhat.com, Milan Broz Subject: [dm-devel] [PATCH] dm-crypt: Reject sector_size feature if device length is not aligned to it X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 13 Sep 2017 14:16:23 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP If a crypt mapping uses optional sector_size feature, additional restrictions to mapped device segment size must be applied in constructor, otherwise the device activation will fail later. Signed-off-by: Milan Broz --- drivers/md/dm-crypt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 54aef8ed97db..488ecd0b1bd0 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -2584,6 +2584,10 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar ti->error = "Invalid feature value for sector_size"; return -EINVAL; } + if (ti->len & ((cc->sector_size >> SECTOR_SHIFT) - 1)) { + ti->error = "Device size is not multiple of sector_size feature"; + return -EINVAL; + } cc->sector_shift = __ffs(cc->sector_size) - SECTOR_SHIFT; } else if (!strcasecmp(opt_string, "iv_large_sectors")) set_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags);