Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp48388pxk; Tue, 15 Sep 2020 17:25:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoki8MG8Q9BZNyT4G0SNsAIcCeMm2C1CzW2DOweRZa7liUDs/Pcjb6+4klW1oTx36ZzwEa X-Received: by 2002:a17:906:15cc:: with SMTP id l12mr23351310ejd.7.1600215910440; Tue, 15 Sep 2020 17:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600215910; cv=none; d=google.com; s=arc-20160816; b=CYuk8xonn31r4197e/ozmUIZsc7llet7iOIieCHFgAuM4+P4vT5p3WZuA4CCx9yL4m 497VIiwoIkJwKrmSfBeV6h24U8Pj8w1Mvz3dT7wwsUNvhJj82dPhyU74ghShJGQfYPUg eFfhmRwP8y5bvGCjqVvznbjuSGb/GTDENLYvKw1k4XoDpNbFh8Fflc32E5kT7zr9g1YV eOjYXtT8drnT6ZE0VHyKdQfz63oemq2K/ZR+4dtDg3SkqhEDkfTwYhGvrKraFjlTw1Ti cZWgZSEhi1vF1fP1zVO9nDK26mC2IerkpXV60j9HELq0/MQUE5MkN0x+pQMtpynEQ8Xr VV2A== 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=PsN8kohoSV0m/OaQCkPm//Qhe/m6uxlBdCg5BhzfYpw=; b=dFS4lI+jep1+UPKzNqJ53HWfZ1SoPWaDg74shtfXBMycUcnoX00nAlCBGFzQGRgLNZ QUmb10pq5G9nDNSdXbSHtD8TUoACS4XQ0EWCfzszXcObZ1fFqCQj7DbY4cxRcPHu/xIj ggaIxsg9AnhYSomRujbBk6Y5H5wqhQkLvfno5Fy02JWeS+iUkO7yqccZyOF7u2tTiP1m Qm5TCCwd40JdcEamys3UE4+xaXdjxsL+tybZwykmlcIolmMJQp5xDQwudYHZE+OANMY2 69/s6hCpK4NgBe0b6efGbMO9o15Uu8ZMfCiLBcERfYisTdcZDBx0LTv4sdHIGfvqULgo gDcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Bonz1nAQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a21si10760894edr.363.2020.09.15.17.24.47; Tue, 15 Sep 2020 17:25:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Bonz1nAQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727440AbgIPAWL (ORCPT + 99 others); Tue, 15 Sep 2020 20:22:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:37100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbgIOOVf (ORCPT ); Tue, 15 Sep 2020 10:21:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 AF51122262; Tue, 15 Sep 2020 14:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179441; bh=p7cyvx5FCIt9EeIMFbZcg4VXvU9Oxz0PMhb8cSQboU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bonz1nAQoTGhHguuio2LBQJz1MoruawRJD6eVNYv2whMBlfsPV7DfhlsP1A5AdV82 yr89vUzBba5zyvpqf4m3i+COU2dsViC2uE9J7FoHlHSzUUiJDRpN40URkUFL2pOAnQ P6Yl7hRLVhVjwJQfRSRlcVppYzIXbgJ1AUNhRvPA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Christie , Varun Prakash , "Martin K. Petersen" Subject: [PATCH 4.19 59/78] scsi: target: iscsi: Fix data digest calculation Date: Tue, 15 Sep 2020 16:13:24 +0200 Message-Id: <20200915140636.530891594@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@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: Varun Prakash commit 5528d03183fe5243416c706f64b1faa518b05130 upstream. Current code does not consider 'page_off' in data digest calculation. To fix this, add a local variable 'first_sg' and set first_sg.offset to sg->offset + page_off. Link: https://lore.kernel.org/r/1598358910-3052-1-git-send-email-varun@chelsio.com Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1") Cc: Reviewed-by: Mike Christie Signed-off-by: Varun Prakash Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/target/iscsi/iscsi_target.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1381,14 +1381,27 @@ static u32 iscsit_do_crypto_hash_sg( sg = cmd->first_data_sg; page_off = cmd->first_data_sg_off; + if (data_length && page_off) { + struct scatterlist first_sg; + u32 len = min_t(u32, data_length, sg->length - page_off); + + sg_init_table(&first_sg, 1); + sg_set_page(&first_sg, sg_page(sg), len, sg->offset + page_off); + + ahash_request_set_crypt(hash, &first_sg, NULL, len); + crypto_ahash_update(hash); + + data_length -= len; + sg = sg_next(sg); + } + while (data_length) { - u32 cur_len = min_t(u32, data_length, (sg->length - page_off)); + u32 cur_len = min_t(u32, data_length, sg->length); ahash_request_set_crypt(hash, sg, NULL, cur_len); crypto_ahash_update(hash); data_length -= cur_len; - page_off = 0; /* iscsit_map_iovec has already checked for invalid sg pointers */ sg = sg_next(sg); }