linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: Keith Busch <kbusch@kernel.org>,
	Dakshaja Uppalapati <dakshaja@chelsio.com>,
	Christoph Hellwig <hch@lst.de>,
	linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: fix dsm failure when payload does not match sgl descriptor
Date: Sat, 25 Jan 2020 22:23:52 +0100	[thread overview]
Message-ID: <20200125212352.GA5407@lst.de> (raw)
In-Reply-To: <20200124173942.2744-1-sagi@grimberg.me>

On Fri, Jan 24, 2020 at 09:39:42AM -0800, Sagi Grimberg wrote:
> The host is allowed to pass the controller an sgl describing a buffer
> that is larger than the dsm payload itself, allow it when executing
> dsm.
> 
> Reported-by: Dakshaja Uppalapati <dakshaja@chelsio.com>
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
>  drivers/nvme/target/core.c        | 12 ++++++++++++
>  drivers/nvme/target/io-cmd-bdev.c |  2 +-
>  drivers/nvme/target/io-cmd-file.c |  2 +-
>  drivers/nvme/target/nvmet.h       |  1 +
>  4 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index 28438b833c1b..9217c824620f 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -938,6 +938,18 @@ bool nvmet_check_data_len(struct nvmet_req *req, size_t data_len)
>  }
>  EXPORT_SYMBOL_GPL(nvmet_check_data_len);
>  
> +bool nvmet_check_data_len_lte(struct nvmet_req *req, size_t data_len)
> +{
> +	if (unlikely(data_len > req->transfer_len)) {
> +		req->error_loc = offsetof(struct nvme_common_command, dptr);
> +		nvmet_req_complete(req, NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR);
> +		return false;
> +	}
> +
> +	return true;
> +}
> +EXPORT_SYMBOL_GPL(nvmet_check_data_len_lte);

Why would this need an export??

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-01-25 21:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 17:39 [PATCH] nvmet: fix dsm failure when payload does not match sgl descriptor Sagi Grimberg
2020-01-24 18:28 ` Keith Busch
2020-01-24 18:35   ` Sagi Grimberg
2020-01-24 18:55     ` Keith Busch
2020-01-25 21:23 ` Christoph Hellwig [this message]
2020-01-27  7:23   ` Sagi Grimberg
2020-03-19 17:23 ` Potnuri Bharat Teja
2020-03-19 21:06   ` Sagi Grimberg
2020-03-20  5:48     ` Potnuri Bharat Teja

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200125212352.GA5407@lst.de \
    --to=hch@lst.de \
    --cc=dakshaja@chelsio.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).