From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Johannes Thumshirn <jth@kernel.org>,
Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
Doug Gilberg <dgilbert@interlog.com>,
linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.com>
Subject: Re: [PATCHv3 3/6] sg: protect accesses to 'reserved' page array
Date: Fri, 03 Feb 2017 10:21:24 -0800 [thread overview]
Message-ID: <1486146084.2431.36.camel@HansenPartnership.com> (raw)
In-Reply-To: <1d212ffc-d1c2-f743-151d-b8f48ea94f30@kernel.org>
On Fri, 2017-02-03 at 19:06 +0100, Johannes Thumshirn wrote:
>
> On 02/03/2017 05:19 PM, Christoph Hellwig wrote:
> > On Fri, Feb 03, 2017 at 02:38:35PM +0100, Hannes Reinecke wrote:
> > > On 02/03/2017 02:31 PM, Christoph Hellwig wrote:
> > > > > - if (sg_res_in_use(sfp)) {
> > > > > + mutex_lock(&sfp->f_mutex);
> > > > > + if (sfp->res_in_use) {
> > > > > + mutex_unlock(&sfp->f_mutex);
> > > > > sg_remove_request(sfp, srp);
> > > > > return -EBUSY; /* reserve
> > > > > buffer already being used */
> > > > > }
> > > > > + mutex_unlock(&sfp->f_mutex);
> > > > Holding a mutex over a the check of a single scalar doesn't
> > > > make sense.
> > > >
> > > It's adds a synchronisation point, doesn't it?
> > It does, but it doesn't actually protect anything..
>
> But all the other mutex_{un,}locks() do (for instance guarding
> sg_build_indirect()) and this one provides a synchronization point.
>
> Sorry but I really don't get your point here.
>
> The sole purpose is to guard the reserved list from being altered
> while blk_rq_map_* or similar functions are in progess (that's what
> the syzcaller reproducer was doing).
What he means is that naturally aligned reads are always atomic, so
adding further synchronisation gains nothing (you already atomically
get either the prior or next value) and only causes an unnecessary
pipeline stall. From a reviewer's perspective, the sequence
lock
read
unlock
is always a red flag because it means the writer may not understand how
locking works. Usually because the writer thinks there's some other
synchronization they need that this sequence doesn't give.
James
next prev parent reply other threads:[~2017-02-03 18:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 13:12 [PATCHv3 0/6] sanitize sg Hannes Reinecke
2017-02-03 13:12 ` [PATCHv3 1/6] sg: disable SET_FORCE_LOW_DMA Hannes Reinecke
2017-02-03 13:29 ` Christoph Hellwig
2017-02-03 13:12 ` [PATCHv3 2/6] sg: remove 'save_scat_len' Hannes Reinecke
2017-02-03 13:29 ` Christoph Hellwig
2017-02-03 13:12 ` [PATCHv3 3/6] sg: protect accesses to 'reserved' page array Hannes Reinecke
2017-02-03 13:31 ` Christoph Hellwig
2017-02-03 13:38 ` Hannes Reinecke
2017-02-03 16:19 ` Christoph Hellwig
2017-02-03 18:06 ` Johannes Thumshirn
2017-02-03 18:21 ` James Bottomley [this message]
2017-02-03 13:12 ` [PATCHv3 4/6] sg: check for valid direction before starting the request Hannes Reinecke
2017-02-03 13:12 ` [PATCHv3 5/6] sg: use standard lists for sg_requests Hannes Reinecke
2017-02-03 13:12 ` [PATCHv3 6/6] sg: close race condition in sg_remove_sfp_usercontext() Hannes Reinecke
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=1486146084.2431.36.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=dgilbert@interlog.com \
--cc=hare@suse.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jth@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 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.