kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] scsi: cxgb4i: fix dereference of pointer tdata before it is null checked
@ 2020-07-09 13:52 Colin King
  2020-07-13 16:17 ` Varun Prakash
  2020-07-14  4:58 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2020-07-09 13:52 UTC (permalink / raw)
  To: James E . J . Bottomley, Martin K . Petersen, Varun Prakash, linux-scsi
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently pointer tdata is being dereferenced on the initialization of
pointer skb before tdata is null checked. This could lead to a potential
null pointer dereference.  Fix this by dereferencing tdata after tdata
has been null pointer sanity checked.

Addresses-Coverity: ("Dereference before null check")
Fixes: e33c2482289b ("scsi: cxgb4i: Add support for iSCSI segmentation offload")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/scsi/cxgbi/libcxgbi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 1fb101c616b7..a6119d9daedf 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -2147,7 +2147,7 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset,
 	struct iscsi_conn *conn = task->conn;
 	struct iscsi_tcp_task *tcp_task = task->dd_data;
 	struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
-	struct sk_buff *skb = tdata->skb;
+	struct sk_buff *skb;
 	struct scsi_cmnd *sc = task->sc;
 	u32 expected_count, expected_offset;
 	u32 datalen = count, dlimit = 0;
@@ -2161,6 +2161,7 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset,
 		       tcp_task ? tcp_task->dd_data : NULL, tdata);
 		return -EINVAL;
 	}
+	skb = tdata->skb;
 
 	log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX,
 		  "task 0x%p,0x%p, skb 0x%p, 0x%x,0x%x,0x%x, %u+%u.\n",
@@ -2365,7 +2366,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
 	struct iscsi_tcp_task *tcp_task = task->dd_data;
 	struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
 	struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
-	struct sk_buff *skb = tdata->skb;
+	struct sk_buff *skb;
 	struct cxgbi_sock *csk = NULL;
 	u32 pdulen = 0;
 	u32 datalen;
@@ -2378,6 +2379,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
 		return -EINVAL;
 	}
 
+	skb = tdata->skb;
 	if (!skb) {
 		log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX,
 			  "task 0x%p, skb NULL.\n", task);
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] scsi: cxgb4i: fix dereference of pointer tdata before it is null checked
  2020-07-09 13:52 [PATCH][next] scsi: cxgb4i: fix dereference of pointer tdata before it is null checked Colin King
@ 2020-07-13 16:17 ` Varun Prakash
  2020-07-14  4:58 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Varun Prakash @ 2020-07-13 16:17 UTC (permalink / raw)
  To: Colin King
  Cc: James E . J . Bottomley, Martin K . Petersen, linux-scsi,
	kernel-janitors, linux-kernel

On Thu, Jul 09, 2020 at 02:52:17PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently pointer tdata is being dereferenced on the initialization of
> pointer skb before tdata is null checked. This could lead to a potential
> null pointer dereference.  Fix this by dereferencing tdata after tdata
> has been null pointer sanity checked.
> 
> Addresses-Coverity: ("Dereference before null check")
> Fixes: e33c2482289b ("scsi: cxgb4i: Add support for iSCSI segmentation offload")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/scsi/cxgbi/libcxgbi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
> index 1fb101c616b7..a6119d9daedf 100644
> --- a/drivers/scsi/cxgbi/libcxgbi.c
> +++ b/drivers/scsi/cxgbi/libcxgbi.c
> @@ -2147,7 +2147,7 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset,
>  	struct iscsi_conn *conn = task->conn;
>  	struct iscsi_tcp_task *tcp_task = task->dd_data;
>  	struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
> -	struct sk_buff *skb = tdata->skb;
> +	struct sk_buff *skb;
>  	struct scsi_cmnd *sc = task->sc;
>  	u32 expected_count, expected_offset;
>  	u32 datalen = count, dlimit = 0;
> @@ -2161,6 +2161,7 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset,
>  		       tcp_task ? tcp_task->dd_data : NULL, tdata);
>  		return -EINVAL;
>  	}
> +	skb = tdata->skb;
>  
>  	log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX,
>  		  "task 0x%p,0x%p, skb 0x%p, 0x%x,0x%x,0x%x, %u+%u.\n",
> @@ -2365,7 +2366,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
>  	struct iscsi_tcp_task *tcp_task = task->dd_data;
>  	struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);
>  	struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo;
> -	struct sk_buff *skb = tdata->skb;
> +	struct sk_buff *skb;
>  	struct cxgbi_sock *csk = NULL;
>  	u32 pdulen = 0;
>  	u32 datalen;
> @@ -2378,6 +2379,7 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
>  		return -EINVAL;
>  	}
>  
> +	skb = tdata->skb;
>  	if (!skb) {
>  		log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX,
>  			  "task 0x%p, skb NULL.\n", task);

Acked-by: Varun Prakash <varun@chelsio.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] scsi: cxgb4i: fix dereference of pointer tdata before it is null checked
  2020-07-09 13:52 [PATCH][next] scsi: cxgb4i: fix dereference of pointer tdata before it is null checked Colin King
  2020-07-13 16:17 ` Varun Prakash
@ 2020-07-14  4:58 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2020-07-14  4:58 UTC (permalink / raw)
  To: James E . J . Bottomley, Varun Prakash, linux-scsi, Colin King
  Cc: Martin K . Petersen, linux-kernel, kernel-janitors

On Thu, 9 Jul 2020 14:52:17 +0100, Colin King wrote:

> Currently pointer tdata is being dereferenced on the initialization of
> pointer skb before tdata is null checked. This could lead to a potential
> null pointer dereference.  Fix this by dereferencing tdata after tdata
> has been null pointer sanity checked.

Applied to 5.9/scsi-queue, thanks!

[1/1] scsi: cxgb4i: Fix dereference of pointer tdata before it is null checked
      https://git.kernel.org/mkp/scsi/c/b92a4a9f7be8

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-14  4:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 13:52 [PATCH][next] scsi: cxgb4i: fix dereference of pointer tdata before it is null checked Colin King
2020-07-13 16:17 ` Varun Prakash
2020-07-14  4:58 ` Martin K. Petersen

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).