lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52CEB901.6030504@mellanox.com>
Date:	Thu, 9 Jan 2014 16:58:09 +0200
From:	Sagi Grimberg <sagig@...lanox.com>
To:	"Nicholas A. Bellinger" <nab@...erainc.com>,
	target-devel <target-devel@...r.kernel.org>
CC:	linux-scsi <linux-scsi@...r.kernel.org>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	Christoph Hellwig <hch@....de>, Hannes Reinecke <hare@...e.de>,
	Or Gerlitz <ogerlitz@...lanox.com>,
	Nicholas Bellinger <nab@...ux-iscsi.org>,
	oren Duer <oren@...lanox.com>
Subject: Re: [PATCH 03/14] target/sbc: Add sbc_check_prot + update sbc_parse_cdb
 for DIF

On 1/8/2014 10:36 PM, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@...ux-iscsi.org>
>
> This patch adds sbc_check_prot() for performing various DIF
> related CDB sanity checks, along with setting SCF_PROT once
> sanity checks have passed.
>
> Also, add calls in sbc_parse_cdb() for READ_[10,12,16] +
> WRITE_[10,12,16] to perform DIF sanity checking.
>
> Cc: Martin K. Petersen <martin.petersen@...cle.com>
> Cc: Christoph Hellwig <hch@....de>
> Cc: Hannes Reinecke <hare@...e.de>
> Cc: Sagi Grimberg <sagig@...lanox.com>
> Cc: Or Gerlitz <ogerlitz@...lanox.com>
> Signed-off-by: Nicholas Bellinger <nab@...ux-iscsi.org>
> ---
>   drivers/target/target_core_sbc.c |   39 ++++++++++++++++++++++++++++++++++++++
>   1 file changed, 39 insertions(+)
>
> diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
> index 52ae54e..600ffcb 100644
> --- a/drivers/target/target_core_sbc.c
> +++ b/drivers/target/target_core_sbc.c
> @@ -563,6 +563,27 @@ sbc_compare_and_write(struct se_cmd *cmd)
>   	return TCM_NO_SENSE;
>   }
>   
> +bool
> +sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb)
> +{
> +	if (!dev->dev_attrib.pi_prot_type)
> +		return true;
> +
> +	if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE2_PROT &&
> +	   (cdb[1] & 0xe0))
> +		return false;
> +
> +	if (!(cdb[1] & 0xe0)) {
> +		pr_warn("Target: Unprotected READ/WRITE to DIF device\n");
> +		return true;
> +	}
> +	if (!cmd->t_prot_sg || !cmd->t_prot_nents)
> +		return true;
> +
> +	cmd->se_cmd_flags |= SCF_PROT;

Isn't this the place to fill the se_cmd DIF execution parameters? 
prot_op, prot_type, guard_type, initial_reftag, apptag etc...
Next, all parties interested in DIF execution should look in se_cmd 
(backstore, transport).

> +	return true;
> +}
> +
>   sense_reason_t
>   sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
>   {
> @@ -581,6 +602,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
>   		cmd->execute_cmd = sbc_execute_rw;
>   		break;
>   	case READ_10:
> +		if (!sbc_check_prot(dev, cmd, cdb))
> +			return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
>   		sectors = transport_get_sectors_10(cdb);
>   		cmd->t_task_lba = transport_lba_32(cdb);
>   		cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
> @@ -588,6 +612,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
>   		cmd->execute_cmd = sbc_execute_rw;
>   		break;
>   	case READ_12:
> +		if (!sbc_check_prot(dev, cmd, cdb))
> +			return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
>   		sectors = transport_get_sectors_12(cdb);
>   		cmd->t_task_lba = transport_lba_32(cdb);
>   		cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
> @@ -595,6 +622,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
>   		cmd->execute_cmd = sbc_execute_rw;
>   		break;
>   	case READ_16:
> +		if (!sbc_check_prot(dev, cmd, cdb))
> +			return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
>   		sectors = transport_get_sectors_16(cdb);
>   		cmd->t_task_lba = transport_lba_64(cdb);
>   		cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
> @@ -610,6 +640,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
>   		break;
>   	case WRITE_10:
>   	case WRITE_VERIFY:
> +		if (!sbc_check_prot(dev, cmd, cdb))
> +			return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
>   		sectors = transport_get_sectors_10(cdb);
>   		cmd->t_task_lba = transport_lba_32(cdb);
>   		if (cdb[1] & 0x8)
> @@ -619,6 +652,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
>   		cmd->execute_cmd = sbc_execute_rw;
>   		break;
>   	case WRITE_12:
> +		if (!sbc_check_prot(dev, cmd, cdb))
> +			return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
>   		sectors = transport_get_sectors_12(cdb);
>   		cmd->t_task_lba = transport_lba_32(cdb);
>   		if (cdb[1] & 0x8)
> @@ -628,6 +664,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
>   		cmd->execute_cmd = sbc_execute_rw;
>   		break;
>   	case WRITE_16:
> +		if (!sbc_check_prot(dev, cmd, cdb))
> +			return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
>   		sectors = transport_get_sectors_16(cdb);
>   		cmd->t_task_lba = transport_lba_64(cdb);
>   		if (cdb[1] & 0x8)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ