Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Chengfeng Ye <dg573847474@gmail.com>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	Jack Wang <jinpu.wang@cloud.ionos.com>,
	linux-scsi@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: pm8001: Fix potential TOCTOU race in pm8001_find_tag
Date: Mon, 19 Jan 2026 22:42:44 -0500	[thread overview]
Message-ID: <d7040eecadcc3557c04c27f0c74ce40b2885c311.camel@HansenPartnership.com> (raw)
In-Reply-To: <CAAo+4rUkmuOruVVVNYePyfqu5OgxUxWupEBwvJg7Aus3g7WDqA@mail.gmail.com>

On Tue, 2026-01-20 at 00:50 +0800, Chengfeng Ye wrote:
> > I don't get how a race is possible here.  Before the query function
> > begins, the sas logic calls abort task on the tag, which means the
> > controller should ensure there are no further completion functions
> > for
> > it regardless of whether the abort succeeds or not.
> 
> Thanks a lot for looking into it!
> 
> Sorry that I might miss something as I am not very familiar with the
> code. But I also notice the find_tag() function is also invoked
> inside the abort function (and invoked before the completion).

This is part of the problem, though: you're apparently using some tool
looking for data races in an ancient driver but most of what you find
isn't significant and costs us review cycles to check.

> For the find_tag() invoked inside the abort path will it be a race?
> https://github.com/torvalds/linux/blob/master/drivers/scsi/pm8001/pm8001_sas.c#L1085

So the theory now is that in the couple of instruction cycles between
checking lldd_task and dereferencing it to find the tag, it goes null?
That's so astronomically unlikely precisely because abort is only
called on a task that timed out anyway and the completion function sets
the state done flags, which sas error handling checks, long before it
begins to free the lldd_task.

Regards,

James


  reply	other threads:[~2026-01-20  3:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17 10:19 [PATCH] scsi: pm8001: Fix potential TOCTOU race in pm8001_find_tag Chengfeng Ye
2026-01-18  9:42 ` Markus Elfring
2026-01-19 15:24 ` Chengfeng Ye
2026-01-19 16:39 ` James Bottomley
2026-01-19 16:50   ` Chengfeng Ye
2026-01-20  3:42     ` James Bottomley [this message]
2026-01-20  4:39       ` Chengfeng Ye
2026-01-20 14:28         ` James Bottomley
2026-01-20 16:39           ` Chengfeng Ye
2026-01-20 23:43           ` Finn Thain

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=d7040eecadcc3557c04c27f0c74ce40b2885c311.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=dg573847474@gmail.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox