public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Keith Busch <kbusch@kernel.org>,
	linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme-tcp: check for allocated queue in nvme_tcp_get_address()
Date: Wed, 8 Feb 2023 07:27:37 +0100	[thread overview]
Message-ID: <20230208062737.GA14870@lst.de> (raw)
In-Reply-To: <20230207145548.113618-1-hare@suse.de>

On Tue, Feb 07, 2023 at 03:55:48PM +0100, Hannes Reinecke wrote:
> We need to check if the queue is allocated, otherwise we get
> a kernel crash as 'queue->sock' is not allocated.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  drivers/nvme/host/tcp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 4ddf3e7b252a..487ea3e8b6c4 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -2859,6 +2859,9 @@ static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
>  	struct sockaddr_storage src_addr;
>  	int ret, len;
>  
> +	if (!test_bit(NVME_TCP_Q_ALLOCATED, &queue->flags))
> +		return -EINVAL;

I'm not sure this is enough.  The queue could be freed right after
this check.  I think we have to cache the address information
somewhere instead and ensure that it is always valid.


  reply	other threads:[~2023-02-08  6:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 14:55 [PATCH] nvme-tcp: check for allocated queue in nvme_tcp_get_address() Hannes Reinecke
2023-02-08  6:27 ` Christoph Hellwig [this message]
2023-02-13 10:50   ` Sagi Grimberg

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=20230208062737.GA14870@lst.de \
    --to=hch@lst.de \
    --cc=hare@suse.de \
    --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