All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	kbuild@lists.01.org, lduncan@suse.com, cleech@redhat.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	james.bottomley@hansenpartnership.com
Cc: lkp@intel.com, kbuild-all@lists.01.org, lutianxiong@huawei.com,
	linfeilong@huawei.com, liuzhiqiang26@huawei.com,
	haowenchao@huawei.com
Subject: Re: [PATCH 2/9] libiscsi: drop taskqueuelock
Date: Wed, 3 Feb 2021 11:10:26 -0600	[thread overview]
Message-ID: <c32c814b-20fb-c10a-1ace-26a7e07327e3@oracle.com> (raw)
In-Reply-To: <20210203101942.GU2696@kadam>

On 2/3/21 4:19 AM, Dan Carpenter wrote:
> Hi Mike,
> 
> url:    https://github.com/0day-ci/linux/commits/Mike-Christie/iscsi-fixes-and-cleanups/20210203-122757
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
> config: i386-randconfig-m021-20210202 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> smatch warnings:
> drivers/scsi/libiscsi_tcp.c:586 iscsi_tcp_r2t_rsp() warn: variable dereferenced before check 'task->sc' (see line 547)
> 
> vim +586 drivers/scsi/libiscsi_tcp.c
> 
> f7dbf0662a0167 Mike Christie     2021-02-02  529  static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
> a081c13e39b5c1 Mike Christie     2008-12-02  530  {
> a081c13e39b5c1 Mike Christie     2008-12-02  531  	struct iscsi_session *session = conn->session;
> f7dbf0662a0167 Mike Christie     2021-02-02  532  	struct iscsi_tcp_task *tcp_task;
> f7dbf0662a0167 Mike Christie     2021-02-02  533  	struct iscsi_tcp_conn *tcp_conn;
> f7dbf0662a0167 Mike Christie     2021-02-02  534  	struct iscsi_r2t_rsp *rhdr;
> a081c13e39b5c1 Mike Christie     2008-12-02  535  	struct iscsi_r2t_info *r2t;
> f7dbf0662a0167 Mike Christie     2021-02-02  536  	struct iscsi_task *task;
> 5d0fddd0a72d30 Shlomo Pongratz   2014-02-07  537  	u32 data_length;
> 5d0fddd0a72d30 Shlomo Pongratz   2014-02-07  538  	u32 data_offset;
> f7dbf0662a0167 Mike Christie     2021-02-02  539  	int r2tsn;
> a081c13e39b5c1 Mike Christie     2008-12-02  540  	int rc;
> a081c13e39b5c1 Mike Christie     2008-12-02  541  
> f7dbf0662a0167 Mike Christie     2021-02-02  542  	spin_lock(&session->back_lock);
> f7dbf0662a0167 Mike Christie     2021-02-02  543  	task = iscsi_itt_to_ctask(conn, hdr->itt);
> f7dbf0662a0167 Mike Christie     2021-02-02  544  	if (!task) {
> f7dbf0662a0167 Mike Christie     2021-02-02  545  		spin_unlock(&session->back_lock);
> f7dbf0662a0167 Mike Christie     2021-02-02  546  		return ISCSI_ERR_BAD_ITT;
> f7dbf0662a0167 Mike Christie     2021-02-02 @547  	} else if (task->sc->sc_data_direction != DMA_TO_DEVICE) {
>                                                                    ^^^^^^^^
> New unchecked dereference.

I see the issue. iscsi_itt_ctask checks task->sc and if NULL returns NULL.
However, below in this function there is now a not needed task->sc check.
The checker saw that and thinks the above line could be a invalid access.

I'll fix the patch by removing the old check since it's confusing code
that's also not needed since it's done for us now.


WARNING: multiple messages have this Message-ID (diff)
From: Mike Christie <michael.christie@oracle.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH 2/9] libiscsi: drop taskqueuelock
Date: Wed, 03 Feb 2021 11:10:26 -0600	[thread overview]
Message-ID: <c32c814b-20fb-c10a-1ace-26a7e07327e3@oracle.com> (raw)
In-Reply-To: <20210203101942.GU2696@kadam>

[-- Attachment #1: Type: text/plain, Size: 2744 bytes --]

On 2/3/21 4:19 AM, Dan Carpenter wrote:
> Hi Mike,
> 
> url:    https://github.com/0day-ci/linux/commits/Mike-Christie/iscsi-fixes-and-cleanups/20210203-122757
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
> config: i386-randconfig-m021-20210202 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> smatch warnings:
> drivers/scsi/libiscsi_tcp.c:586 iscsi_tcp_r2t_rsp() warn: variable dereferenced before check 'task->sc' (see line 547)
> 
> vim +586 drivers/scsi/libiscsi_tcp.c
> 
> f7dbf0662a0167 Mike Christie     2021-02-02  529  static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
> a081c13e39b5c1 Mike Christie     2008-12-02  530  {
> a081c13e39b5c1 Mike Christie     2008-12-02  531  	struct iscsi_session *session = conn->session;
> f7dbf0662a0167 Mike Christie     2021-02-02  532  	struct iscsi_tcp_task *tcp_task;
> f7dbf0662a0167 Mike Christie     2021-02-02  533  	struct iscsi_tcp_conn *tcp_conn;
> f7dbf0662a0167 Mike Christie     2021-02-02  534  	struct iscsi_r2t_rsp *rhdr;
> a081c13e39b5c1 Mike Christie     2008-12-02  535  	struct iscsi_r2t_info *r2t;
> f7dbf0662a0167 Mike Christie     2021-02-02  536  	struct iscsi_task *task;
> 5d0fddd0a72d30 Shlomo Pongratz   2014-02-07  537  	u32 data_length;
> 5d0fddd0a72d30 Shlomo Pongratz   2014-02-07  538  	u32 data_offset;
> f7dbf0662a0167 Mike Christie     2021-02-02  539  	int r2tsn;
> a081c13e39b5c1 Mike Christie     2008-12-02  540  	int rc;
> a081c13e39b5c1 Mike Christie     2008-12-02  541  
> f7dbf0662a0167 Mike Christie     2021-02-02  542  	spin_lock(&session->back_lock);
> f7dbf0662a0167 Mike Christie     2021-02-02  543  	task = iscsi_itt_to_ctask(conn, hdr->itt);
> f7dbf0662a0167 Mike Christie     2021-02-02  544  	if (!task) {
> f7dbf0662a0167 Mike Christie     2021-02-02  545  		spin_unlock(&session->back_lock);
> f7dbf0662a0167 Mike Christie     2021-02-02  546  		return ISCSI_ERR_BAD_ITT;
> f7dbf0662a0167 Mike Christie     2021-02-02 @547  	} else if (task->sc->sc_data_direction != DMA_TO_DEVICE) {
>                                                                    ^^^^^^^^
> New unchecked dereference.

I see the issue. iscsi_itt_ctask checks task->sc and if NULL returns NULL.
However, below in this function there is now a not needed task->sc check.
The checker saw that and thinks the above line could be a invalid access.

I'll fix the patch by removing the old check since it's confusing code
that's also not needed since it's done for us now.

  reply	other threads:[~2021-02-03 17:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03  1:33 [PATCH 0/9 V5] iscsi fixes and cleanups Mike Christie
2021-02-03  1:33 ` [PATCH 1/9] libiscsi: fix iscsi_prep_scsi_cmd_pdu error handling Mike Christie
2021-02-03  1:33 ` [PATCH 2/9] libiscsi: drop taskqueuelock Mike Christie
2021-02-03 10:19   ` Dan Carpenter
2021-02-03 10:19     ` Dan Carpenter
2021-02-03 10:19     ` Dan Carpenter
2021-02-03 17:10     ` Mike Christie [this message]
2021-02-03 17:10       ` Mike Christie
2021-02-03  1:33 ` [PATCH 3/9] libiscsi: fix iscsi_task use after free Mike Christie
2021-02-03  1:33 ` [PATCH 4/9] libiscsi: fix iscsi host workq destruction Mike Christie
2021-02-03  1:33 ` [PATCH 5/9] libiscsi: add helper to calc max scsi cmds per session Mike Christie
2021-02-03  1:33 ` [PATCH 6/9] iscsi_tcp: fix shost can_queue initialization Mike Christie
2021-02-03 23:33   ` Lee Duncan
2021-02-03  1:33 ` [PATCH 7/9] libiscsi: reset max/exp cmdsn during recovery Mike Christie
2021-02-03  1:33 ` [PATCH 8/9] qla4xxx: use iscsi_is_session_online Mike Christie
2021-02-03  1:33 ` [PATCH 9/9] iscsi class: drop session lock in iscsi_session_chkready Mike Christie
2021-02-03  7:39 [PATCH 2/9] libiscsi: drop taskqueuelock kernel test robot
2021-02-07  4:45 [PATCH 0/9 V6] iscsi fixes and cleanups Mike Christie
2021-02-07  4:46 ` [PATCH 2/9] libiscsi: drop taskqueuelock Mike Christie

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=c32c814b-20fb-c10a-1ace-26a7e07327e3@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=cleech@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=haowenchao@huawei.com \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=lduncan@suse.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=lkp@intel.com \
    --cc=lutianxiong@huawei.com \
    --cc=martin.petersen@oracle.com \
    /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.