All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig@dev.mellanox.co.il>
To: michaelc@cs.wisc.edu, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/1] libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu
Date: Sun, 07 Sep 2014 15:42:47 +0300	[thread overview]
Message-ID: <540C52C7.6030907@dev.mellanox.co.il> (raw)
In-Reply-To: <1409720439-6226-1-git-send-email-michaelc@cs.wisc.edu>

On 9/3/2014 8:00 AM, michaelc@cs.wisc.edu wrote:
> From: Mike Christie <michaelc@cs.wisc.edu>
>
> This patches fixes a potential buffer overrun in __iscsi_conn_send_pdu.
> This function is used by iscsi drivers and userspace to send iscsi PDUs/
> commands. For login commands, we have a set buffer size. For all other
> commands we do not support data buffers.
>
> This was reported by Dan Carpenter here:
> http://www.spinics.net/lists/linux-scsi/msg66838.html
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
> ---
>   drivers/scsi/libiscsi.c |   10 ++++++++++
>   1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index ea025e4..191b597 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -717,11 +717,21 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
>   			return NULL;
>   		}
>
> +		if (data_size > ISCSI_DEF_MAX_RECV_SEG_LEN) {
> +			iscsi_conn_printk(KERN_ERR, conn, "Invalid buffer len of %u for login task. Max len is %u\n", data_size, ISCSI_DEF_MAX_RECV_SEG_LEN);
> +			return NULL;
> +		}
> +
>   		task = conn->login_task;
>   	} else {
>   		if (session->state != ISCSI_STATE_LOGGED_IN)
>   			return NULL;
>
> +		if (data_size != 0) {
> +			iscsi_conn_printk(KERN_ERR, conn, "Can not send data buffer of len %u for op 0x%x\n", data_size, opcode);
> +			return NULL;
> +		}
> +
>   		BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
>   		BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
>
>

Looks good to me too,

Reviewed-by: Sagi Grimberg <sagig@mellanox.com>

      parent reply	other threads:[~2014-09-07 12:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03  5:00 [PATCH 1/1] libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu michaelc
2014-09-06  0:36 ` Christoph Hellwig
2014-09-07 12:42 ` Sagi Grimberg [this message]

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=540C52C7.6030907@dev.mellanox.co.il \
    --to=sagig@dev.mellanox.co.il \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.