- blockdevc-check-errors-fix.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     Correct add_bd_holder() return value

has been removed from the -mm tree.  Its filename is

     blockdevc-check-errors-fix.patch

This patch was dropped because it was folded into blockdevc-check-errors.patch

------------------------------------------------------
Subject: Correct add_bd_holder() return value
From: "Jun'ichi Nomura" <j-nomura@xxxxxxxxxxxxx>

In blockdevc-check-errors.patch, add_bd_holder() is modified to
return error values when some of its operation failed.
Among them, it returns -EEXIST when a given bd_holder object already
exists in the list.
However, in this case, the function completed its work successfully
and need no action by its caller other than freeing unused bd_holder
object.
So I think it's better to return success after freeing by itself.

Otherwise, bd_claim-ing with same claim pointer will fail.
Typically, lvresize will fails with following message:
  device-mapper: reload ioctl failed: Invalid argument
and you'll see messages like below in kernel log:
  device-mapper: table: 254:13: linear: dm-linear: Device lookup failed
  device-mapper: ioctl: error adding target to table

Similarly, it should not add bd_holder to the list if either one
of symlinking fails. I don't have a test case for this to happen
but it should cause dereference of freed pointer.






If a matching bd_holder is found in bd_holder_list, add_bd_holder()
completes its job by just incrementing the reference count.  In this case,
it should be considered as success but it used to return 'fail' to let the
caller free temporary bd_holder.  Fixed it to return success and free given
object by itself.

Also, if either one of symlinking fails, the bd_holder should not be added
to the list so that it can be discarded later.  Otherwise, the caller will
free bd_holder which is in the list.

Signed-off-by: Jun'ichi Nomura <j-nomura@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 fs/block_dev.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff -puN fs/block_dev.c~blockdevc-check-errors-fix fs/block_dev.c
--- a/fs/block_dev.c~blockdevc-check-errors-fix
+++ a/fs/block_dev.c
@@ -650,8 +650,8 @@ static void free_bd_holder(struct bd_hol
  * If there is no matching entry with @bo in @bdev->bd_holder_list,
  * add @bo to the list, create symlinks.
  *
- * Returns 0 if @bo was added to the list.
- * Returns -ve if @bo wasn't used by any reason and should be freed.
+ * Returns 0 if symlinks are created or already there.
+ * Returns -ve if something fails and @bo can be freed.
  */
 static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo)
 {
@@ -664,7 +664,9 @@ static int add_bd_holder(struct block_de
 	list_for_each_entry(tmp, &bdev->bd_holder_list, list) {
 		if (tmp->sdir == bo->sdir) {
 			tmp->count++;
-			return -EEXIST;
+			/* We've already done what we need to do here. */
+			free_bd_holder(bo);
+			return 0;
 		}
 	}
 
@@ -677,7 +679,8 @@ static int add_bd_holder(struct block_de
 		if (ret)
 			del_symlink(bo->sdir, bo->sdev);
 	}
-	list_add_tail(&bo->list, &bdev->bd_holder_list);
+	if (ret == 0)
+		list_add_tail(&bo->list, &bdev->bd_holder_list);
 	return ret;
 }
 
_

Patches currently in -mm which might be from j-nomura@xxxxxxxxxxxxx are

blockdevc-check-errors.patch
blockdevc-check-errors-fix.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux