* [PATCH] block: initialize hd_stuct's reference before assigning it
@ 2016-05-03 13:38 Johannes Thumshirn
2016-05-03 13:46 ` Hannes Reinecke
2016-05-06 10:26 ` Johannes Thumshirn
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2016-05-03 13:38 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Linux Kernel Mailinglist, Hannes Reinecke,
Alexander Graf, Johannes Thumshirn
Inititialize the hd_struct's perpcu reference before assigning the hd_struct
to the partition table list.
This fixes a race which could be triggered using a simple partition
creation/deletion loop with virtio-blk on aarch64.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
block/partition-generic.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/partition-generic.c b/block/partition-generic.c
index 5d87019..aa5b83a 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -361,6 +361,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
goto out_del;
}
+ err = -ENOMEM;
+ if (hd_ref_init(p))
+ goto out_free_info;
+
/* everything is up and running, commence */
rcu_assign_pointer(ptbl->part[partno], p);
@@ -368,8 +372,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
if (!dev_get_uevent_suppress(ddev))
kobject_uevent(&pdev->kobj, KOBJ_ADD);
- if (!hd_ref_init(p))
- return p;
+ return p;
out_free_info:
free_part_info(p);
--
1.8.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: initialize hd_stuct's reference before assigning it
2016-05-03 13:38 [PATCH] block: initialize hd_stuct's reference before assigning it Johannes Thumshirn
@ 2016-05-03 13:46 ` Hannes Reinecke
2016-05-06 10:26 ` Johannes Thumshirn
1 sibling, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2016-05-03 13:46 UTC (permalink / raw)
To: Johannes Thumshirn, Jens Axboe
Cc: linux-block, Linux Kernel Mailinglist, Alexander Graf
On 05/03/2016 03:38 PM, Johannes Thumshirn wrote:
> Inititialize the hd_struct's perpcu reference before assigning the hd_struct
> to the partition table list.
>
> This fixes a race which could be triggered using a simple partition
> creation/deletion loop with virtio-blk on aarch64.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
> block/partition-generic.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/block/partition-generic.c b/block/partition-generic.c
> index 5d87019..aa5b83a 100644
> --- a/block/partition-generic.c
> +++ b/block/partition-generic.c
> @@ -361,6 +361,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
> goto out_del;
> }
>
> + err = -ENOMEM;
> + if (hd_ref_init(p))
> + goto out_free_info;
> +
> /* everything is up and running, commence */
> rcu_assign_pointer(ptbl->part[partno], p);
>
> @@ -368,8 +372,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
> if (!dev_get_uevent_suppress(ddev))
> kobject_uevent(&pdev->kobj, KOBJ_ADD);
>
> - if (!hd_ref_init(p))
> - return p;
> + return p;
>
> out_free_info:
> free_part_info(p);
>
Suggested-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
:-)
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: initialize hd_stuct's reference before assigning it
2016-05-03 13:38 [PATCH] block: initialize hd_stuct's reference before assigning it Johannes Thumshirn
2016-05-03 13:46 ` Hannes Reinecke
@ 2016-05-06 10:26 ` Johannes Thumshirn
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2016-05-06 10:26 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Linux Kernel Mailinglist, Hannes Reinecke,
Alexander Graf, Johannes Thumshirn
On Tue, May 03, 2016 at 03:38:03PM +0200, Johannes Thumshirn wrote:
> Inititialize the hd_struct's perpcu reference before assigning the hd_struct
> to the partition table list.
>
> This fixes a race which could be triggered using a simple partition
> creation/deletion loop with virtio-blk on aarch64.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
> block/partition-generic.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/block/partition-generic.c b/block/partition-generic.c
> index 5d87019..aa5b83a 100644
> --- a/block/partition-generic.c
> +++ b/block/partition-generic.c
> @@ -361,6 +361,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
> goto out_del;
> }
>
> + err = -ENOMEM;
> + if (hd_ref_init(p))
> + goto out_free_info;
> +
> /* everything is up and running, commence */
> rcu_assign_pointer(ptbl->part[partno], p);
>
> @@ -368,8 +372,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
> if (!dev_get_uevent_suppress(ddev))
> kobject_uevent(&pdev->kobj, KOBJ_ADD);
>
> - if (!hd_ref_init(p))
> - return p;
> + return p;
>
> out_free_info:
> free_part_info(p);
> --
> 1.8.5.2
>
We've just seen that this is already fixed with b30a337ca 'block: partition:
initialize percpuref before sending out KOBJ_ADD'
Sorry for the noise,
Johannes
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-06 10:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-03 13:38 [PATCH] block: initialize hd_stuct's reference before assigning it Johannes Thumshirn
2016-05-03 13:46 ` Hannes Reinecke
2016-05-06 10:26 ` Johannes Thumshirn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox