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

Re: [Minios-devel] [PATCH 2/2] lib/ukalloc: Add assertion to page allocator compatibility wrapper





On 02/08/2018 04:42 PM, Simon Kuenzer wrote:
uk_get_real_start() is used by the compatibility wrapper
to figure out the address of meta information. This patch
adds an assertion that checks that the meta information pointer
will never be 0x0.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>

Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>

---
  lib/ukalloc/alloc.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/lib/ukalloc/alloc.c b/lib/ukalloc/alloc.c
index cf378d0..8a19421 100644
--- a/lib/ukalloc/alloc.c
+++ b/lib/ukalloc/alloc.c
@@ -114,6 +114,12 @@ static void *uk_get_real_start(const void *ptr)
  {
        void *intptr;
+ /* a ptr less or equal to page size
+        * would mean that the actual allocated
+        * object started at 0x0, so it was NULL
+        */
+       UK_ASSERT((uintptr_t) ptr > __PAGE_SIZE);
+
        intptr = (void *) ALIGN_DOWN((uintptr_t) ptr,
                                     (uintptr_t) __PAGE_SIZE);
        if (intptr == ptr) {


--
Dr. Florian Schmidt
フローリアン・シュミット
Research Scientist,
Systems and Machine Learning Group
NEC Laboratories Europe
Kurfürsten-Anlage 36, D-69115 Heidelberg
Tel.     +49 (0)6221 4342-265
Fax:     +49 (0)6221 4342-155
e-mail:  florian.schmidt@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.