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: <YYuGMBYaiZD2vybH@apples.localdomain>
Date:   Wed, 10 Nov 2021 09:43:28 +0100
From:   Klaus Jensen <its@...elevant.dk>
To:     linux-nvme@...ts.infradead.org
Cc:     Keith Busch <kbusch@...nel.org>, Christoph Hellwig <hch@....de>,
        Jens Axboe <axboe@...com>, Sagi Grimberg <sagi@...mberg.me>,
        linux-kernel@...r.kernel.org, Klaus Jensen <k.jensen@...sung.com>
Subject: Re: [PATCH] nvme: fix write zeroes pi

On Nov  4 19:16, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@...sung.com>
> 
> Write Zeroes sets PRACT when block integrity is enabled (as it should),
> but neglects to also set the reftag which is expected by reads. This
> causes protection errors on reads.
> 
> Fix this by setting the reftag for type 1 and 2 (for type 3, reads will
> not check the reftag).
> 
> Signed-off-by: Klaus Jensen <k.jensen@...sung.com>
> ---
>  drivers/nvme/host/core.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3825b596ca16..532bad4de025 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -914,10 +914,15 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns,
>  		cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req)));
>  	cmnd->write_zeroes.length =
>  		cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
> -	if (nvme_ns_has_pi(ns))
> +
> +	switch (ns->pi_type) {
> +	case NVME_NS_DPS_PI_TYPE1:
> +	case NVME_NS_DPS_PI_TYPE2:
>  		cmnd->write_zeroes.control = cpu_to_le16(NVME_RW_PRINFO_PRACT);
> -	else
> -		cmnd->write_zeroes.control = 0;
> +		cmnd->write_zeroes.reftag = cpu_to_le32(t10_pi_ref_tag(req));
> +		break;
> +	}
> +
>  	return BLK_STS_OK;
>  }
>  

Ugh. I goofed up. This fails to set PRACT for type 3.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ