Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2470561imj; Mon, 18 Feb 2019 06:35:21 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib2Njy1vYMh+voBCasV2yjw2TXxQeCcSx3PFr2WPTadJZXFudaKayGpqfaAUNwL1nKqYewN X-Received: by 2002:a65:6497:: with SMTP id e23mr18962560pgv.89.1550500521305; Mon, 18 Feb 2019 06:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550500521; cv=none; d=google.com; s=arc-20160816; b=S/npD/tM0AD4faCduzd1SUhiJbFGiiqXaOXuEyCqMIiAzMPyIOR5gb/liLwXlvWnzZ nqTuBOA+mrE3+0ewAaLFGeDLJA1MBlv/AJ0DqsNXwE6XclmeuZnKoPbNOeyCXiiOzhy+ tkj1JkBQ88sg4BCkV6CxOb6SugzR0aBzdnH8dTv9ZZX0iLb3x153F3Ny4j0MLXGsx2hC xT8No6eBIkxG+YnMYYcoLC/5T6XEuZYTfux+7A0/jbZyQQFQyGgAcycpfgLx/IBQ0daA 5HJIVjaozVh4EeE88tB6mRWY+UV3g8aQWQMFAFgaix/oTzrIEDByQ11VUdgilVjTiNxA qsHA== 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=FdUe5c2JAKU2fHYUvIAioKV56kArXkX4yB05g/mAu3k=; b=fMgX49wNlrrG9QKQQK1e2WB+U84uuX5Qb8+ognhfZtNUFUmT+RAb+7tq1NyQV956ES xSVw+hSZvSWH+Yq0caaFc7jB2DX8pmyHDGRXwyrvEnxwnflrhSWrThGnHzYTigksaBpP JvJbZjGDLlEXbfvtxe9JuVu1ydlR2ngQgdchkiWctNnXOtpP4yrP35Rc8tTawV5o90SC Tvd1GG8AKCIcQaQOC48wMMgyz6pGMBe0iLllcRRuFIXx9Z/sVrCv1e2L/xdHEptpnxSP GJtO7H6Uu8QW41tCByLhFg+3EyzdjjfF+vQ1PsoJ4RRwbbSBq7LNjchQh4F7nxAczPfT 96Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dFu3Y/GI"; 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 d186si954886pfg.50.2019.02.18.06.35.05; Mon, 18 Feb 2019 06:35:21 -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="dFu3Y/GI"; 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 S2388976AbfBROeV (ORCPT + 99 others); Mon, 18 Feb 2019 09:34:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:37052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387891AbfBRN4p (ORCPT ); Mon, 18 Feb 2019 08:56:45 -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 3FC0621900; Mon, 18 Feb 2019 13:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498204; bh=MvlxSMLG4IFo1fWp1DFtuhuzHEuCRVOw4iXdIetxS9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFu3Y/GINL5T7TXwRoR48GTPSqI50tdwBSwgBraOOgHn7R2mlAbkIEUvjAgf5AAtK aTxwHqFhwoMCiZG1sH7pM2LyFRnjG4oTTP4FLi+Lag1W6Q4J6D/pU7GGlPU8W7c8RA UWZ2nP1bFQZt2ZHFCM9rA1T+dIj7W935Y/Axcpbw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Milan Broz , Mikulas Patocka , Mike Snitzer Subject: [PATCH 4.14 57/62] dm crypt: dont overallocate the integrity tag space Date: Mon, 18 Feb 2019 14:44:03 +0100 Message-Id: <20190218133510.639510923@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka commit ff0c129d3b5ecb3df7c8f5e2236582bf745b6c5f upstream. bio_sectors() returns the value in the units of 512-byte sectors (no matter what the real sector size of the device). dm-crypt multiplies bio_sectors() by on_disk_tag_size to calculate the space allocated for integrity tags. If dm-crypt is running with sector size larger than 512b, it allocates more data than is needed. Device Mapper trims the extra space when passing the bio to dm-integrity, so this bug didn't result in any visible misbehavior. But it must be fixed to avoid wasteful memory allocation for the block integrity payload. Fixes: ef43aa38063a6 ("dm crypt: add cryptographic data integrity protection (authenticated encryption)") Cc: stable@vger.kernel.org # 4.12+ Reported-by: Milan Broz Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-crypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -935,7 +935,7 @@ static int dm_crypt_integrity_io_alloc(s if (IS_ERR(bip)) return PTR_ERR(bip); - tag_len = io->cc->on_disk_tag_size * bio_sectors(bio); + tag_len = io->cc->on_disk_tag_size * (bio_sectors(bio) >> io->cc->sector_shift); bip->bip_iter.bi_size = tag_len; bip->bip_iter.bi_sector = io->cc->start + io->sector;