Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5988245ybc; Wed, 27 Nov 2019 12:59:24 -0800 (PST) X-Google-Smtp-Source: APXvYqysGy01NRVlIcU+/IzEN//dZmUk1qcO4yBJeYs+JLsb1wC6nTKkFZGct2taKW6LwKfb8Rr1 X-Received: by 2002:a17:906:cb93:: with SMTP id mf19mr50938348ejb.87.1574888364829; Wed, 27 Nov 2019 12:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888364; cv=none; d=google.com; s=arc-20160816; b=uvpKSl1qKQ7wd7OpalfaRM4gfHVZyoAmmKdHmdogZRPMZOwpcG+KFoBGp9jbu4GN5k lIP08jV1q8oz7TkIDXoCwEGTMARaMZmtTgFA1swHDIGwH6dNp1JPpccOKQglff7Qta4m autztYxnn51Ax4OGSrSVuw7vbGToMNCcum+c2QGHNgMwWnIL8gnvGahd/LcsTYI3ECy/ xBkbT2fBEY0P8iiEfSUBcgPybF5Nm5sbVOmUTPR9TPgmBBRPwshxljXBJaHDHxsTmziW dA4e9hGoLBkIYaiDfp4aKRaN4Y3//0Dmyz/yv+2FEK3ub2Ir8kURvqRcGGI85uesPwKm LYkQ== 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=FN01Mg9fDjjjfiEQTC9znI92n5PGCvZ4Mq/Odtt66Sw=; b=Tx4y7kKdyGP/PXVj4ROE6fftqaQs2qZL8iN4wvll/A6VkH0NqAVLmmjDk+DRXcD8td w06vNRezvYVhlcPyu89W+hPCXXolFLu20q5vmDNokTRgYrl4F7w5fgOTp03AOjFtPAOk kNwKUVeydPuCYk9ItdKJXuyreW8Ym3jM18uiDg2V32Qrkz7OuloRyfBl3+Z3BorC0B7r 6SljBASaFowjoN5crXa/8VXCfRt5fJs/m8+I/bRVh/d5uQpiDof2pD3i90Lj8o453lft iUxAWcqSHIWJvruk356qzhAc3wobRJ7nJ/nuvK7g9i3P73wCJY69Ud0pTU4cwLDHbOMd iPNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IbkcJD2K; 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 rs1si10715141ejb.73.2019.11.27.12.59.01; Wed, 27 Nov 2019 12:59:24 -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=IbkcJD2K; 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 S1731022AbfK0U6H (ORCPT + 99 others); Wed, 27 Nov 2019 15:58:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:49294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729462AbfK0U6G (ORCPT ); Wed, 27 Nov 2019 15:58:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 C057321582; Wed, 27 Nov 2019 20:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888285; bh=bPTlPH2rYRCi56/K0e6IaVB93IuksRjPjxYZGiewy/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IbkcJD2KsGoeelT3yxgIx+zsMNgC3N8L9CS2T1wr51PmHlmXU4uHaTWBPGVmax9Br SFLWzV7GstUG/tgbMVnLGS4ieP1wqwL/pTSY2pdS/a5O5yuJNlupGzUv8Q8RqwBEG8 Vqy6INHOY/B2ygRYuF0/lXyOAKiqB9vHvTA6n4a4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Chaitanya Kulkarni , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.19 075/306] nvmet: avoid integer overflow in the discard code Date: Wed, 27 Nov 2019 21:28:45 +0100 Message-Id: <20191127203120.350833425@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Bart Van Assche [ Upstream commit 8eacd1bd21d6913ec27e6120e9a8733352e191d3 ] Although I'm not sure whether it is a good idea to support large discard commands, I think integer overflow for discard ranges larger than 4 GB should be avoided. This patch avoids that smatch reports the following: drivers/nvme/target/io-cmd-file.c:249:1 nvmet_file_execute_discard() warn: should '((range.nlb)) << req->ns->blksize_shift' be a 64 bit type? Fixes: d5eff33ee6f8 ("nvmet: add simple file backed ns support") Signed-off-by: Bart Van Assche Reviewed-by: Chaitanya Kulkarni Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/io-cmd-file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index 81a9dc5290a87..39d972e2595f0 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -246,7 +246,8 @@ static void nvmet_file_execute_discard(struct nvmet_req *req) break; offset = le64_to_cpu(range.slba) << req->ns->blksize_shift; - len = le32_to_cpu(range.nlb) << req->ns->blksize_shift; + len = le32_to_cpu(range.nlb); + len <<= req->ns->blksize_shift; if (offset + len > req->ns->size) { ret = NVME_SC_LBA_RANGE | NVME_SC_DNR; break; -- 2.20.1