lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1462282683-17664-1-git-send-email-jthumshirn@suse.de>
Date:	Tue,  3 May 2016 15:38:03 +0200
From:	Johannes Thumshirn <jthumshirn@...e.de>
To:	Jens Axboe <axboe@...com>
Cc:	linux-block@...r.kernel.org,
	Linux Kernel Mailinglist <linux-kernel@...r.kernel.org>,
	Hannes Reinecke <hare@...e.de>, Alexander Graf <agraf@...e.de>,
	Johannes Thumshirn <jthumshirn@...e.de>
Subject: [PATCH] block: initialize hd_stuct's reference before assigning it

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@...e.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ