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>] [day] [month] [year] [list]
Message-Id: <1472482938-6025-1-git-send-email-arvind.yadav.cs@gmail.com>
Date:   Mon, 29 Aug 2016 20:32:18 +0530
From:   Arvind Yadav <arvind.yadav.cs@...il.com>
To:     gregkh@...uxfoundation.org, arve@...roid.com,
        riandrews@...roid.com, greg@...ah.com
Cc:     devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
        Arvind Yadav <arvind.yadav.cs@...il.com>
Subject: [PATCH] android: ashmem: handle the failures in ashmen driver

Check return value of range_alloc, ashmem_shrink_scan and
register_shrinker. Handle errors correctly.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
---
 drivers/staging/android/ashmem.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index ca9a53c..eacc48d 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -595,6 +595,7 @@ static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
 {
 	struct ashmem_range *range, *next;
 	int ret = ASHMEM_NOT_PURGED;
+	int err;
 
 	list_for_each_entry_safe(range, next, &asma->unpinned_list, unpinned) {
 		/* moved past last applicable page; we can short circuit */
@@ -643,8 +644,11 @@ static int ashmem_pin(struct ashmem_area *asma, size_t pgstart, size_t pgend)
 			 * more complicated, we allocate a new range for the
 			 * second half and adjust the first chunk's endpoint.
 			 */
-			range_alloc(asma, range, range->purged,
-				    pgend + 1, range->pgend);
+			err = range_alloc(asma, range, range->purged,
+					  pgend + 1, range->pgend);
+			if (err)
+				return err;
+
 			range_shrink(range, range->pgstart, pgstart - 1);
 			break;
 		}
@@ -800,7 +804,9 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 				.nr_to_scan = LONG_MAX,
 			};
 			ret = ashmem_shrink_count(&ashmem_shrinker, &sc);
-			ashmem_shrink_scan(&ashmem_shrinker, &sc);
+			if (ret)
+				return ret;
+			ret = ashmem_shrink_scan(&ashmem_shrinker, &sc);
 		}
 		break;
 	}
@@ -870,12 +876,18 @@ static int __init ashmem_init(void)
 		goto out_free2;
 	}
 
-	register_shrinker(&ashmem_shrinker);
+	ret = register_shrinker(&ashmem_shrinker);
+	if (unlikely(ret)) {
+		pr_err("failed to register shrinker!\n");
+		goto out_free3;
+	}
 
 	pr_info("initialized\n");
 
 	return 0;
 
+out_free3:
+	misc_deregister(&ashmem_misc);
 out_free2:
 	kmem_cache_destroy(ashmem_range_cachep);
 out_free1:
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ