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]
Date:	Mon, 12 Aug 2013 15:17:45 +0400
From:	Andrew Rybchenko <Andrew.Rybchenko@...etlabs.ru>
To:	Artem Bityutskiy <dedekind1@...il.com>,
	linux-mtd@...ts.infradead.org
Cc:	linux-kernel@...r.kernel.org,
	Andrew Rybchenko <Andrew.Rybchenko@...etlabs.ru>
Subject: [PATCH 1/1] ubi: remove and create MTD device back when UBI volume is resized

If underlying MTD device size is simply corrected (as it was before),
MTD block device is not notified about MTD device size change. As the
result, for example, mount fails after create with zero size, resize,
write file system image.

Side effect of the patch is change of MTD device number on resize/update.

Signed-off-by: Andrew Rybchenko <Andrew.Rybchenko@...etlabs.ru>
---
 drivers/mtd/ubi/gluebi.c |   64 +++++-----------------------------------------
 1 file changed, 7 insertions(+), 57 deletions(-)

diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index b93807b..fa4f764 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -403,60 +403,6 @@ static int gluebi_remove(struct ubi_volume_info *vi)
 }
 
 /**
- * gluebi_updated - UBI volume was updated notifier.
- * @vi: volume info structure
- *
- * This function is called every time an UBI volume is updated. It does nothing
- * if te volume @vol is dynamic, and changes MTD device size if the
- * volume is static. This is needed because static volumes cannot be read past
- * data they contain. This function returns zero in case of success and a
- * negative error code in case of error.
- */
-static int gluebi_updated(struct ubi_volume_info *vi)
-{
-	struct gluebi_device *gluebi;
-
-	mutex_lock(&devices_mutex);
-	gluebi = find_gluebi_nolock(vi->ubi_num, vi->vol_id);
-	if (!gluebi) {
-		mutex_unlock(&devices_mutex);
-		err_msg("got update notification for unknown UBI device %d volume %d",
-			vi->ubi_num, vi->vol_id);
-		return -ENOENT;
-	}
-
-	if (vi->vol_type == UBI_STATIC_VOLUME)
-		gluebi->mtd.size = vi->used_bytes;
-	mutex_unlock(&devices_mutex);
-	return 0;
-}
-
-/**
- * gluebi_resized - UBI volume was re-sized notifier.
- * @vi: volume info structure
- *
- * This function is called every time an UBI volume is re-size. It changes the
- * corresponding fake MTD device size. This function returns zero in case of
- * success and a negative error code in case of error.
- */
-static int gluebi_resized(struct ubi_volume_info *vi)
-{
-	struct gluebi_device *gluebi;
-
-	mutex_lock(&devices_mutex);
-	gluebi = find_gluebi_nolock(vi->ubi_num, vi->vol_id);
-	if (!gluebi) {
-		mutex_unlock(&devices_mutex);
-		err_msg("got update notification for unknown UBI device %d volume %d",
-			vi->ubi_num, vi->vol_id);
-		return -ENOENT;
-	}
-	gluebi->mtd.size = vi->used_bytes;
-	mutex_unlock(&devices_mutex);
-	return 0;
-}
-
-/**
  * gluebi_notify - UBI notification handler.
  * @nb: registered notifier block
  * @l: notification type
@@ -475,10 +421,14 @@ static int gluebi_notify(struct notifier_block *nb, unsigned long l,
 		gluebi_remove(&nt->vi);
 		break;
 	case UBI_VOLUME_RESIZED:
-		gluebi_resized(&nt->vi);
-		break;
 	case UBI_VOLUME_UPDATED:
-		gluebi_updated(&nt->vi);
+		/*
+		 * In theory it could be possible to simply change MTD device
+		 * size, but it would require a way to notify
+		 * corresponding block device as well.
+		 */
+		gluebi_remove(&nt->vi);
+		gluebi_create(&nt->di, &nt->vi);
 		break;
 	default:
 		break;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ