linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: petkovbb@gmail.com
Cc: Tejun Heo <tj@kernel.org>, axboe@kernel.dk, linux-ide@vger.kernel.org
Subject: Re: [PATCH 02/15] ide-tape: remove back-to-back REQUEST_SENSE detection
Date: Sat, 18 Apr 2009 18:51:49 +0200	[thread overview]
Message-ID: <200904181851.50010.bzolnier@gmail.com> (raw)
In-Reply-To: <9ea470500904170323k2adbe63q5488c63fe368d328@mail.gmail.com>

On Friday 17 April 2009 12:23:13 Borislav Petkov wrote:
> Hi,
> 
> On Fri, Apr 17, 2009 at 11:33 AM, Tejun Heo <tj@kernel.org> wrote:
> > Impact: fix an oops which always triggers
> >
> > ide_tape_issue_pc() assumed drive->pc isn't NULL on invocation when
> > checking for back-to-back request sense issues but drive->pc can be
> > NULL and even when it's not NULL, it's not safe to dereference it once
> > the previous command is complete because pc could have been freed or
> > was on stack.  Kill back-to-back REQUEST_SENSE detection.
> >
> > Signed-off-by: Tejun Heo <tj@kernel.org>
> > ---
> >  drivers/ide/ide-tape.c |    6 ------
> >  1 files changed, 0 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
> > index cb942a9..3a53e08 100644
> > --- a/drivers/ide/ide-tape.c
> > +++ b/drivers/ide/ide-tape.c
> > @@ -614,12 +614,6 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
> >  {
> >        idetape_tape_t *tape = drive->driver_data;
> >
> > -       if (drive->pc->c[0] == REQUEST_SENSE &&
> > -           pc->c[0] == REQUEST_SENSE) {
> > -               printk(KERN_ERR "ide-tape: possible ide-tape.c bug - "
> > -                       "Two request sense in serial were issued\n");
> > -       }
> > -
> >        if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE)
> >                drive->failed_pc = pc;
> >
> 
> I hit that too when debugging an ide-tape problem a user has
> (http://bugzilla.kernel.org/show_bug.cgi?id=12874). However, this is not the
> proper solution since, currently, ide-tape stuffs all packet commands in
> rq->buffer or rq->special now after your changes. It has to get them out of
> there in the ->do_request callback and set drive->pc to point to the current
> packet command in flight through the IRQ handler. And since ide_tape_issue_pc()
> is called by the ->do_request callback we should have the drive->pc always
> valid.
> 
> How about something like that instead:

Can't we just apply them both? :)

Could it be that we just need to take care if this case:

        if (rq->cmd[13] & REQ_IDETAPE_PC2) {
                idetape_media_access_finished(drive);
                return ide_stopped;
        }

[all other code-paths set pc before calling ide_tape_issue_pc()]

> diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
> index 4e6181c..171dbcd 100644
> --- a/drivers/ide/ide-tape.c
> +++ b/drivers/ide/ide-tape.c
> @@ -792,6 +792,9 @@ static ide_startstop_t
> idetape_do_request(ide_drive_t *drive,
>  	struct request *postponed_rq = tape->postponed_rq;
>  	u8 stat;
> 
> +	if (rq->cmd_type == REQ_TYPE_SPECIAL)
> +		drive->pc = (struct ide_atapi_pc *) rq->buffer;
> +
>  	debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu,"
>  			" current_nr_sectors: %u\n",
>  			(unsigned long long)rq->sector, rq->nr_sectors,

  parent reply	other threads:[~2009-04-18 16:54 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-17  9:33 [PATCHSET pata-2.6] ide: rq->buffer, data, special and misc cleanups, take#2 Tejun Heo
2009-04-17  9:33 ` [PATCH 01/15] block: clear req->errors on bio completion only for fs requests Tejun Heo
2009-04-17  9:33 ` [PATCH 02/15] ide-tape: remove back-to-back REQUEST_SENSE detection Tejun Heo
2009-04-17 10:23   ` Borislav Petkov
2009-04-17 10:35     ` Tejun Heo
2009-04-17 10:40       ` Tejun Heo
2009-04-17 11:03         ` Borislav Petkov
2009-04-17 21:12           ` Tejun Heo
2009-04-17 21:27             ` Mark Lord
2009-04-18 19:48             ` Borislav Petkov
2009-04-18 21:39               ` Tejun Heo
2009-04-19  7:28                 ` Borislav Petkov
2009-04-19  7:36                   ` Tejun Heo
2009-04-18 16:51     ` Bartlomiej Zolnierkiewicz [this message]
2009-04-18 21:42       ` Tejun Heo
2009-04-17  9:33 ` [PATCH 03/15] ide: use blk_run_queue() instead of blk_start_queueing() Tejun Heo
2009-04-17  9:33 ` [PATCH 04/15] ide: don't set REQ_SOFTBARRIER Tejun Heo
2009-04-17  9:33 ` [PATCH 05/15] ide kill unused ide_cmd->special Tejun Heo
2009-04-17  9:33 ` [PATCH 06/15] ide-cd: clear sense buffer before issuing request sense Tejun Heo
2009-04-17  9:33 ` [PATCH 07/15] ide-floppy: block pc always uses bio Tejun Heo
2009-04-17  9:33 ` [PATCH 08/15] ide-taskfile: don't abuse rq->buffer Tejun Heo
2009-04-17  9:33 ` [PATCH 09/15] ide-atapi: " Tejun Heo
2009-04-17  9:33 ` [PATCH 10/15] ide-cd: " Tejun Heo
2009-04-17  9:33 ` [PATCH 11/15] ide: add helpers for preparing sense requests Tejun Heo
2009-04-17  9:33 ` [PATCH 12/15] ide-cd: convert to using generic sense request Tejun Heo
2009-04-19  9:22   ` Borislav Petkov
2009-04-19  9:28     ` Tejun Heo
2009-04-19  9:30       ` Tejun Heo
2009-04-17  9:33 ` [PATCH 13/15] ide-atapi: convert ide-{floppy,tape} to using preallocated sense buffer Tejun Heo
2009-04-17  9:33 ` [PATCH 14/15] ide-cd,atapi: use bio for internal commands Tejun Heo
2009-04-17  9:33 ` [PATCH 15/15] ide-pm: don't abuse rq->data Tejun Heo
2009-04-18 16:32 ` [PATCHSET pata-2.6] ide: rq->buffer, data, special and misc cleanups, take#2 Bartlomiej Zolnierkiewicz
2009-04-18 20:04   ` Borislav Petkov
2009-04-18 21:43   ` Tejun Heo
2009-04-18 22:04     ` [GIT PATCH " Tejun Heo
2009-04-20 11:47       ` Bartlomiej Zolnierkiewicz
2009-04-20 11:59         ` Tejun Heo

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=200904181851.50010.bzolnier@gmail.com \
    --to=bzolnier@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-ide@vger.kernel.org \
    --cc=petkovbb@gmail.com \
    --cc=tj@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 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).