From: Christoph Hellwig <hch@lst.de>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <james.bottomley@hansenpartnership.com>,
Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Bart van Assche <bart.vanassche@sandisk.com>
Subject: Re: [PATCH 11/20] scsi_dh_alua: Use separate alua_port_group structure
Date: Fri, 24 Jul 2015 16:58:11 +0200 [thread overview]
Message-ID: <20150724145811.GA29296@lst.de> (raw)
In-Reply-To: <1436346378-96518-12-git-send-email-hare@suse.de>
On Wed, Jul 08, 2015 at 11:06:09AM +0200, Hannes Reinecke wrote:
> + pg = kzalloc(sizeof(struct alua_port_group), GFP_KERNEL);
> + if (!pg) {
> + sdev_printk(KERN_WARNING, sdev,
> + "%s: kzalloc port group failed\n",
> + ALUA_DH_NAME);
> + /* Temporary failure, bypass */
> + return SCSI_DH_DEV_TEMP_BUSY;
> + }
> + pg->group_id = group_id;
> + pg->buff = pg->inq;
> + pg->bufflen = ALUA_INQUIRY_SIZE;
> + pg->tpgs = h->tpgs;
> + pg->state = TPGS_STATE_OPTIMIZED;
> + kref_init(&pg->kref);
> + spin_lock(&port_group_lock);
> + list_add(&pg->node, &port_group_list);
> + h->pg = pg;
> + spin_unlock(&port_group_lock);
Is there any high level protection against someone racing to allocate
this structure, e.g. from a sysfs-initiated scan?
> - len = (h->buff[0] << 24) + (h->buff[1] << 16) +
> - (h->buff[2] << 8) + h->buff[3] + 4;
> + len = get_unaligned_be32(&pg->buff[0]) + 4;
Andother spurious get/set_unaligned conversion. I'd really recommend doing
all of them before the atual series.
> + rcu_read_lock();
> + pg = rcu_dereference(h->pg);
> + if (!pg) {
> + rcu_read_unlock();
> + return -ENXIO;
> + }
> + rcu_read_unlock();
> +
> if (optimize)
> - h->flags |= ALUA_OPTIMIZE_STPG;
> + pg->flags |= ALUA_OPTIMIZE_STPG;
> else
> - h->flags &= ~ALUA_OPTIMIZE_STPG;
> + pg->flags |= ~ALUA_OPTIMIZE_STPG;
You'll need to move the rcu_read_unlock here to be safe.
next prev parent reply other threads:[~2015-07-24 14:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 9:05 [PATCHv2 00/20] asynchronous ALUA device handler Hannes Reinecke
2015-07-08 9:05 ` [PATCH 01/20] scsi_dh_alua: Disable ALUA handling for non-disk devices Hannes Reinecke
2015-07-08 9:06 ` [PATCH 02/20] scsi_dh_alua: Use vpd_pg83 information Hannes Reinecke
2015-07-08 9:06 ` [PATCH 03/20] scsi_dh_alua: improved logging Hannes Reinecke
2015-07-08 9:06 ` [PATCH 04/20] scsi_dh_alua: Improve error handling Hannes Reinecke
2015-07-24 14:48 ` Christoph Hellwig
2015-07-25 15:42 ` Hannes Reinecke
2015-07-08 9:06 ` [PATCH 05/20] scsi: remove scsi_show_sense_hdr() Hannes Reinecke
2015-07-08 9:06 ` [PATCH 06/20] scsi_dh_alua: use flag for RTPG extended header Hannes Reinecke
2015-07-08 9:06 ` [PATCH 07/20] scsi_dh_alua: Pass buffer as function argument Hannes Reinecke
2015-07-24 14:48 ` Christoph Hellwig
2015-07-08 9:06 ` [PATCH 08/20] scsi_dh_alua: Make stpg synchronous Hannes Reinecke
2015-07-24 14:51 ` Christoph Hellwig
2015-07-25 15:44 ` Hannes Reinecke
2015-07-08 9:06 ` [PATCH 09/20] scsi_dh_alua: switch to scsi_execute() Hannes Reinecke
2015-07-24 14:53 ` Christoph Hellwig
2015-07-25 15:44 ` Hannes Reinecke
2015-07-08 9:06 ` [PATCH 10/20] scsi_dh_alua: put sense buffer on stack Hannes Reinecke
2015-07-08 9:06 ` [PATCH 11/20] scsi_dh_alua: Use separate alua_port_group structure Hannes Reinecke
2015-07-24 14:58 ` Christoph Hellwig [this message]
2015-07-25 15:52 ` Hannes Reinecke
2015-07-08 9:06 ` [PATCH 12/20] scsi_dh_alua: allocate RTPG buffer separately Hannes Reinecke
2015-07-24 14:59 ` Christoph Hellwig
2015-07-08 9:06 ` [PATCH 13/20] scsi_dh_alua: simplify sense code handling Hannes Reinecke
2015-07-24 15:00 ` Christoph Hellwig
2015-07-08 9:06 ` [PATCH 14/20] scsi_dh_alua: parse target device id Hannes Reinecke
2015-07-24 15:07 ` Christoph Hellwig
2015-07-24 15:28 ` Martin K. Petersen
2015-07-25 16:00 ` Hannes Reinecke
2015-07-25 15:53 ` Hannes Reinecke
2015-07-08 9:06 ` [PATCH 15/20] revert "scsi_dh_alua: ALUA hander attach should succeed while TPG is transitioning" Hannes Reinecke
2015-07-08 9:06 ` [PATCH 16/20] scsi_dh_alua: Use workqueue for RTPG Hannes Reinecke
2015-07-24 15:21 ` Christoph Hellwig
2015-07-25 15:58 ` Hannes Reinecke
2015-07-08 9:06 ` [PATCH 17/20] scsi_dh_alua: Recheck state on unit attention Hannes Reinecke
2015-07-08 9:06 ` [PATCH 18/20] scsi_dh_alua: update all port states Hannes Reinecke
2015-07-08 9:06 ` [PATCH 19/20] scsi_dh_alua: Send TEST UNIT READY to poll for transitioning Hannes Reinecke
2015-07-08 9:06 ` [PATCH 20/20] scsi_dh_alua: Update version to 2.0 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=20150724145811.GA29296@lst.de \
--to=hch@lst.de \
--cc=bart.vanassche@sandisk.com \
--cc=hare@suse.de \
--cc=james.bottomley@hansenpartnership.com \
--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.