Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3286252pxk; Mon, 21 Sep 2020 09:43:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys/PwyYTdtbD9UMbVyEHp4dQt5EZXUOUbRYPBW0LzuR5LFUFWBD+YmL6tO8lzvlQ2XWlhe X-Received: by 2002:a05:6402:d8:: with SMTP id i24mr554457edu.294.1600706582058; Mon, 21 Sep 2020 09:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706582; cv=none; d=google.com; s=arc-20160816; b=FD2IiKp81ny5QS3v0i+lmrQ8xtDF8CFcBixgdVhSUKeP8HPFwhn+6HNITv9MsGm/Jk JcZRKltaRgt3uKLJrvtIWcwkQjbfbIAWBt5MKZxRidGYrRMW58YmFv68qWjyuGZeLw2Z XyCxK9BpEgnXQYU+5Wvu24P4A5ubcU/fgMCO7MmiA0v2W/6Kqoe3nnJpye3UAczujmKN L3sQC7l8PbeHH+87F1ZImLpi8dMvPg6ZK3if9IKZGVeDjythNoy4XenMPdTT6+x+MGgB OlLaEjpoexocH2g9EJafP9Oa1FvB+61muQKIK8JbsHPalUJ7uwQ4yZQXzkCEXnrHFNNQ 4P2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=63zj+oPNDwT8tnN3BKN33Grwaf3PWjzhNVUfMWEqS9U=; b=LGjKvJuC3kEdlkheeiB+Y+pkLkKdUAXeMHmP1trS1Keihf4PiPZpWvV4hG6PdLkQ8p 17IZthTvupHuN5YKdFSKDlTfpKTnws9Mk92PBbAW8bz0YjXxrH+Tqy2hO/d/ysjwA+bP V0UbPwwaMCtHoCJsQPXs8MhXVrtVup91iFUtOH/63IINxx5Xmlrn5a7KMEs2eRVIy1pY //jiY80O5d8lsxhbgLa0mHp5SDyHBMWL40fXcCjStzV+FwZIG1EFLeUsN3z0DUc3w38Q OdlNAWmQ6eMELpWPSFHBa34uYScPYJzq/Mhxr/Ib1q9qthaDMyAjxHg1vChmbFYXvZrM 9VVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=alVltCbw; 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 ds2si8453739ejc.117.2020.09.21.09.42.38; Mon, 21 Sep 2020 09:43:02 -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=alVltCbw; 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 S1729186AbgIUQin (ORCPT + 99 others); Mon, 21 Sep 2020 12:38:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728626AbgIUQiR (ORCPT ); Mon, 21 Sep 2020 12:38:17 -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 B01AE206B7; Mon, 21 Sep 2020 16:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706296; bh=wOGQmjX4h89ENxZdVhJDy72GEdbI3DlGxhw+F2HHsW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=alVltCbwKQaaOSkibqAwTJl4g/RSI+DHbvg/hs0TQbcrmP97YWOPp2XZtNt3oLlTn tRh8jPfyUDLatxmrC/wx3/z0SqotZgchmwKpgGYPqT/SlyD8goFeqwwnfOoDF4cVMW C3P/8XdMOrNrr34lsGhozyODO7Uyhi1vvxZK/GUE= 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.14 43/94] scsi: target: iscsi: Fix data digest calculation Date: Mon, 21 Sep 2020 18:27:30 +0200 Message-Id: <20200921162037.524819462@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.541285330@linuxfoundation.org> References: <20200921162035.541285330@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 @@ -1382,14 +1382,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); }