[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1110212000010.5184@kai.makisara.local>
Date: Fri, 21 Oct 2011 20:00:54 +0300 (EEST)
From: Kai Makisara <Kai.Makisara@...umbus.fi>
To: Petr Uzel <petr.uzel@...e.cz>
cc: linux-kernel@...r.kernel.org, Willem Riede <osst@...de.org>,
jack@...e.cz, linux-scsi@...r.kernel.org,
juergen.gross@...fujitsu.com
Subject: Re: [PATCH] st: fix race in st_scsi_execute_end
On Fri, 21 Oct 2011, Petr Uzel wrote:
> The call to complete() in st_scsi_execute_end() wakes up sleeping thread
> in write_behind_check(), which frees the st_request, thus invalidating
> the pointer to the associated bio structure, which is then passed to the
> blk_rq_unmap_user(). Fix by storing pointer to bio structure into
> temporary local variable.
>
> This bug is present since at least linux-2.6.32.
>
> CC: stable@...nel.org
> Signed-off-by: Petr Uzel <petr.uzel@...e.cz>
> Reported-by: Juergen Groß <juergen.gross@...fujitsu.com>
> Reviewed-by: Jan Kara <jack@...e.cz>
Acked-by: Kai Mäkisara <kai.makisara@...umbus.fi>
> ---
> drivers/scsi/st.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index 1871b8a..9b28f39 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -462,14 +462,16 @@ static void st_scsi_execute_end(struct request *req, int uptodate)
> {
> struct st_request *SRpnt = req->end_io_data;
> struct scsi_tape *STp = SRpnt->stp;
> + struct bio *tmp;
>
> STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors;
> STp->buffer->cmdstat.residual = req->resid_len;
>
> + tmp = SRpnt->bio;
> if (SRpnt->waiting)
> complete(SRpnt->waiting);
>
> - blk_rq_unmap_user(SRpnt->bio);
> + blk_rq_unmap_user(tmp);
> __blk_put_request(req->q, req);
> }
>
>
Thanks for the fix.
Kai
Powered by blists - more mailing lists