From: Mike Christie <mchristi@redhat.com>
To: Dmitry Fomichev <dmitry.fomichev@wdc.com>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
target-devel@vger.kernel.org,
Bart Van Assche <bvanassche@acm.org>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Subject: Re: [PATCH v2] tcmu: avoid use-after-free after command timeout
Date: Mon, 12 Aug 2019 10:30:19 -0500 [thread overview]
Message-ID: <5D51860B.1060902@redhat.com> (raw)
In-Reply-To: <20190811182510.1706-1-dmitry.fomichev@wdc.com>
On 08/11/2019 01:25 PM, Dmitry Fomichev wrote:
> In tcmu_handle_completion() function, the variable called read_len is
> always initialized with a value taken from se_cmd structure. If this
> function is called to complete an expired (timed out) out command, the
> session command pointed by se_cmd is likely to be already deallocated by
> the target core at that moment. As the result, this access triggers a
> use-after-free warning from KASAN.
>
> This patch fixes the code not to touch se_cmd when completing timed out
> TCMU commands. It also resets the pointer to se_cmd at the time when the
> TCMU_CMD_BIT_EXPIRED flag is set because it is going to become invalid
> after calling target_complete_cmd() later in the same function,
> tcmu_check_expired_cmd().
>
> Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
> ---
Acked-by: Mike Christie <mchristi@redhat.com>
WARNING: multiple messages have this Message-ID (diff)
From: Mike Christie <mchristi@redhat.com>
To: Dmitry Fomichev <dmitry.fomichev@wdc.com>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
target-devel@vger.kernel.org,
Bart Van Assche <bvanassche@acm.org>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Subject: Re: [PATCH v2] tcmu: avoid use-after-free after command timeout
Date: Mon, 12 Aug 2019 15:30:19 +0000 [thread overview]
Message-ID: <5D51860B.1060902@redhat.com> (raw)
In-Reply-To: <20190811182510.1706-1-dmitry.fomichev@wdc.com>
On 08/11/2019 01:25 PM, Dmitry Fomichev wrote:
> In tcmu_handle_completion() function, the variable called read_len is
> always initialized with a value taken from se_cmd structure. If this
> function is called to complete an expired (timed out) out command, the
> session command pointed by se_cmd is likely to be already deallocated by
> the target core at that moment. As the result, this access triggers a
> use-after-free warning from KASAN.
>
> This patch fixes the code not to touch se_cmd when completing timed out
> TCMU commands. It also resets the pointer to se_cmd at the time when the
> TCMU_CMD_BIT_EXPIRED flag is set because it is going to become invalid
> after calling target_complete_cmd() later in the same function,
> tcmu_check_expired_cmd().
>
> Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
> ---
Acked-by: Mike Christie <mchristi@redhat.com>
next prev parent reply other threads:[~2019-08-12 15:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-11 18:25 [PATCH v2] tcmu: avoid use-after-free after command timeout Dmitry Fomichev
2019-08-11 18:25 ` Dmitry Fomichev
2019-08-12 15:30 ` Mike Christie [this message]
2019-08-12 15:30 ` Mike Christie
2019-08-12 18:00 ` Damien Le Moal
2019-08-15 2:00 ` Martin K. Petersen
2019-08-15 2:00 ` Martin K. Petersen
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=5D51860B.1060902@redhat.com \
--to=mchristi@redhat.com \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@wdc.com \
--cc=dmitry.fomichev@wdc.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.kernel.org \
/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.